citrine.resources.team module

Resources that represent both individual and collections of teams.

class citrine.resources.team.Team(name: str, *, description: str = '', session: Session | None = None)

Bases: Resource[Team]

A Citrine Team.

A Team is a collection of projects and resources.

Parameters:
  • name (str) – Name of the team.

  • description (str) – Long-form description of the team.

  • session (Session, optional) – The Citrine session used to connect to the database.

access_control_dict() dict

Return an access control entity representation of this resource. Internal use only.

add_user(user_id: str | UUID | User, *, actions: List[WRITE | READ | SHARE] | None = None) bool

Add a User to a Team.

Requires admin privileges.

If no actions are specified, adds User with READ action to the Team.

Use the update_user_action method to change a User’s actions.

Parameters:
  • user_id (User, str or uuid) – The id of the user to add to the team

  • actions (list of TEAM_ACTIONS) – The actions to give the new user in this team The options are: WRITE, READ, SHARE defaults to READ

Returns:

Returns True if user successfully added

Return type:

bool

classmethod build(data: dict) Self

Build an instance of this object from given data.

dump() dict

Dump this instance.

gemd_batch_delete(id_list: List[LinkByUID | UUID | str | BaseEntity], *, timeout: float = 120, polling_delay: float = 1.0) List[Tuple[LinkByUID, ApiError]]

Remove a set of GEMD objects.

You may provide GEMD objects that reference each other, and the objects will be removed in the appropriate order.

A failure will be returned if the object cannot be deleted due to an external reference.

You must have Write access on the associated datasets for each object.

Parameters:
  • id_list (List[Union[LinkByUID, UUID, str, BaseEntity]]) – A list of the IDs of data objects to be removed. They can be passed as a LinkByUID tuple, a UUID, a string, or the object itself. A UUID or string is assumed to be a Citrine ID, whereas a LinkByUID or BaseEntity can also be used to provide an external ID.

  • timeout (float) – Amount of time to wait on the job (in seconds) before giving up. Defaults to 2 minutes. Note that this number has no effect on the underlying job itself, which can also time out server-side.

  • polling_delay (float) – How long to delay between each polling retry attempt (in seconds).

Returns:

A list of (LinkByUID, api_error) for each failure to delete an object. Note that this method doesn’t raise an exception if an object fails to be deleted.

Return type:

List[Tuple[LinkByUID, ApiError]]

get_member(user_id: str | UUID | User) TeamMember

Get a particular member in the current team.

May require admin privileges depending on which user is being requested.

Parameters:

user_id (str or uuid) – The id of the user to remove from the team

Returns:

The requested team member

Return type:

TeamMember

list_members() List[TeamMember]

List all of the members in the current team.

Requires admin privileges.

Returns:

The members of the current team

Return type:

List[TeamMember]

me() TeamMember

Get the member for the current user.

Returns:

The TeamMember object representing the current user

Return type:

TeamMember

owned_dataset_ids() List[str]

List all the ids of the datasets owned by the current team.

Returns:

The ids of the modules owned by current team

Return type:

List[str]

remove_user(user_id: str | UUID | User) bool

Remove a User from a Team.

Requires admin privileges.

Parameters:

user_id (User, str or uuid) – The id of the user to remove from the team

Returns:

Returns True if user successfully removed

Return type:

bool

share(*, resource: Resource, target_team_id: str | UUID | Team) bool

Share a resource with another team.

Requires SHARE action.

Parameters:
  • resource (Resource) – The resource owned by this team, which will be shared

  • target_team_id (Union[str, UUID, Team]) – The id of the team with which to share the resource

Returns:

Returns True if resource successfully shared

Return type:

bool

un_share(*, resource: Resource, target_team_id: str | UUID | Team) bool

Revoke the share of a particular resource to a secondary team.

Requires SHARE action.

Parameters:
  • resource (Resource) – The resource owned by this team, which will be un-shared

  • target_team_id (Union[str, UUID, Team]) – The id of the team which should not have access to the resource

Returns:

Returns True if resource successfully un-shared

Return type:

bool

update_user_action(user_id: str | UUID | User, *, actions: List[WRITE | READ | SHARE]) bool

Overwrites a User’s action permissions in the Team.

Requires admin privileges.

Parameters:
  • user_id (User, str or uuid) – The id of the user to add to the team

  • actions (list of TEAM_ACTIONS) – The actions to give the new user in this team The options are: WRITE, READ, SHARE

Returns:

Returns True if user successfully added

Return type:

bool

property analyses: AnalysisWorkflowCollection

Return a resource representing all visible analysis workflows in this team.

property condition_templates: ConditionTemplateCollection

Return a resource representing all condition templates in this dataset.

created_at = None

