gitcode_api.resources.misc

Release, tag, and webhook resource groups.

Classes

AsyncReleasesResource(client)

Asynchronous release endpoints.

AsyncTagsResource(client)

Asynchronous tag endpoints.

AsyncWebhooksResource(client)

Asynchronous webhook endpoints.

ReleasesResource(client)

Synchronous release endpoints.

TagsResource(client)

Synchronous tag endpoints.

WebhooksResource(client)

Synchronous webhook endpoints.

class ReleasesResource(client: SyncAPIClient)

Bases: SyncResource

Synchronous release endpoints.

Bind the resource to a synchronous API client.

update(*, release_id: int | str, tag_name: str, name: str, body: str, owner: str | None = None, repo: str | None = None) Release

Update a repository release.

Parameters:
  • release_id – Release identifier.

  • tag_name – Tag name for the release.

  • name – Release name.

  • body – Release description.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository name. Uses the client default when omitted.

Returns:

Updated release payload.

get_by_tag(*, tag: str, owner: str | None = None, repo: str | None = None) Release

Get a repository release by tag name.

Parameters:
  • tag – Git tag the release is attached to.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Release metadata for that tag.

list(*, owner: str | None = None, repo: str | None = None) List[Release]

List releases for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Releases ordered as returned by the API.

class TagsResource(client: SyncAPIClient)

Bases: SyncResource

Synchronous tag endpoints.

Bind the resource to a synchronous API client.

list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Tag]

List tags for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Tags.

create(*, refs: str, tag_name: str, owner: str | None = None, repo: str | None = None, tag_message: str | None = None) Tag

Create a tag for a repository.

Parameters:
  • refs – Object SHA or ref the tag should point to.

  • tag_name – Name of the new tag.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • tag_message – Optional annotated tag message.

Returns:

Created tag.

list_protected(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[ProtectedTag]

List protected tags for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Protected tag rules.

delete_protected(*, tag_name: str, owner: str | None = None, repo: str | None = None) None

Delete a protected tag rule.

Parameters:
  • tag_name – Protected tag name in the URL path.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

get_protected(*, tag_name: str, owner: str | None = None, repo: str | None = None) ProtectedTag

Get details for a protected tag rule.

Parameters:
  • tag_name – Tag name in the path.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Protected tag configuration.

create_protected(*, name: str, owner: str | None = None, repo: str | None = None, create_access_level: int | None = None) ProtectedTag

Create a protected tag rule.

Parameters:
  • name – Tag name or pattern to protect.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • create_access_level – Minimum access level required to create matching tags (API-specific integer).

Returns:

Created rule.

update_protected(*, name: str, create_access_level: int, owner: str | None = None, repo: str | None = None) ProtectedTag

Update a protected tag rule.

class WebhooksResource(client: SyncAPIClient)

Bases: SyncResource

Synchronous webhook endpoints.

Bind the resource to a synchronous API client.

list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Webhook]

List webhooks for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Hook configurations.

create(*, url: str, owner: str | None = None, repo: str | None = None, **payload) Webhook

Create a repository webhook.

Parameters:
  • url – Payload URL GitCode should POST events to.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • payload – Additional fields from the Webhooks API (events list, secret, content type, etc.).

Returns:

Created webhook.

get(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) Webhook

Get a repository webhook by identifier.

Parameters:
  • hook_id – Webhook id from the API.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Webhook configuration.

update(*, hook_id: int | str, url: str, owner: str | None = None, repo: str | None = None, **payload) Webhook

Update a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • url – New payload URL (merged into the JSON body).

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • payload – Other mutable webhook fields accepted by the API.

Returns:

Updated webhook.

delete(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) None

Delete a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

test(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) None

Send a test delivery for a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

class AsyncReleasesResource(client: AsyncAPIClient)

Bases: AsyncResource

Asynchronous release endpoints.

Mirrors ReleasesResource; see that class for parameters (Release API in docs/rest_api).

