Organization

A developer guide for querying organization information via the Python SDK.

Client

Get the current organization

organization = client.get_organization()

Methods

Get IAM integrations

# get the default IAM integration
default_iam_integration = organization.get_default_iam_integration()

# get all of the IAM integrations (returns a list of IAMIntegration objects)
iam_integrations = organization.get_iam_integrations()

for integration in iam_integrations:
  print(integration)

Create a project tag

organization.create_resource_tag(
  {
    "text": "new-tag-name",
    "color": "ffffff"
  }
)

Get the project tags

# get the project tags (returns a list of ResourceTag objects)
tags = organization.get_resource_tags()

for tag in tags:
  print(tag)

Invite a user

# get and view the available roles
roles = client.get_roles()
print("Roles: ", roles)

# create an invitation for an organization-wide role (in this case, a labeler)
organization.invite_user(
    email="<email_address>",
    role=roles["LABELER"]
)
# get and view the available roles
roles = client.get_roles()
print("Roles: ", roles)

# get a project
project = client.get_project("<project_id>")

# create an invitation for a project-based role, in this case a labeler on one project
org.invite_user(
  email="<email_address>",
  # for a project-based role, the org-wide role must be NONE
  role=roles["NONE"],
  # create a ProjectRole object for each project that the user should have access to
  project_roles=[lb.ProjectRole(
    project=project,
    role=roles["LABELER"]
  )]
)

View the invite limit

# already accounts for users currently in the organization, thus:
# 	used = users + invites_sent
# 	remaining = limit - used
organization.invite_limit()

Remove a user

# the argument must be a User object
organization.remove_user(user)

Attributes

Get the basics

# name (str)
organization.name

# created_at (datetime)
organization.created_at

# updated_at (datetime)
organization.updated_at

Get the users

# get the users (relationship to User objects)
users = organization.users()

# inspect one user
next(users)

# inspect all users
for user in users:
  print(user)
  
# for ease of use, you can convert the paginated collection to a list
list(users)

Get the projects

# get the projects (relationship to Project objects)
projects = organization.projects()

# inspect one project
next(projects)

# inspect all projects
for project in projects:
  print(project)

# for ease of use, you can convert the paginated collection to a list
list(projects)

Get the webhooks

# get the webhooks (relationship to Webhook objects)
webhooks = organization.webhooks()

# inspect one webhook
next(webhooks)

# inspect all webhooks
for webhook in webhooks:
  print(webhook)

# for ease of use, you can convert the paginated collection to a list
list(webhooks)