Time the team was created, in seconds since epoch.

Type:

int

property dataset_ids: TeamResourceIDs

Return a TeamResourceIDs instance for listing published dataset IDs.

property datasets: DatasetCollection

Return a resource representing all visible datasets.

description: str = None

Description of the Team

Type:

str

property gemd: GEMDResourceCollection

Return a resource representing all GEMD objects/templates in this dataset.

property ingredient_runs: IngredientRunCollection

Return a resource representing all ingredient runs in this dataset.

property ingredient_specs: IngredientSpecCollection

Return a resource representing all ingredient specs in this dataset.

property material_runs: MaterialRunCollection

Return a resource representing all material runs in this dataset.

property material_specs: MaterialSpecCollection

Return a resource representing all material specs in this dataset.

property material_templates: MaterialTemplateCollection

Return a resource representing all material templates in this dataset.

property measurement_runs: MeasurementRunCollection

Return a resource representing all measurement runs in this dataset.

property measurement_specs: MeasurementSpecCollection

Return a resource representing all measurement specs in this dataset.

property measurement_templates: MeasurementTemplateCollection

Return a resource representing all measurement templates in this dataset.

property module_ids: TeamResourceIDs

Return a TeamResourceIDs instance for listing published module IDs.

name: str = None

Name of the Team

Type:

str

property parameter_templates: ParameterTemplateCollection

Return a resource representing all parameter templates in this dataset.

property process_runs: ProcessRunCollection

Return a resource representing all process runs in this dataset.

property process_specs: ProcessSpecCollection

Return a resource representing all process specs in this dataset.

property process_templates: ProcessTemplateCollection

Return a resource representing all process templates in this dataset.

property projects: ProjectCollection

Return a resource representing all visible projects in this team.

property property_templates: PropertyTemplateCollection

Return a resource representing all property templates in this dataset.

property table_definition_ids: TeamResourceIDs

Return a TeamResourceIDs instance for listing published table definition IDs.

property table_ids: TeamResourceIDs

Return a TeamResourceIDs instance for listing published table IDs.

uid = None

Unique uuid4 identifier of this team.

Type:

UUID

class citrine.resources.team.TeamCollection(session: Session)

Bases: AdminCollection[Team]

Represents the collection of all teams as well as the resources belonging to it.

Parameters:

session (Session, optional) – The Citrine session used to connect to the database.

build(data) Team

Build an individual team from a dictionary.

Parameters:

data (dict) – A dictionary representing the team.

Returns:

The team created from data.

Return type:

Team

delete(uid: UUID | str) Response

Delete a particular element of the collection.

get(uid: UUID | str) ResourceType

Get a particular element of the collection.

list(*, per_page: int = 100, as_admin: bool = False) Iterator[ResourceType]

Paginate over the elements of the collection.

Leaving page and per_page as default values will yield all elements in the collection, paginating over all available pages.

Parameters:
  • per_page (int, optional) – Max number of results to return per page. Default is 100. This parameter is used when making requests to the backend service. If the page parameter is specified it limits the maximum number of elements in the response.

  • as_admin (bool, optional) – Whether this request should be made as an admin (returning all teams, rather than only those to which the user belongs).

Returns:

An iterator that can be used to loop over all the resources in this collection. Use list() to force evaluation of all results into an in-memory list.

Return type:

Iterator[ResourceType]

register(name: str, *, description: str = '') Team

Create and upload new team.

Automatically grants user READ, WRITE, and SHARE access to this team.

Parameters:
  • name (str) – Name of the team to be created.

  • description (str) – Long-form description of the team to be created.

update(team: Team) Team

Update a particular team.

You can only update the name and/or description. :param team: The Team Resource to be updated :type team: Team

class citrine.resources.team.TeamMember(*, user: User, team: Team, actions: List[WRITE | READ | SHARE])

Bases: object

A Member of a Team.

class citrine.resources.team.TeamResourceIDs(session: Session, team_id: str | UUID, resource_type: str)

Bases: object

A Citrine Team Resource IDs class.

This class is used to list the unique IDs for specific resource types published in a single team and therefore available to be pulled in by all projects.

Parameters:
  • team_id (str or uuid) – ID of the team.

  • resource_type (str) – The resource type to list, one of DATASET/MODULE/TABLE/TABLE_DEFINITION

list_readable()

List IDs of the published resources with READ access.

Returns:

Returns a list of string UUIDs for each resource

Return type:

List[str]

list_shareable()

List IDs of the published resources with SHARE access.

Returns:

Returns a list of string UUIDs for each resource

Return type:

List[str]

list_writeable()

List IDs of the published resources with WRITE access.

Returns:

Returns a list of string UUIDs for each resource

Return type:

List[str]