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)

Fetch 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 a single project.
>>> project = dt.Project.get_project('<PROJECT_ID>')
disruptive.Project.list_projects(organization_id=None, query=None, **kwargs)

Fetch a list of all available projects.

Parameters
  • organization_id (str, optional) – Specify an organization by its unique identifier.

  • 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 a list of all available projects.
>>> projects = dt.Project.list_projects()
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 with the name "my-new-project".
>>> project = dt.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 to "new-name".
>>> dt.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.
>>> dt.Project.delete_project('<PROJECT_ID>')
Return type

None

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

Gets a list 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 = dt.Project.list_members('<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) – User- or Service Account email address.

  • 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 member with the role project.developer.
>>> member = dt.Project.add_member(
...     project_id='<PROJECT_ID>',
...     email='<MEMBER_EMAIL_ADDRESS>',
...     roles=[dt.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 member identifier. 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 a member's role to project.user.
>>> member = dt.Project.update_member(
...     member_id='<MEMBER_ID>',
...     project_id='<PROJECT_ID>',
...     roles=[dt.Role.PROJECT_USER],
... )
disruptive.Project.remove_member(member_id, project_id, **kwargs)

Revoke a member’s membership in the specified project. This does not delete the underlying Service Account or User.

Parameters
  • member_id (str) – Unique member identifier. 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.
>>> dt.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 = dt.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 = dt.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
  • project_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.

  • id (str) – Unique project ID (Deprecated in favor of project_id).

  • raw (dict[str, str]) – Unmodified API response JSON.