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.
- 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:
- 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:
- 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 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
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
- 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.
- description: str = None
Description of the Team
- Type:
str
- property module_ids: TeamResourceIDs
Return a TeamResourceIDs instance for listing published module IDs.
- name: str = None
Name of the Team
- Type:
str
- property projects: ProjectCollection
Return a resource representing all visible projects in this team.
- 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:
- 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]
- 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 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]