Skip to content

users

Accessed as client.admin.users; the async client mirrors it.

AdminUsers

The admin.users namespace.

emails

keys

quota

tokens

create

create(
    *,
    created_at: datetime | None = None,
    email: str,
    full_name: str | None = None,
    login_name: str | None = None,
    must_change_password: bool | None = None,
    password: str | None = None,
    restricted: bool | None = None,
    send_notify: bool | None = None,
    source_id: int | None = None,
    username: str,
    visibility: str | None = None,
) -> User

Create a user account.

Parameters:

Name Type Description Default
created_at datetime | None

For explicitly setting the user creation timestamp. Useful when users are migrated from other systems. When omitted, the user's creation timestamp will be set to "now".

None
email str
required
full_name str | None
None
login_name str | None
None
must_change_password bool | None
None
password str | None
None
restricted bool | None
None
send_notify bool | None
None
source_id int | None
None
username str
required
visibility str | None
None

Returns:

Type Description
User

User.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateUser

create_org

create_org(
    username: str,
    *,
    description: str | None = None,
    email: str | None = None,
    full_name: str | None = None,
    location: str | None = None,
    repo_admin_change_team_access: bool | None = None,
    body_username: str,
    visibility: CreateOrgOptionVisibility | None = None,
    website: str | None = None,
) -> Organization

Create an organization.

Parameters:

Name Type Description Default
username str

username of the user that will own the created organization

required
description str | None
None
email str | None
None
full_name str | None
None
location str | None
None
repo_admin_change_team_access bool | None
None
body_username str

Wire field username.

required
visibility CreateOrgOptionVisibility | None

possible values are public (default), limited or private

None
website str | None
None

Returns:

Type Description
Organization

Organization.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateOrg

create_repo

create_repo(
    username: str,
    *,
    auto_init: bool | None = None,
    default_branch: str | None = None,
    description: str | None = None,
    gitignores: str | None = None,
    issue_labels: str | None = None,
    license: str | None = None,
    name: str,
    object_format_name: CreateRepoOptionObjectFormatName | None = None,
    private: bool | None = None,
    readme: str | None = None,
    template: bool | None = None,
    trust_model: CreateRepoOptionTrustModel | None = None,
) -> Repository

Create a repository on behalf of a user.

Parameters:

Name Type Description Default
username str

username of the user. This user will own the created repository

required
auto_init bool | None

Whether the repository should be auto-initialized?

None
default_branch str | None

DefaultBranch of the repository (used when initializes and in template)

None
description str | None

Description of the repository to create

None
gitignores str | None

Gitignores to use, separated by commas

None
issue_labels str | None

Label-Set to use

None
license str | None

License to use

None
name str

Name of the repository to create

required
object_format_name CreateRepoOptionObjectFormatName | None

ObjectFormatName of the underlying git repository

None
private bool | None

Whether the repository is private

None
readme str | None

Readme of the repository to create

None
template bool | None

Whether the repository is template

None
trust_model CreateRepoOptionTrustModel | None

TrustModel of the repository

None

Returns:

Type Description
Repository

Repository.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
ConflictError
  1. APIError is error format response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateRepo

delete

delete(username: str, *, purge: bool | None = None) -> None

Delete user account.

Parameters:

Name Type Description Default
username str

username of user to delete

required
purge bool | None

purge the user from the system completely

None

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminDeleteUser

list

list(
    *,
    source_id: int | None = None,
    login_name: str | None = None,
    is_2fa_enabled: bool | None = None,
    sort: Literal["oldest", "newest", "alphabetically", "reversealphabetically", "recentupdate", "leastupdate"]
    | None = None,
    page: int | None = None,
    limit: int | None = None,
) -> Paginated[User]

Search users according filter conditions.

Parameters:

Name Type Description Default
source_id int | None

ID of the user's login source to search for

None
login_name str | None

user's login name to search for

None
is_2fa_enabled bool | None

whether or not to filter users with the 2fa enabled

None
sort Literal['oldest', 'newest', 'alphabetically', 'reversealphabetically', 'recentupdate', 'leastupdate'] | None

sort order of results

None
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
Paginated[User]

UserList.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.

Operation ID: adminSearchUsers

rename

rename(username: str, *, new_username: str) -> None

Rename a user.

Parameters:

Name Type Description Default
username str

existing username of user

required
new_username str

New username for this user. This name cannot be in use yet by any other user.

required

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminRenameUser

update

update(
    username: str,
    *,
    active: bool | None = None,
    admin: bool | None = None,
    allow_create_organization: bool | None = None,
    allow_git_hook: bool | None = None,
    allow_import_local: bool | None = None,
    description: str | None = None,
    email: str | None = None,
    full_name: str | None = None,
    hide_email: bool | None = None,
    location: str | None = None,
    login_name: str | None = None,
    max_repo_creation: int | None = None,
    must_change_password: bool | None = None,
    password: str | None = None,
    prohibit_login: bool | None = None,
    pronouns: str | None = None,
    restricted: bool | None = None,
    source_id: int | None = None,
    visibility: str | None = None,
    website: str | None = None,
) -> User

Edit an existing user.

Parameters:

Name Type Description Default
username str

username of user to edit

required
active bool | None
None
admin bool | None
None
allow_create_organization bool | None
None
allow_git_hook bool | None
None
allow_import_local bool | None
None
description str | None
None
email str | None
None
full_name str | None
None
hide_email bool | None
None
location str | None
None
login_name str | None
None
max_repo_creation int | None
None
must_change_password bool | None
None
password str | None
None
prohibit_login bool | None
None
pronouns str | None
None
restricted bool | None
None
source_id int | None
None
visibility str | None
None
website str | None
None

Returns:

Type Description
User

User.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminEditUser

AsyncAdminUsers

