A developer guide for querying organization information via the Python SDK.
organization = client.get_organization()
# 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)
organization.create_resource_tag(
{
"text": "new-tag-name",
"color": "ffffff"
}
)
# get the project tags (returns a list of ResourceTag objects)
tags = organization.get_resource_tags()
for tag in tags:
print(tag)
# 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"]
)
project_id = "<project_id>"
# For the entire organization
org_invites = organization.get_invites()
# For a specific project
project_invites = organization.get_project_invites(project_id)
email = "<email_address>""
project_id = "<project_id>"
# Option 1: organization invite
invite = next(
invite for invite in org.get_invites() if invite.email == email
)
# Option 2: project invite
invite = next(
invite for invite in org.get_project_invites(project_id) if invite.email == email
)
invite.cancel()
# already accounts for users currently in the organization, thus:
# used = users + invites_sent
# remaining = limit - used
organization.invite_limit()
# the argument must be a User object
organization.remove_user(user)
# name (str)
organization.name
# created_at (datetime)
organization.created_at
# updated_at (datetime)
organization.updated_at
# 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 (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 (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)
# All tasks
tasks = organization.tasks()
# Tasks in progress
org_tasks_in_progress = organization.tasks(where=Task.status_as_enum == TaskStatus.In_Progress)
# Failed tasks
org_task_failed = organization.tasks(where=Task.status_as_enum == TaskStatus.Failed)