Bind the resource to an asynchronous API client.

async update(*, release_id: int | str, tag_name: str, name: str, body: str, owner: str | None = None, repo: str | None = None) Release

Update a repository release.

Parameters:
  • release_id – Release identifier.

  • tag_name – Tag name for the release.

  • name – Release name.

  • body – Release description.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository name. Uses the client default when omitted.

Returns:

Updated release payload.

async get_by_tag(*, tag: str, owner: str | None = None, repo: str | None = None) Release

Get a repository release by tag name.

Parameters:
  • tag – Git tag the release is attached to.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Release metadata for that tag.

async list(*, owner: str | None = None, repo: str | None = None) List[Release]

List releases for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Releases ordered as returned by the API.

class AsyncTagsResource(client: AsyncAPIClient)

Bases: AsyncResource

Asynchronous tag endpoints.

Mirrors TagsResource; see that class and docs/rest_api/repos/tag for semantics.

Bind the resource to an asynchronous API client.

async list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Tag]

List tags for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Tags.

async create(*, refs: str, tag_name: str, owner: str | None = None, repo: str | None = None, tag_message: str | None = None) Tag

Create a tag for a repository.

Parameters:
  • refs – Object SHA or ref the tag should point to.

  • tag_name – Name of the new tag.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • tag_message – Optional annotated tag message.

Returns:

Created tag.

async list_protected(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[ProtectedTag]

List protected tags for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Protected tag rules.

async delete_protected(*, tag_name: str, owner: str | None = None, repo: str | None = None) None

Delete a protected tag rule.

Parameters:
  • tag_name – Protected tag name in the URL path.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

async get_protected(*, tag_name: str, owner: str | None = None, repo: str | None = None) ProtectedTag

Get details for a protected tag rule.

Parameters:
  • tag_name – Tag name in the path.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Protected tag configuration.

async create_protected(*, name: str, owner: str | None = None, repo: str | None = None, create_access_level: int | None = None) ProtectedTag

Create a protected tag rule.

Parameters:
  • name – Tag name or pattern to protect.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • create_access_level – Minimum access level required to create matching tags (API-specific integer).

Returns:

Created rule.

async update_protected(*, name: str, create_access_level: int, owner: str | None = None, repo: str | None = None) ProtectedTag

Update a protected tag rule.

Parameters:
  • name – Tag name or pattern.

  • create_access_level – New create access level.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Updated rule.

class AsyncWebhooksResource(client: AsyncAPIClient)

Bases: AsyncResource

Asynchronous webhook endpoints.

Mirrors WebhooksResource; see that class and docs/rest_api/repos/webhooks.

Bind the resource to an asynchronous API client.

async list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Webhook]

List webhooks for a repository.

Parameters:
  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • page – Page number.

  • per_page – Page size.

Returns:

Hook configurations.

async create(*, url: str, owner: str | None = None, repo: str | None = None, **payload) Webhook

Create a repository webhook.

Parameters:
  • url – Payload URL GitCode should POST events to.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • payload – Additional fields from the Webhooks API (events list, secret, content type, etc.).

Returns:

Created webhook.

async get(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) Webhook

Get a repository webhook by identifier.

Parameters:
  • hook_id – Webhook id from the API.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

Returns:

Webhook configuration.

async update(*, hook_id: int | str, url: str, owner: str | None = None, repo: str | None = None, **payload) Webhook

Update a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • url – New payload URL (merged into the JSON body).

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

  • payload – Other mutable webhook fields accepted by the API.

Returns:

Updated webhook.

async delete(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) None

Delete a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.

async test(*, hook_id: int | str, owner: str | None = None, repo: str | None = None) None

Send a test delivery for a repository webhook.

Parameters:
  • hook_id – Webhook id.

  • owner – Repository owner path. Uses the client default when omitted.

  • repo – Repository path. Uses the client default when omitted.