Project

The Project resource can be used to interact with projects. Various tasks can be performed by using the API Methods included in the class.

Each project fetched by an API Method is represented by an instance of the Project class that is returned to the user.

API Methods

disruptive.Project.get_project(project_id, **kwargs)

Gets the current state of a single project.

Parameters:
  • project_id (str) – Unique project ID.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

project – Object representing the specified project.

Return type:

Project

Examples

>>> # Fetch information about a specific project.
>>> project = disruptive.Project.get_project(
...     project_id='<PROJECT_ID>',
... )
disruptive.Project.list_projects(organization_id=None, query=None, **kwargs)

Gets a list of the current state of all available projects.

Parameters:
  • organization_id (str) – Unique organization ID.

  • query (str, optional) – Keyword based search for project- and organization display names.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

projects – List of objects each representing a project.

Return type:

list[Project]

Examples

>>> # Fetch information about all projects in an organization.
>>> projects = disruptive.Project.list_projects(
...     organization_id='<ORGANIZATION_ID>',
... )
disruptive.Project.create_project(organization_id, display_name, **kwargs)

Create a new project in the specified organization.

Parameters:
  • organization_id (str) – Unique organization ID.

  • display_name (str) – Sets a display name for the project.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

project – Object representing the newly created project.

Return type:

Project

Examples

>>> # Create a new project.
>>> project = disruptive.Project.create_project(
...     organization_id='<ORGANIZATION_ID>',
...     display_name='my-new-project',
... )
disruptive.Project.update_project(project_id, display_name=None, **kwargs)

Updates the display name a specified project.

Parameters:
  • project_id (str) – Unique ID of the project to update.

  • display_name (str, optional) – If provided, updates the project display name.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Examples

>>> # Update the display_name of a project.
>>> disruptive.Project.update_project(
...     project_id='<PROJECT_ID>',
...     display_name='new-name',
... )
Return type:

None

disruptive.Project.delete_project(project_id, **kwargs)

Deletes the specified project.

Only empty projects can be deleted. If the specified project contains any devices or Data Connectors, an error is raised.

Parameters:
  • project_id (str) – Unique ID of the project to delete.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Raises:

BadRequest – If the specified project contains devices or Data Connectors.

Examples

>>> # Delete the specified project.
>>> disruptive.Project.delete_project(
...     project_id='<PROJECT_ID>',
... )
Return type:

None

disruptive.Project.list_members(project_id, **kwargs)

Gets a list of the current state of all members in a project.

Parameters:
  • project_id (str) – Unique ID of the project to get members from.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

members – List of objects each representing a member.

Return type:

list[Member]

Examples

>>> # List all members in a project.
>>> members = disruptive.Project.list_members(
...     project_id='<PROJECT_ID>',
... )
disruptive.Project.add_member(project_id, email, roles, **kwargs)

Add a new member to the specified project.

Parameters:
  • project_id (str) – Unique ID of the project to add a member to.

  • email (str) – Email of the user or Service Account to be added.

  • roles (list[str]) – The role(s) to provide the new member in the project.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

member – Object representing the newly added member.

Return type:

Member

Examples

>>> # Add a new project.developer member to a project.
>>> member = disruptive.Project.add_member(
...     project_id='<PROJECT_ID>',
...     email='<MEMBER_EMAIL_ADDRESS>',
...     roles=[disruptive.Role.PROJECT_DEVELOPER],
... )
disruptive.Project.update_member(member_id, project_id, roles, **kwargs)

Update the role(s) of the specified member.

Parameters:
  • member_id (str) – Unique ID of the member to get. For Service Account members, this is the Service Account ID. For User members, this is the unique User ID.

  • project_id (str) – Unique ID of the project to update a member in.

  • roles (list[str]) – List of new roles for the specified member.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

member – Object representing the updated member.

Return type:

Member

Examples

>>> # Update the role of a member.
>>> member = disruptive.Project.update_member(
...     member_id='<MEMBER_ID>',
...     project_id='<PROJECT_ID>',
...     roles=[disruptive.Role.PROJECT_USER],
... )
disruptive.Project.remove_member(member_id, project_id, **kwargs)

Revoke a member’s membership in the specified project.

Parameters:
  • member_id (str) – Unique ID of the member to get. For Service Account members, this is the Service Account ID. For User members, this is the unique User ID.

  • project_id (str) – Unique ID of the project to remove a member from.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Examples

>>> # Remove the specified member from a project.
>>> disruptive.Project.remove_member(
...     member_id='<MEMBER_ID>',
...     project_id='<PROJECT_ID>',
... )
Return type:

None

disruptive.Project.get_member_invite_url(member_id, project_id, **kwargs)

Get the invite URL for a member with pending invite.

This will only work if the invite is still pending. If the invite has already been accepted, an error is raised.

Parameters:
  • member_id (str) – Unique ID of the member to get. For Service Account members, this is the Service Account ID. For User members, this is the unique User ID.

  • project_id (str) – Unique ID of the project of the member to get the URL from.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

invite_url – The invite url for the specified member.

Return type:

str

Raises:

BadRequest – If the invite has already been accepted.

Examples

>>> # Fetch the pending invite URL of a member.
>>> url = disruptive.Project.get_member_invite_url(
...     member_id='<MEMBER_ID>',
...     project_id='<PROJECT_ID>',
... )
disruptive.Project.list_permissions(project_id, **kwargs)

List permissions available to the caller in the specified project.

Parameters:
  • project_id (str) – Unique ID of the project to list permissions in.

  • **kwargs – Arbitrary keyword arguments. See the Configuration page.

Returns:

permissions – List of permissions available to the caller.

Return type:

list[str]

Examples

>>> # List the available permissions in a project.
>>> permissions = disruptive.Project.list_permissions('<PROJECT_ID>')

Class

class disruptive.Project(project)

Represents a project.

When a project response is received, the content is unpacked and the related attributes are set.

Variables:
  • id (str) – Unique project ID.

  • display_name (str) – The provided display name.

  • organization_id (str) – Unique ID of parent organization.

  • organization_display_name (str) – The provided display name to parent organization.

  • sensor_count (int) – Number of sensors in project.

  • cloud_connector_count (int) – Number of Cloud Connectors in project.

  • is_inventory (bool) – True if project is organization inventory, otherwise False.