The admin.users namespace.

emails

tokens

create

create(
    *,
    created_at: datetime | None = None,
    email: str,
    full_name: str | None = None,
    login_name: str | None = None,
    must_change_password: bool | None = None,
    password: str | None = None,
    restricted: bool | None = None,
    send_notify: bool | None = None,
    source_id: int | None = None,
    username: str,
    visibility: str | None = None,
) -> User

Create a user account.

Parameters:

Name Type Description Default
created_at datetime | None

For explicitly setting the user creation timestamp. Useful when users are migrated from other systems. When omitted, the user's creation timestamp will be set to "now".

None
email str
required
full_name str | None
None
login_name str | None
None
must_change_password bool | None
None
password str | None
None
restricted bool | None
None
send_notify bool | None
None
source_id int | None
None
username str
required
visibility str | None
None

Returns:

Type Description
User

User.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateUser

create_org

create_org(
    username: str,
    *,
    description: str | None = None,
    email: str | None = None,
    full_name: str | None = None,
    location: str | None = None,
    repo_admin_change_team_access: bool | None = None,
    body_username: str,
    visibility: CreateOrgOptionVisibility | None = None,
    website: str | None = None,
) -> Organization

Create an organization.

Parameters:

Name Type Description Default
username str

username of the user that will own the created organization

required
description str | None
None
email str | None
None
full_name str | None
None
location str | None
None
repo_admin_change_team_access bool | None
None
body_username str

Wire field username.

required
visibility CreateOrgOptionVisibility | None

possible values are public (default), limited or private

None
website str | None
None

Returns:

Type Description
Organization

Organization.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateOrg

create_repo

create_repo(
    username: str,
    *,
    auto_init: bool | None = None,
    default_branch: str | None = None,
    description: str | None = None,
    gitignores: str | None = None,
    issue_labels: str | None = None,
    license: str | None = None,
    name: str,
    object_format_name: CreateRepoOptionObjectFormatName | None = None,
    private: bool | None = None,
    readme: str | None = None,
    template: bool | None = None,
    trust_model: CreateRepoOptionTrustModel | None = None,
) -> Repository

Create a repository on behalf of a user.

Parameters:

Name Type Description Default
username str

username of the user. This user will own the created repository

required
auto_init bool | None

Whether the repository should be auto-initialized?

None
default_branch str | None

DefaultBranch of the repository (used when initializes and in template)

None
description str | None

Description of the repository to create

None
gitignores str | None

Gitignores to use, separated by commas

None
issue_labels str | None

Label-Set to use

None
license str | None

License to use

None
name str

Name of the repository to create

required
object_format_name CreateRepoOptionObjectFormatName | None

ObjectFormatName of the underlying git repository

None
private bool | None

Whether the repository is private

None
readme str | None

Readme of the repository to create

None
template bool | None

Whether the repository is template

None
trust_model CreateRepoOptionTrustModel | None

TrustModel of the repository

None

Returns:

Type Description
Repository

Repository.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
ConflictError
  1. APIError is error format response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminCreateRepo

delete

delete(username: str, *, purge: bool | None = None) -> None

Delete user account.

Parameters:

Name Type Description Default
username str

username of user to delete

required
purge bool | None

purge the user from the system completely

None

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminDeleteUser

list

list(
    *,
    source_id: int | None = None,
    login_name: str | None = None,
    is_2fa_enabled: bool | None = None,
    sort: Literal["oldest", "newest", "alphabetically", "reversealphabetically", "recentupdate", "leastupdate"]
    | None = None,
    page: int | None = None,
    limit: int | None = None,
) -> AsyncPaginated[User]

Search users according filter conditions.

Parameters:

Name Type Description Default
source_id int | None

ID of the user's login source to search for

None
login_name str | None

user's login name to search for

None
is_2fa_enabled bool | None

whether or not to filter users with the 2fa enabled

None
sort Literal['oldest', 'newest', 'alphabetically', 'reversealphabetically', 'recentupdate', 'leastupdate'] | None

sort order of results

None
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
AsyncPaginated[User]

UserList.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.

Operation ID: adminSearchUsers

rename

rename(username: str, *, new_username: str) -> None

Rename a user.

Parameters:

Name Type Description Default
username str

existing username of user

required
new_username str

New username for this user. This name cannot be in use yet by any other user.

required

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminRenameUser

update

update(
    username: str,
    *,
    active: bool | None = None,
    admin: bool | None = None,
    allow_create_organization: bool | None = None,
    allow_git_hook: bool | None = None,
    allow_import_local: bool | None = None,
    description: str | None = None,
    email: str | None = None,
    full_name: str | None = None,
    hide_email: bool | None = None,
    location: str | None = None,
    login_name: str | None = None,
    max_repo_creation: int | None = None,
    must_change_password: bool | None = None,
    password: str | None = None,
    prohibit_login: bool | None = None,
    pronouns: str | None = None,
    restricted: bool | None = None,
    source_id: int | None = None,
    visibility: str | None = None,
    website: str | None = None,
) -> User

Edit an existing user.

Parameters:

Name Type Description Default
username str

username of user to edit

required
active bool | None
None
admin bool | None
None
allow_create_organization bool | None
None
allow_git_hook bool | None
None
allow_import_local bool | None
None
description str | None
None
email str | None
None
full_name str | None
None
hide_email bool | None
None
location str | None
None
login_name str | None
None
max_repo_creation int | None
None
must_change_password bool | None
None
password str | None
None
prohibit_login bool | None
None
pronouns str | None
None
restricted bool | None
None
source_id int | None
None
visibility str | None
None
website str | None
None

Returns:

Type Description
User

User.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
UnprocessableEntityError
  1. APIValidationError is error format response related to input validation.

Operation ID: adminEditUser