User Group

class labelbox.schema.user_group.UserGroup(client: Client, id: str = '', name: str = '', color: UserGroupColor = UserGroupColor.BLUE, users: Set[User] = {}, projects: Set[Project] = {})[source]

Bases: BaseModel

Represents a user group in Labelbox.

id

The ID of the user group.

Type:

str

name

The name of the user group.

Type:

str

color

The color of the user group.

Type:

UserGroupColor

users

The set of users in the user group.

Type:

Set[UserGroupUser]

projects

The set of projects associated with the user group.

Type:

Set[UserGroupProject]

client

The Labelbox client object.

Type:

Client

__init__(self, client

Client)

get(self) 'UserGroup'[source]
update(self) 'UserGroup'[source]
create(self) 'UserGroup'[source]
delete(self) bool[source]
get_user_groups(client

Client) -> Iterator[“UserGroup”]

create() UserGroup[source]

Creates a new user group.

Raises:
  • ResourceCreationError – If the group already exists.

  • ValueError – If the group name is not provided.

Returns:

The created user group.

Return type:

UserGroup

delete() bool[source]

Deletes the user group from Labelbox.

This method sends a mutation request to the Labelbox API to delete the user group with the specified ID. If the deletion is successful, it returns True. Otherwise, it raises an UnprocessableEntityError and returns False.

Returns:

True if the user group was successfully deleted, False otherwise.

Return type:

bool

Raises:
  • ResourceNotFoundError – If the deletion of the user group fails due to not existing

  • ValueError – If the group ID is not provided.

get() UserGroup[source]

Reloads the user group information from the server.

This method sends a GraphQL query to the server to fetch the latest information about the user group, including its name, color, projects, and members. The fetched information is then used to update the corresponding attributes of the Group object.

Returns:

The updated UserGroup object.

Return type:

UserGroup

Raises:
  • ResourceNotFoundError – If the query fails to fetch the group information.

  • ValueError – If the group ID is not provided.

get_user_groups() Iterator[UserGroup][source]

Gets all user groups in Labelbox.

Parameters:

client (Client) – The Labelbox client.

Returns:

An iterator over the user groups.

Return type:

Iterator[UserGroup]

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'client': FieldInfo(annotation=Client, required=True), 'color': FieldInfo(annotation=UserGroupColor, required=True), 'id': FieldInfo(annotation=str, required=True), 'name': FieldInfo(annotation=str, required=True), 'projects': FieldInfo(annotation=Set[labelbox.schema.project.Project], required=True), 'users': FieldInfo(annotation=Set[labelbox.schema.user.User], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

update() UserGroup[source]

Updates the group in Labelbox.

Returns:

The updated UserGroup object. (self)

Return type:

UserGroup

Raises:
class labelbox.schema.user_group.UserGroupColor(value)[source]

Bases: Enum

Enum representing the colors available for a group.

BLUE

Hex color code for blue (#9EC5FF).

Type:

str

PURPLE

Hex color code for purple (#CEB8FF).

Type:

str

ORANGE

Hex color code for orange (#FFB35F).

Type:

str

CYAN

Hex color code for cyan (#4ED2F9).

Type:

str

PINK

Hex color code for pink (#FFAEA9).

Type:

str

LIGHT_PINK

Hex color code for light pink (#FFA9D5).

Type:

str

GREEN

Hex color code for green (#3FDC9A).

Type:

str

YELLOW

Hex color code for yellow (#E7BF00).

Type:

str

GRAY

Hex color code for gray (#B8C4D3).

Type:

str