gitcode_api.resources
Public resource group exports for the GitCode SDK.
- class AsyncBranchesResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous branch endpoints.
Mirrors
BranchesResource(docs/rest_api/repos/branch).Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Branch]
List branches in a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sort – Optional sort field such as
nameorupdated.direction – Sort direction, usually
ascordesc.page – Page number.
per_page – Page size.
- Returns:
Repository branches.
- async get(*, branch: str, owner: str | None = None, repo: str | None = None) BranchDetail
Get a single branch.
- Parameters:
branch – Branch name.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Branch details.
- async create(*, branch: str, ref: str, owner: str | None = None, repo: str | None = None) Branch
Create a branch from an existing ref.
- Parameters:
branch – New branch name.
ref – Starting ref such as a branch, tag, or commit SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Created branch details.
- async list_protected(*, owner: str | None = None, repo: str | None = None) List[ProtectedBranch]
List protected branch rules for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Protected branch rules.
- class AsyncCommitsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous commit endpoints.
Mirrors
CommitsResource(docs/rest_api/repos/commit).Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None, sha: str | None = None, path: str | None = None, page: int | None = None, per_page: int | None = None) List[CommitSummary]
List commits in a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sha – Optional starting SHA or ref.
path – Optional file path filter.
page – Page number.
per_page – Page size.
- Returns:
Matching commits.
- async get(*, sha: str, owner: str | None = None, repo: str | None = None) Commit
Get a single commit.
- Parameters:
sha – Commit SHA or branch name accepted by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit details.
- async compare(*, base: str, head: str, owner: str | None = None, repo: str | None = None) CommitComparison
Compare two refs in a repository.
- Parameters:
base – Base commit SHA, branch, or tag.
head – Head commit SHA, branch, or tag.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit comparison payload.
- async list_comments(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[CommitComment]
List commit comments for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Commit comments.
- async get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) CommitComment
Get a single commit comment.
- Parameters:
comment_id – Commit comment identifier.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit comment details.
- async create_comment(*, sha: str, body: str, owner: str | None = None, repo: str | None = None, path: str | None = None, position: int | None = None) CommitComment
Create a comment on a commit.
- Parameters:
sha – Commit SHA.
body – Comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
path – Optional file path associated with the comment.
position – Optional diff position.
- Returns:
Created commit comment.
- async update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) CommitComment
Update a commit comment.
- Parameters:
comment_id – Commit comment identifier.
body – Updated comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Updated commit comment.
- async delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete a commit comment.
- Parameters:
comment_id – Commit comment identifier.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- class AsyncIssuesResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous issue endpoints.
Methods correspond one-to-one with
IssuesResource; signatures, JSON/query payloads, and return types are the same. Refer to the synchronous class for full parameter descriptions aligned withdocs/rest_api(Issues API).Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None, state: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Issue]
List issues for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
state – Issue state filter such as
openorclosed(see Issues API).sort – Optional sort field.
direction – Optional sort direction.
page – Page number.
per_page – Page size.
- Returns:
Matching issues.
- async get(*, number: int | str, owner: str | None = None, repo: str | None = None) Issue
Get a single issue by number.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Issue details.
- async create(*, owner: str, repo: str | None = None, title: str, body: str | None = None, assignee: str | None = None, labels: List[str] | None = None, milestone: int | str | None = None, security_hole: str | None = None) Issue
Create an issue for a repository.
- Parameters:
owner – Repository owner path.
repo – Repository name. Uses the client default when omitted.
title – Issue title.
body – Optional issue description.
assignee – Optional assignee username.
labels – Optional label names (comma-separated in the JSON body).
milestone – Optional milestone identifier.
security_hole – Whether the issue is private; form field described in the Issues API.
- Returns:
Created issue details.
- async update(*, number: int | str, owner: str, repo: str | None = None, title: str | None = None, body: str | None = None, state: str | None = None, assignee: str | None = None, labels: List[str] | None = None, milestone: int | str | None = None, security_hole: str | None = None) Issue
Update an existing issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path.
repo – Repository name. Uses the client default when omitted.
title – Updated issue title.
body – Updated issue description.
state – Updated state such as
reopenorclose.assignee – Updated assignee username.
labels – Replacement label names (comma-separated in the JSON body).
milestone – Updated milestone identifier.
security_hole – Whether the issue is private; form field described in the Issues API.
- Returns:
Updated issue details.
- async list_comments(*, number: int | str, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[IssueComment]
List comments for an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path (name). Uses the client default when omitted.
page – Current page number (query).
per_page – Page size; maximum per REST API is typically 100.
- Returns:
Issue comments.
- async create_comment(*, number: int | str, body: str, owner: str | None = None, repo: str | None = None) IssueComment
Create a comment on an issue.
- Parameters:
number – Repository-local issue number.
body – Comment body text.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Created comment.
- async get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) IssueComment
Get a single issue comment by identifier.
- Parameters:
comment_id – Comment id from the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Issue comment.
- async update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) IssueComment
Update an issue comment.
- Parameters:
comment_id – Comment id from the API.
body – Updated comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Updated comment.
- async delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete an issue comment.
- Parameters:
comment_id – Comment id from the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async list_pull_requests(*, number: int | str, owner: str | None = None, repo: str | None = None) List[PullRequest]
List pull requests associated with an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull requests linked to the issue.
- async add_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Add labels to an issue.
- Parameters:
number – Repository-local issue number.
labels – Label names to add (request body is a JSON array per REST API).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels on the issue after the operation.
- async remove_label(*, number: int | str, name: str, owner: str | None = None, repo: str | None = None) None
Remove one label from an issue (REST path includes the label name).
- Parameters:
number – Repository-local issue number.
name – Label name to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async list_enterprise(*, enterprise: str, **params) List[Issue]
List enterprise issues visible to the caller.
- Parameters:
enterprise – Enterprise path or login.
params – Additional query parameters accepted by
GET .../enterprises/{enterprise}/issues.
- Returns:
Enterprise-scoped issues.
- async list_user(**params) List[Issue]
List issues for the authenticated user.
- Parameters:
params – Query parameters for
GET /user/issues(filters, pagination, etc.).- Returns:
Issues assigned to or authored by the user, per API rules.
- async list_org(*, org: str, **params) List[Issue]
List organization issues visible to the current user.
- Parameters:
org – Organization path or login.
params – Query parameters for
GET .../orgs/{org}/issues.
- Returns:
Organization-scoped issues.
- async get_enterprise_issue(*, enterprise: str, number: int | str) Issue
Get a specific enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue id or number as accepted by the API path.
- Returns:
Issue payload.
- async list_enterprise_comments(*, enterprise: str, number: int | str, **params) List[IssueComment]
List comments for an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue identifier in the path.
params – Optional pagination or filter query parameters.
- Returns:
Comments on the enterprise issue.
- async list_enterprise_labels(*, enterprise: str, issue_id: int | str) List[Label]
List labels attached to an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
issue_id – Enterprise issue id in the path segment
.../issues/{issue_id}/labels.
- Returns:
Labels on the issue.
- async list_operation_logs(*, owner: str, number: int | str, page: int | None = None, per_page: int | None = None) List[IssueOperationLog]
List operation (audit) logs for an issue.
- Parameters:
owner – Repository owner path (path segment
repos/{owner}/...for this endpoint).number – Repository-local issue number.
page – Page number.
per_page – Page size.
- Returns:
Operation log entries.
- async list_templates(*, owner: str | None = None, repo: str | None = None) List[RepositoryGitCodeTemplate]
List active issue templates under
.gitcode/for this repository.Matches Markdown (
.md,.markdown) and YAML (.yml/.yaml) paths whose names start withISSUE_TEMPLATEunder.gitcode/(case-insensitive), including files inside localized directories such as.gitcode/ISSUE_TEMPLATE.en/.Resolution tries the repository, then the owner’s
.gitcoderepository, then any parent main andparent/.gitcodepairs discovered from forks (each candidate is inspected withGET /repos/{owner}/{repo}; whenforkis true, its parent’s repos are appended, deduplicated, and visited in order). The first source with matching templates wins.Version 1.2.19: Now also supporting GitHub-mirrored repos with a
.github/folder.- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Template metadata entries (paths and SHAs); empty when none match.
- async get_template(*, path: str, owner: str | None = None, repo: str | None = None, encoding: str = 'utf-8', **decoding_kwargs) str
Load a single issue template file body from the default branch.
Uses the same resolution order as
list_templates(). The path must match the active issue template naming convention (see GitCode.gitcodedocumentation).- Parameters:
path – Repository-relative path such as
.gitcode/ISSUE_TEMPLATE_bug.mdor.gitcode/ISSUE_TEMPLATE/config.yml.owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
encoding – Codec to use when decoding raw file bytes. Default
utf-8.decoding_kwargs – Keyword arguments forwarded to
bytes.decode(), such aserrors("strict","ignore", or"replace").
- Returns:
Decoded template file contents.
- class AsyncLabelsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous label endpoints.
Mirrors
LabelsResource; see that class for parameter documentation.Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None) List[Label]
List repository labels.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
All labels defined on the repository.
- async create(*, name: str, color: str, owner: str | None = None, repo: str | None = None) Label
Create a repository label.
- Parameters:
name – Label name.
color – Label color (typically a
#RRGGBBhex string per API examples).owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Created label.
- async update(*, original_name: str, owner: str | None = None, repo: str | None = None, name: str | None = None, color: str | None = None) Label
Update a repository label.
- Parameters:
original_name – Current label name in the URL path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
name – New label name, if renaming.
color – New color value.
- Returns:
Updated label.
- async delete(*, name: str, owner: str | None = None, repo: str | None = None) None
Delete a repository label.
- Parameters:
name – Label name in the path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async clear_issue_labels(*, number: int | str, owner: str | None = None, repo: str | None = None) None
Remove all labels from an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async replace_issue_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Replace all labels on an issue.
- Parameters:
number – Repository-local issue number.
labels – Complete new label set (JSON array body).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after replacement.
- async list_enterprise(*, enterprise: str, search: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None, api_version: str = 'v5') List[Label]
List labels for an enterprise, optionally using a different API version.
- Parameters:
enterprise – Enterprise path or login.
search – Optional name search string.
direction – Sort direction for results.
page – Page number.
per_page – Page size.
api_version –
v5uses/api/v5/...; other values build/api/{version}/...on the same host.
- Returns:
Enterprise label definitions.
- class AsyncMembersResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous repository member endpoints.
Mirrors
MembersResource(collaborators API); see that class for parameters.Bind the resource to an asynchronous API client.
- async add_or_update(*, username: str, owner: str | None = None, repo: str | None = None, permission: str | None = None) RepoMember
Add or update repository member permissions.
- Parameters:
username – Collaborator login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
permission – Permission string (for example
pull,push,adminper GitCode API).
- Returns:
Collaborator record.
- async remove(*, username: str, owner: str | None = None, repo: str | None = None) None
Remove a repository member.
- Parameters:
username – Collaborator login to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[RepoCollaborator]
List repository members (collaborators).
- 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:
Collaborators with permission metadata.
- async get(*, username: str, owner: str | None = None, repo: str | None = None) RepositoryCollaboratorCheck
Check whether a user is a repository member.
- Parameters:
username – User login to look up.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Membership payload (typically includes whether the user is a collaborator).
- async get_permission(*, username: str, owner: str | None = None, repo: str | None = None) RepoMemberPermission
Get repository member permissions.
- Parameters:
username – Collaborator login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Effective permission for the user on the repository.
- class AsyncMilestonesResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous milestone endpoints.
Mirrors
MilestonesResource; see that class for parameter documentation.Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None, **params) List[Milestone]
List milestones for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
params – Query parameters accepted by the milestones listing (state, sort, pagination, etc.).
- Returns:
Milestones.
- async get(*, number: int | str, owner: str | None = None, repo: str | None = None) Milestone
Get a single milestone.
- Parameters:
number – Milestone number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Milestone details.
- async create(*, title: str, due_on: str, owner: str | None = None, repo: str | None = None, description: str | None = None) Milestone
Create a milestone.
- Parameters:
title – Milestone title.
due_on – Due date string in the format expected by the API (often ISO 8601).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
description – Optional description.
- Returns:
Created milestone.
- async update(*, number: int | str, title: str, due_on: str, owner: str | None = None, repo: str | None = None, description: str | None = None, state: str | None = None) Milestone
Update a milestone.
- Parameters:
number – Milestone number.
title – Updated title.
due_on – Updated due date.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
description – Updated description.
state – Milestone state such as
openorclosedper API.
- Returns:
Updated milestone.
- async delete(*, number: int | str, owner: str | None = None, repo: str | None = None) None
Delete a milestone.
- Parameters:
number – Milestone number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- class AsyncOAuthResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous helpers for GitCode OAuth flows.
build_authorize_urlmatchesOAuthResourceexactly. Token helpers mirrorOAuthResource.exchange_token()andOAuthResource.refresh_token()(seedocs/rest_api/oauth).Bind the resource to an asynchronous API client.
- build_authorize_url(*, client_id: str, redirect_uri: str, scope: str | None = None, state: str | None = None, response_type: str = 'code') str
Build the GitCode OAuth authorization URL.
- Parameters:
client_id – OAuth application client ID.
redirect_uri – Registered redirect URI.
scope – Optional OAuth scopes.
state – Optional CSRF protection value.
response_type – OAuth response type, defaults to
"code".
- Returns:
Browser URL for the authorization step.
- async exchange_token(*, code: str, client_id: str, client_secret: str) OAuthToken
Exchange an authorization code for an OAuth token.
- Parameters:
code – Authorization code returned by GitCode.
client_id – OAuth application client ID.
client_secret – OAuth application client secret.
- Returns:
OAuth access token payload.
- async refresh_token(*, refresh_token: str) OAuthToken
Refresh an OAuth token.
- Parameters:
refresh_token – Refresh token previously issued by GitCode.
- Returns:
Refreshed OAuth token payload.
- class AsyncOrgsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous organization and enterprise endpoints.
Mirrors
OrgsResource; see that class for parameters (docs/rest_api/orgs).Bind the resource to an asynchronous API client.
- async list_for_user(*, username: str, page: int | None = None, per_page: int | None = None) List[OrganizationSummary]
List organizations for a user.
- Parameters:
username – GitCode username or login.
page – Page number.
per_page – Page size.
- Returns:
Organizations the user belongs to.
- async list_authenticated(*, page: int | None = None, per_page: int | None = None, admin: bool | None = None) List[OrganizationSummary]
List organizations for the authenticated user.
- Parameters:
page – Page number.
per_page – Page size.
admin – Optional admin-only filter.
- Returns:
Organizations visible to the authorized user.
- async get_member(*, org: str, username: str) OrganizationMembership
Get an organization member profile.
- Parameters:
org – Organization path or login.
username – Member username or login.
- Returns:
Organization membership details.
- async get(*, org: str) Organization
Get an organization.
- Parameters:
org – Organization path or login.
- Returns:
Organization details.
- async list_repos(*, org: str, type: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories for an organization.
- Parameters:
org – Organization path or login.
type – Repository type filter such as
all,public, orprivate.page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- async create_repo(*, org: str, name: str, **payload) Repository
Create an organization repository.
Additional payload fields match the organization repository creation endpoint, such as
description,homepage,private,public,auto_init, anddefault_branch.- Parameters:
org – Organization path or login.
name – Repository name.
payload – Additional repository creation fields.
- Returns:
Created repository metadata.
- async get_enterprise_member(*, enterprise: str, username: str) EnterpriseMember
Get a member profile for an enterprise.
- Parameters:
enterprise – Enterprise path or login.
username – Member username or login.
- Returns:
Enterprise membership details.
- async get_membership(*, org: str) OrganizationMembership
Get the authenticated user’s membership in an organization.
- Parameters:
org – Organization path or login.
- Returns:
Membership details for the current user.
- async list_members(*, org: str, page: int | None = None, per_page: int | None = None, role: str | None = None) List[User]
List members of an organization.
- Parameters:
org – Organization path or login.
page – Page number.
per_page – Page size.
role – Optional role filter such as
all,admin, ormember.
- Returns:
Organization members.
- async list_enterprise_members(*, enterprise: str, page: int | None = None, per_page: int | None = None, role: str | None = None) List[EnterpriseMember]
List members of an enterprise.
- Parameters:
enterprise – Enterprise path or login.
page – Page number.
per_page – Page size.
role – Optional role filter.
- Returns:
Enterprise members.
- async remove_member(*, org: str, username: str) EmptyResponse
Remove a member from an organization.
- Parameters:
org – Organization path or login.
username – Member username or login.
- Returns:
API response payload, if any.
- async list_followers(*, owner: str, page: int | None = None, per_page: int | None = None) List[User]
List followers of an organization.
- Parameters:
owner – Organization path.
page – Page number.
per_page – Page size.
- Returns:
Followers of the organization.
- async get_issue_extend_settings(*, org: str) List[APIObject]
Get extended issue type and status settings for an organization.
- Parameters:
org – Organization path or login.
- Returns:
Extended issue configuration entries.
- async invite_member(*, org: str, username: str, permission: str | None = None, role_id: str | None = None) User
Invite a user to an organization.
- Parameters:
org – Organization path or login.
username – Member username or login.
permission – Permission level such as
pull,push, oradmin.role_id – Custom role identifier when using a customized permission.
- Returns:
Invited user information with permissions.
- async update_enterprise_member(*, enterprise: str, username: str, role: str) EnterpriseMember
Update the role of an enterprise member.
- Parameters:
enterprise – Enterprise path or login.
username – Member username or login.
role – Enterprise role such as
viewer,developer, oradmin.
- Returns:
Updated enterprise membership.
- async update(*, org: str, **payload) Organization
Update organization metadata.
- Parameters:
org – Organization path or login.
payload – Updatable fields such as
name,email, ordescription.
- Returns:
Updated organization details.
- async leave(*, org: str) None
Leave an organization as the authenticated user.
- Parameters:
org – Organization path or login.
- class AsyncPullsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous pull request endpoints.
Methods correspond to
PullsResourcewith identical arguments and semantics, includingonly_countresponses documented in the Pull Request API underdocs/rest_api.Bind the resource to an asynchronous API client.
- async list(*, owner: str | None = None, repo: str | None = None, state: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None, **params) List[PullRequest] | PullRequestCount
List pull requests for a repository.
When
only_countis true inparams(or passed via**params), the API returns a JSON object with counts per state instead of an array (see Pull Request API).- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path (name). Uses the client default when omitted.
state – PR state filter:
all,open,closed,locked,merged(defaultallin API).sort – Sort field, typically
createdorupdated.direction –
ascordesc(API default is usuallydesc).page – Current page number.
per_page – Page size (max 100 per API documentation).
params – Extra query parameters from the Pull Request API, for example
base,since,author,assignee,reviewer,milestone_number,labels(comma-separated),merged_after,merged_before,created_after,created_before,updated_after,updated_before,only_count(boolean), and ISO 8601 timestamps (URL-encoded when sent).
- Returns:
A list of pull requests, or an
APIObjectfor count-only responses.
- async get(*, number: int | str, owner: str | None = None, repo: str | None = None) PullRequest
Get a single pull request.
- Parameters:
number – Pull request number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull request details.
- async create(*, title: str, head: str, base: str, owner: str | None = None, repo: str | None = None, body: str | None = None, draft: bool | None = None, assignees: List[str] | None = None, testers: List[str] | None = None, labels: List[str] | None = None, milestone_number: int | None = None, issue: str | None = None, prune_source_branch: bool | None = None, squash: bool | None = None, squash_commit_message: str | None = None, fork_path: str | None = None) PullRequest
Create a pull request.
- Parameters:
title – Pull request title.
head – Source branch ref (head branch, in forks use
owner:branchlike “SushiNinja:develop”).base – Target branch ref (base branch).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
body – Description body.
draft – Whether to create as draft.
assignees – Assignee logins; sent as a comma-separated string per API.
testers – Tester logins; comma-separated in the JSON body.
labels – Label names; comma-separated in the JSON body.
milestone_number – Target milestone number.
issue – Related issue reference when supported by the API.
prune_source_branch – Whether to delete the source branch after merge when applicable.
squash – Squash-merge preference where supported.
squash_commit_message – Custom squash commit message.
fork_path – Fork
owner/repowhen opening a PR from a fork, like “SushiNinja/agent-core-contrib”.
- Returns:
Created pull request.
- async update(*, number: int | str, owner: str | None = None, repo: str | None = None, title: str | None = None, body: str | None = None, state: str | None = None, base: str | None = None, labels: List[str] | None = None, draft: bool | None = None) PullRequest
Update a pull request.
- Parameters:
number – Pull request number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
title – New title.
body – New description.
state – New state as accepted by the API.
base – New base branch name.
labels – Replacement labels; comma-separated in the JSON body.
draft – Draft flag.
- Returns:
Updated pull request.
- async merge(*, number: int | str, owner: str | None = None, repo: str | None = None, merge_commit_message: str | None = None, squash: bool | None = None) MergeResult
Merge a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
merge_commit_message – Optional merge commit message.
squash – Whether to squash merge when supported.
- Returns:
Merge result payload.
- async get_merge_status(*, number: int | str, owner: str | None = None, repo: str | None = None) MergeStatus
Get mergeability status for a pull request (GET on the merge resource).
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Merge status / mergeability information.
- async list_commits(*, number: int | str, owner: str | None = None, repo: str | None = None) List[APIObject]
List commits included in a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Commit objects (wrapped as
APIObject).
- async list_files(*, number: int | str, owner: str | None = None, repo: str | None = None) List[PullRequestFile]
List files changed by a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
File change entries.
- async list_comments(*, number: int | str, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[PullRequestComment]
List comments on a pull request.
- Parameters:
number – Pull request number.
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:
Pull request review comments.
- async create_comment(*, number: int | str, body: str, owner: str | None = None, repo: str | None = None, commit_id: str | None = None, path: str | None = None, position: int | None = None) PullRequestComment
Create a pull request (review) comment.
- Parameters:
number – Pull request number.
body – Comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
commit_id – Commit SHA the comment applies to.
path – File path in the diff.
position – Line or diff position as defined by the API.
- Returns:
Created comment.
- async get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) PullRequestComment
Get a single pull request comment by id (global comment endpoint).
- Parameters:
comment_id – Comment id.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull request comment.
- async update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) PullRequestComment
Update a pull request comment.
- Parameters:
comment_id – Comment id.
body – Updated body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Updated comment.
- async delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete a pull request comment.
- Parameters:
comment_id – Comment id.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async list_labels(*, number: int | str, owner: str | None = None, repo: str | None = None) List[Label]
List labels attached to a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels on the pull request.
- async add_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Add labels to a pull request.
- Parameters:
number – Pull request number.
labels – Label names (JSON array body per API).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after the operation.
- async replace_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Replace all labels on a pull request.
- Parameters:
number – Pull request number.
labels – Complete new label set (JSON array body).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after replacement.
- async remove_label(*, number: int | str, label: str, owner: str | None = None, repo: str | None = None) None
Remove a label from a pull request.
- Parameters:
number – Pull request number.
label – Label name to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async request_review(*, number: int | str, owner: str | None = None, repo: str | None = None, event: str, body: str | None = None) None
Submit a pull request review event (approve, request changes, etc., per API).
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
event – Review event name as required by GitCode (see API docs).
body – Optional comment body accompanying the event.
- Returns:
Review result object.
- async list_operation_logs(*, number: int | str, owner: str | None = None, repo: str | None = None, **params) List[PullRequestOperationLog]
List operation logs for a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
params – Additional query parameters accepted by the operate_logs endpoint.
- Returns:
Log entries as generic API objects.
- async request_test(*, number: int | str, owner: str | None = None, repo: str | None = None, **payload) None
Request testing for a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
payload – JSON fields required by the test request endpoint.
- Returns:
Test request result.
- async update_testers(*, number: int | str, testers: List[str], owner: str | None = None, repo: str | None = None) None
Replace pull request testers.
- Parameters:
number – Pull request number.
testers – New tester list; serialized as a comma-separated
testersfield in JSON.owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- async add_testers(*, number: int | str, testers: List[str], owner: str | None = None, repo: str | None = None) List[UserSummary]
Add testers to a pull request.
- Parameters:
number – Pull request number.
testers – Usernames to add; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- async update_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) None
Replace pull request assignees.
- Parameters:
number – Pull request number.
assignees – New assignee list; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- async add_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) PullRequestAssigneeCount
Add assignees to a pull request.
- Parameters:
number – Pull request number.
assignees – Usernames to add; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- async remove_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) None
Remove assignees from a pull request.
- Parameters:
number – Pull request number.
assignees – Usernames to remove; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- async list_issues(*, number: int | str, owner: str | None = None, repo: str | None = None) List[Issue]
List issues linked to a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Linked issues.
- async list_enterprise(*, enterprise: str, **params) List[PullRequest]
List enterprise pull requests.
- Parameters:
enterprise – Enterprise path or login.
params – Query parameters for the enterprise pull_requests listing.
- Returns:
Pull requests in the enterprise scope.
- async list_org(*, org: str, **params) List[PullRequest]
List pull requests for an organization scope.
- Parameters:
org – Organization path (
GET .../org/{org}/pull_requests).params – Query parameters accepted by that listing.
- Returns:
Organization-scoped pull requests.
- async list_issue_pull_requests(*, enterprise: str, number: int | str) List[PullRequest]
List pull requests associated with an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue number or id in the path.
- Returns:
Related pull requests.
- async list_templates(*, owner: str | None = None, repo: str | None = None) List[RepositoryGitCodeTemplate]
List active pull request templates under
.gitcode/for this repository.Resolution tries the repository, then the owner’s
.gitcoderepository, then any parent main andparent/.gitcodepairs discovered from forks (each candidate is inspected withGET /repos/{owner}/{repo}; whenforkis true, its parent’s repos are appended, deduplicated, and visited in order). The first source with matching templates wins.Version 1.2.19: Now also supporting GitHub-mirrored repos with a
.github/folder.- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Template metadata entries (paths and SHAs); empty when none match.
- async get_template(*, path: str, owner: str | None = None, repo: str | None = None, encoding: str = 'utf-8', **decoding_kwargs) str
Load a single pull request template file body from the default branch.
Uses the same resolution order as
list_templates(). The path must match the active pull request template naming convention (see GitCode.gitcodedocumentation).- Parameters:
path – Repository-relative path such as
.gitcode/PULL_REQUEST_TEMPLATE.md.owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
encoding – Codec to use when decoding raw file bytes. Default
utf-8.decoding_kwargs – Keyword arguments forwarded to
bytes.decode(), such aserrors("strict","ignore", or"replace").
- Returns:
Decoded template file contents.
- class AsyncRepoContentsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous repository contents endpoints.
Mirrors
RepoContentsResource(contents, trees, blobs, raw files; seedocs/rest_api/repos).Bind the resource to an asynchronous API client.
- async get(*, path: str, owner: str | None = None, repo: str | None = None, ref: str | None = None) ContentObject
Get a file or directory entry from a repository.
- Parameters:
path – Repository-relative file path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref – Optional branch, tag, or commit SHA.
- Returns:
Content metadata and payload details.
- async create(*, path: str, content: str, message: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Create a file in a repository.
- Parameters:
path – Repository-relative file path.
content – File content, typically base64-encoded for this API.
message – Commit message.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- async update(*, path: str, content: str, message: str, sha: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Update a file in a repository.
- Parameters:
path – Repository-relative file path.
content – Updated file content, typically base64-encoded.
message – Commit message.
sha – Current blob SHA required by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- async delete(*, path: str, message: str, sha: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Delete a file from a repository.
- Parameters:
path – Repository-relative file path.
message – Commit message.
sha – Current blob SHA required by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- async list_paths(*, owner: str | None = None, repo: str | None = None, ref_name: str | None = None, file_name: str | None = None) List[str]
List repository paths known to GitCode.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref_name – Optional ref name to inspect.
file_name – Optional filename filter.
- Returns:
Matching repository paths.
- async get_tree(*, sha: str, owner: str | None = None, repo: str | None = None, recursive: int | None = None, page: int | None = None, per_page: int | None = None) Tree
Get a Git tree object.
- Parameters:
sha – Tree SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
recursive – Pass
1to fetch the tree recursively (query parameter per Repository API).page – Page number for large trees.
per_page – Page size for large trees.
- Returns:
Tree metadata and entries.
- async get_blob(*, sha: str, owner: str | None = None, repo: str | None = None) Blob
Get a Git blob object by SHA.
- Parameters:
sha – Blob SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Blob metadata and content.
- async get_raw(*, path: str, owner: str | None = None, repo: str | None = None, ref: str | None = None) bytes
Download raw file bytes from a repository.
- Parameters:
path – Repository-relative file path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref – Optional branch, tag, or commit SHA.
- Returns:
Raw file bytes.
- class AsyncReleasesResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous release endpoints.
Mirrors
ReleasesResource; see that class for parameters (Release API indocs/rest_api).Bind the resource to an asynchronous API client.
- async create(*, tag: str, name: str, body: str, owner: str | None = None, repo: str | None = None, target_commitish: str | None = None, release_status: str | None = None) Release
Create a repository release.
- Parameters:
tag – Tag name for the release.
name – Release title.
body – Release description.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
target_commitish – Branch name or commit SHA for creating a missing tag.
release_status – Release status, such as
preorlatest.
- Returns:
Created release payload.
- async update(*, tag: str, name: str, body: str, owner: str | None = None, repo: str | None = None, release_status: str | None = None) Release
Update a repository release.
- Parameters:
tag – Tag name in the release URL path.
name – Release name.
body – Release description.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
release_status – Release status, such as
preorlatest.
- Returns:
Updated release payload.
- async get_upload_url(*, tag: str, file_name: str, owner: str | None = None, repo: str | None = None) ReleaseUploadURL
Get a pre-signed URL for uploading a release attachment.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name to upload.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Upload URL and required headers.
- async upload(*, tag: str, file_name: str, content: bytes | str, owner: str | None = None, repo: str | None = None, upload_timeout: float | None = 300.0) None
Upload a release attachment through the pre-signed upload URL.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name to upload.
content – Attachment bytes, or a local file path to read as bytes.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
upload_timeout – Timeout for upload operation. Default to 300 (5 minutes).
- 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, direction: str | None = None, page: int | None = None, per_page: int | 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.
direction – Sort direction, for example
ascordesc.page – Page number.
per_page – Page size, up to 100.
- Returns:
Releases ordered as returned by the API.
- async get_latest(*, owner: str | None = None, repo: str | None = None, type: str | None = None) Release
Get the latest repository release.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
type – Selection type, either
updatedorlatest.
- Returns:
Latest release metadata.
- async get(*, tag: str, owner: str | None = None, repo: str | None = None, temp_download_url: bool | str | None = None) Release
Get a repository release by tag path.
- Parameters:
tag – Tag name in the release URL path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
temp_download_url – Whether to return temporary source package and attachment URLs.
- Returns:
Release metadata.
- async download_attachment(*, tag: str, file_name: str, owner: str | None = None, repo: str | None = None) bytes
Download a release attachment as bytes.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Attachment bytes.
- class AsyncReposResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous repository endpoints.
Mirrors
ReposResource; see that class for parameters and JSON fields (Repository API indocs/rest_api/repos).Bind the resource to an asynchronous API client.
- async get(*, owner: str | None = None, repo: str | None = None) Repository
Get a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Repository metadata.
- async list_user(*, visibility: str | None = None, affiliation: str | None = None, type: str | None = None, sort: str | None = None, direction: str | None = None, q: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories visible to the authenticated user.
- Parameters:
visibility – Visibility filter such as
public,private, orall.affiliation – Ownership filter accepted by the REST API.
type – Repository type filter.
sort – Sort field such as
createdorfull_name.direction – Sort direction.
q – Optional keyword filter.
page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- async list_for_owner(*, owner: str, type: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List public repositories for a user or owner path.
- Parameters:
owner – Repository owner path or username.
type – Repository type filter.
sort – Sort field.
direction – Sort direction.
page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- async create_personal(*, name: str, description: str | None = None, path: str | None = None, private: bool | None = None, auto_init: bool | None = None, has_issues: bool | None = None, has_wiki: bool | None = None, default_branch: str | None = None, gitignore_template: str | None = None, license_template: str | None = None) Repository
Create a repository for the authenticated user.
- Parameters:
name – Repository name.
description – Repository description.
path – Optional repository path.
private – Whether the repository should be private.
auto_init – Whether to initialize the repository with a README.
has_issues – Whether issues are enabled.
has_wiki – Whether wiki support is enabled.
default_branch – Default branch name when initializing.
gitignore_template – Optional gitignore template.
license_template – Optional license template.
- Returns:
Created repository metadata.
- async create_for_org(*, org: str, name: str, description: str | None = None, homepage: str | None = None, path: str | None = None, private: bool | None = None, public: int | None = None, auto_init: bool | None = None, has_issues: bool | None = None, has_wiki: bool | None = None, can_comment: bool | None = None, default_branch: str | None = None, gitignore_template: str | None = None, license_template: str | None = None) Repository
Create a repository under an organization.
- Parameters:
org – Organization path or login.
name – Repository name.
description – Repository description.
homepage – Repository homepage URL.
path – Optional repository path.
private – Whether the repository should be private.
public – Visibility mode used by the GitCode API.
auto_init – Whether to initialize the repository with a README.
has_issues – Whether issues are enabled.
has_wiki – Whether wiki support is enabled.
can_comment – Whether comments are enabled.
default_branch – Default branch name when initializing.
gitignore_template – Optional gitignore template.
license_template – Optional license template.
- Returns:
Created repository metadata.
- async update(*, owner: str | None = None, repo: str | None = None, **changes) Repository
Update repository metadata.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
changes – Repository fields accepted by the update endpoint.
- Returns:
Updated repository metadata.
- async delete(*, owner: str | None = None, repo: str | None = None) None
Delete a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- async fork(*, owner: str | None = None, repo: str | None = None, namespace: str | None = None, path: str | None = None, name: str | None = None) Repository
Fork a repository.
- Parameters:
owner – Source repository owner path.
repo – Source repository name.
namespace – Optional destination namespace.
path – Optional destination repository path.
name – Optional destination repository name.
- Returns:
Forked repository metadata.
- async list_forks(*, owner: str | None = None, repo: str | None = None, sort: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List forks of a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sort – Optional sort field.
page – Page number.
per_page – Page size.
- Returns:
Fork repositories.
- async list_contributors(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Contributor]
List repository contributors.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Contributors for the repository.
- async list_languages(*, owner: str | None = None, repo: str | None = None) Dict[str, int]
List language statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Mapping of language names to byte counts.
- async list_stargazers(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[UserSummary]
List users who starred a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Users who starred the repository.
- async list_subscribers(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[UserSummary]
List users watching a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Subscribers for the repository.
- async update_module_settings(*, owner: str | None = None, repo: str | None = None, **settings) ApiStatusResponse
Update repository module settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
settings – Module settings accepted by the GitCode API.
- Returns:
API response payload.
- async update_reviewer_settings(*, owner: str | None = None, repo: str | None = None, **settings) RepositoryReviewerSettingsUpdate
Update repository reviewer settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
settings – Reviewer settings accepted by the GitCode API.
- Returns:
API response payload.
- async set_org_repo_status(*, org: str, repo: str, **payload) ApiStatusResponse
Update organization repository status metadata.
- Parameters:
org – Organization path.
repo – Repository path.
payload – Status fields accepted by the API.
- Returns:
API response payload.
- async transfer_to_org(*, org: str, repo: str, **payload) ApiStatusResponse
Transfer a repository to an organization.
- Parameters:
org – Destination organization path.
repo – Repository path.
payload – Transfer options accepted by the API.
- Returns:
API response payload.
- async get_transition(*, owner: str | None = None, repo: str | None = None) RepositoryPermissionMode
Get repository transition settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Transition configuration.
- async update_transition(*, owner: str | None = None, repo: str | None = None, **payload) ApiStatusResponse
Update repository transition settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Transition settings accepted by the API.
- Returns:
API response payload.
- async update_push_config(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryPushConfig
Update repository push configuration.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Push configuration values accepted by the API.
- Returns:
API response payload.
- async get_push_config(*, owner: str | None = None, repo: str | None = None) RepositoryPushConfig
Get repository push configuration.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Push configuration payload.
- async upload_image(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryUploadResult
Upload an image asset for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Upload fields accepted by the API.
- Returns:
Uploaded image metadata.
- async upload_file(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryUploadResult
Upload a file asset for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Upload fields accepted by the API.
- Returns:
Uploaded file metadata.
- async update_repo_settings(*, owner: str | None = None, repo: str | None = None, **payload) RepositorySettings
Update repository settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Settings fields accepted by the API.
- Returns:
API response payload.
- async get_repo_settings(*, owner: str | None = None, repo: str | None = None) RepositorySettings
Get repository settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Repository settings payload.
- async get_pull_request_settings(*, owner: str | None = None, repo: str | None = None) PullRequestSettings
Get pull request settings for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Pull request settings payload.
- async update_pull_request_settings(*, owner: str | None = None, repo: str | None = None, **payload) PullRequestSettings
Update pull request settings for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Pull request settings accepted by the API.
- Returns:
API response payload.
- async set_member_role(*, username: str, owner: str | None = None, repo: str | None = None, permission: str | None = None) RepoMember
Set a repository member role.
- Parameters:
username – Member username or login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
permission – Permission or role name accepted by the API.
- Returns:
API response payload.
- async transfer(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryTransferResult
Transfer a repository to another owner or namespace.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Transfer options accepted by the API.
- Returns:
API response payload.
- async list_customized_roles(*, owner: str | None = None, repo: str | None = None) List[RepositoryCustomizedRole]
List customized roles for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Customized role definitions.
- async get_download_statistics(*, owner: str | None = None, repo: str | None = None, **params) RepositoryDownloadStatistics
Get download statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
params – Query parameters accepted by the statistics endpoint.
- Returns:
Download statistics payload.
- async get_contributor_statistics(*, owner: str | None = None, repo: str | None = None) List[ContributorStatistics]
Get code contribution statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Contributor statistics payload.
- async list_events(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[APIObject]
List repository events.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Repository event payloads.
- class AsyncSearchResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous search endpoints.
Query parameters match
SearchResource(page,per_page,sort,order, etc.); seedocs/rest_api/searchand the synchronous methods for field meanings.Bind the resource to an asynchronous API client.
- async users(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None) List[SearchUser]
Search users.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field such as
joined_at.order – Sort order, usually
ascordesc.
- Returns:
Matching user search results.
- async issues(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None, repo: str | None = None, state: str | None = None) List[SearchIssue]
Search issues.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field.
order – Sort order, usually
ascordesc.repo – Optional repository path filter.
state – Optional issue state filter.
- Returns:
Matching issue search results.
- async repositories(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None, owner: str | None = None, fork: str | None = None, language: str | None = None) List[SearchRepository]
Search repositories.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field such as
stars_count.order – Sort order, usually
ascordesc.owner – Optional owner path filter.
fork – Optional fork visibility filter.
language – Optional programming language filter.
- Returns:
Matching repository search results.
- class AsyncTagsResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous tag endpoints.
Mirrors
TagsResource; see that class anddocs/rest_api/repos/tagfor 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 AsyncUsersResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous user and account endpoints.
Mirrors
UsersResource; see that class for full parameter descriptions (docs/rest_api/usersand related guides).Bind the resource to an asynchronous API client.
- async get(*, username: str) User
Get a user profile.
- Parameters:
username – GitCode username or login.
- Returns:
User profile details.
- async list_emails() List[Email]
List email addresses for the authenticated user.
- Returns:
Email records associated with the current account.
- async list_events(*, username: str, year: str | None = None, next: str | None = None) UserEventsResponse
List activity events for a user.
- Parameters:
username – GitCode username or login (path segment, see User API).
year – Optional start year filter (query
year, e.g.2024per documentation).next – Optional end date / pagination cursor (query
next; often an ISO timestamp from a prior page).
- Returns:
Event payload grouped by date.
- async list_repos(*, username: str, **params) List[Repository]
List public repositories owned by a user.
Supported filters follow the user repository API documentation, such as
type,sort,direction,page, andper_page.- Parameters:
username – GitCode username or login.
params – Query parameters accepted by the REST endpoint.
- Returns:
Matching repositories.
- async create_key(*, key: str, title: str) PublicKey
Add a public SSH key for the authenticated user.
- Parameters:
key – Public key material.
title – Human-readable key name.
- Returns:
Created key metadata.
- async list_keys(*, page: int | None = None, per_page: int | None = None) List[APIObject]
List public SSH keys for the authenticated user.
- Parameters:
page – Page number.
per_page – Page size.
- Returns:
Public key records.
- async delete_key(*, key_id: int | str) None
Delete a public SSH key.
- Parameters:
key_id – Public key identifier.
- async get_key(*, key_id: int | str) PublicKey
Get a single public SSH key.
- Parameters:
key_id – Public key identifier.
- Returns:
Public key metadata.
- async get_namespace(*, path: str) Namespace
Resolve namespace information for the authenticated user.
- Parameters:
path – Namespace path to look up.
- Returns:
Namespace details.
- async list_starred(*, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories starred by the authenticated user.
- Parameters:
sort – Sort field such as
createdorupdated.direction – Sort direction, usually
ascordesc.page – Page number.
per_page – Page size.
- Returns:
Starred repositories.
- class AsyncWebhooksResource(client: AsyncAPIClient)
Bases:
AsyncResourceAsynchronous webhook endpoints.
Mirrors
WebhooksResource; see that class anddocs/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.
- class BranchesResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous branch endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Branch]
List branches in a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sort – Optional sort field such as
nameorupdated.direction – Sort direction, usually
ascordesc.page – Page number.
per_page – Page size.
- Returns:
Repository branches.
- get(*, branch: str, owner: str | None = None, repo: str | None = None) BranchDetail
Get a single branch.
- Parameters:
branch – Branch name.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Branch details.
- create(*, branch: str, ref: str, owner: str | None = None, repo: str | None = None) Branch
Create a branch from an existing ref.
- Parameters:
branch – New branch name.
ref – Starting ref such as a branch, tag, or commit SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Created branch details.
- list_protected(*, owner: str | None = None, repo: str | None = None) List[ProtectedBranch]
List protected branch rules for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Protected branch rules.
- class CommitsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous commit endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None, sha: str | None = None, path: str | None = None, page: int | None = None, per_page: int | None = None) List[CommitSummary]
List commits in a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sha – Optional starting SHA or ref.
path – Optional file path filter.
page – Page number.
per_page – Page size.
- Returns:
Matching commits.
- get(*, sha: str, owner: str | None = None, repo: str | None = None) Commit
Get a single commit.
- Parameters:
sha – Commit SHA or branch name accepted by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit details.
- compare(*, base: str, head: str, owner: str | None = None, repo: str | None = None) CommitComparison
Compare two refs in a repository.
- Parameters:
base – Base commit SHA, branch, or tag.
head – Head commit SHA, branch, or tag.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit comparison payload.
- list_comments(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[CommitComment]
List commit comments for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Commit comments.
- get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) CommitComment
Get a single commit comment.
- Parameters:
comment_id – Commit comment identifier.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Commit comment details.
- create_comment(*, sha: str, body: str, owner: str | None = None, repo: str | None = None, path: str | None = None, position: int | None = None) CommitComment
Create a comment on a commit.
- Parameters:
sha – Commit SHA.
body – Comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
path – Optional file path associated with the comment.
position – Optional diff position.
- Returns:
Created commit comment.
- update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) CommitComment
Update a commit comment.
- Parameters:
comment_id – Commit comment identifier.
body – Updated comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Updated commit comment.
- delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete a commit comment.
- Parameters:
comment_id – Commit comment identifier.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- class IssuesResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous issue endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None, state: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Issue]
List issues for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
state – Issue state filter such as
openorclosed(see Issues API).sort – Optional sort field.
direction – Optional sort direction.
page – Page number.
per_page – Page size.
- Returns:
Matching issues.
- get(*, number: int | str, owner: str | None = None, repo: str | None = None) Issue
Get a single issue by number.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Issue details.
- create(*, owner: str, repo: str | None = None, title: str, body: str | None = None, assignee: str | None = None, labels: List[str] | None = None, milestone: int | str | None = None, security_hole: str | None = None) Issue
Create an issue for a repository.
- Parameters:
owner – Repository owner path.
repo – Repository name. Uses the client default when omitted.
title – Issue title.
body – Optional issue description.
assignee – Optional assignee username.
labels – Optional label names.
milestone – Optional milestone identifier.
security_hole – Whether the issue is private; form field described in the Issues API (default public).
- Returns:
Created issue details.
- update(*, number: int | str, owner: str, repo: str | None = None, title: str | None = None, body: str | None = None, state: str | None = None, assignee: str | None = None, labels: List[str] | None = None, milestone: int | str | None = None, security_hole: str | None = None) Issue
Update an existing issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path.
repo – Repository name. Uses the client default when omitted.
title – Updated issue title.
body – Updated issue description.
state – Updated state such as
reopenorclose.assignee – Updated assignee username.
labels – Replacement label names.
milestone – Updated milestone identifier.
security_hole – Whether the issue is private; form field described in the Issues API.
- Returns:
Updated issue details.
- list_comments(*, number: int | str, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[IssueComment]
List comments for an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path (name). Uses the client default when omitted.
page – Current page number (query).
per_page – Page size; maximum per REST API is typically 100.
- Returns:
Issue comments.
- create_comment(*, number: int | str, body: str, owner: str | None = None, repo: str | None = None) IssueComment
Create a comment on an issue.
- Parameters:
number – Repository-local issue number.
body – Comment body text.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Created comment.
- get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) IssueComment
Get a single issue comment by identifier.
- Parameters:
comment_id – Comment id from the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Issue comment.
- update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) IssueComment
Update an issue comment.
- Parameters:
comment_id – Comment id from the API.
body – Updated comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Updated comment.
- delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete an issue comment.
- Parameters:
comment_id – Comment id from the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- list_pull_requests(*, number: int | str, owner: str | None = None, repo: str | None = None) List[PullRequest]
List pull requests associated with an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull requests linked to the issue.
- add_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Add labels to an issue.
- Parameters:
number – Repository-local issue number.
labels – Label names to add (request body is a JSON array per REST API).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels on the issue after the operation.
- remove_label(*, number: int | str, name: str, owner: str | None = None, repo: str | None = None) None
Remove one label from an issue (REST path includes the label name).
- Parameters:
number – Repository-local issue number.
name – Label name to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- list_enterprise(*, enterprise: str, **params) List[Issue]
List enterprise issues visible to the caller.
- Parameters:
enterprise – Enterprise path or login.
params – Additional query parameters accepted by
GET .../enterprises/{enterprise}/issues.
- Returns:
Enterprise-scoped issues.
- list_user(**params) List[Issue]
List issues for the authenticated user.
- Parameters:
params – Query parameters for
GET /user/issues(filters, pagination, etc.).- Returns:
Issues assigned to or authored by the user, per API rules.
- list_org(*, org: str, **params) List[Issue]
List organization issues visible to the current user.
- Parameters:
org – Organization path or login.
params – Query parameters for
GET .../orgs/{org}/issues.
- Returns:
Organization-scoped issues.
- get_enterprise_issue(*, enterprise: str, number: int | str) Issue
Get a specific enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue id or number as accepted by the API path.
- Returns:
Issue payload.
- list_enterprise_comments(*, enterprise: str, number: int | str, **params) List[IssueComment]
List comments for an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue identifier in the path.
params – Optional pagination or filter query parameters.
- Returns:
Comments on the enterprise issue.
- list_enterprise_labels(*, enterprise: str, issue_id: int | str) List[Label]
List labels attached to an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
issue_id – Enterprise issue id in the path segment
.../issues/{issue_id}/labels.
- Returns:
Labels on the issue.
- list_operation_logs(*, owner: str, number: int | str, page: int | None = None, per_page: int | None = None) List[IssueOperationLog]
List operation (audit) logs for an issue.
- Parameters:
owner – Repository owner path (path segment
repos/{owner}/...for this endpoint).number – Repository-local issue number.
page – Page number.
per_page – Page size.
- Returns:
Operation log entries.
- list_templates(*, owner: str | None = None, repo: str | None = None) List[RepositoryGitCodeTemplate]
List active issue templates under
.gitcode/for this repository.Matches Markdown (
.md,.markdown) and YAML (.yml/.yaml) paths whose names start withISSUE_TEMPLATEunder.gitcode/(case-insensitive), including files inside localized directories such as.gitcode/ISSUE_TEMPLATE.en/.Resolution tries the repository, then the owner’s
.gitcoderepository, then any parent main andparent/.gitcodepairs discovered from forks (each candidate is inspected withGET /repos/{owner}/{repo}; whenforkis true, its parent’s repos are appended, deduplicated, and visited in order). The first source with matching templates wins.Version 1.2.19: Now also supporting GitHub-mirrored repos with a
.github/folder.- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Template metadata entries (paths and SHAs); empty when none match.
- get_template(*, path: str, owner: str | None = None, repo: str | None = None, encoding: str = 'utf-8', **decoding_kwargs) str
Load a single issue template file body from the default branch.
Uses the same resolution order as
list_templates(). The path must match the active issue template naming convention (see GitCode.gitcodedocumentation).- Parameters:
path – Repository-relative path such as
.gitcode/ISSUE_TEMPLATE_bug.mdor.gitcode/ISSUE_TEMPLATE/config.yml.owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
encoding – Codec to use when decoding raw file bytes. Default
utf-8.decoding_kwargs – Keyword arguments forwarded to
bytes.decode(), such aserrors("strict","ignore", or"replace").
- Returns:
Decoded template file contents.
- class LabelsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous label endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None) List[Label]
List repository labels.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
All labels defined on the repository.
- create(*, name: str, color: str, owner: str | None = None, repo: str | None = None) Label
Create a repository label.
- Parameters:
name – Label name.
color – Label color (typically a
#RRGGBBhex string per API examples).owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Created label.
- update(*, original_name: str, owner: str | None = None, repo: str | None = None, name: str | None = None, color: str | None = None) Label
Update a repository label.
- Parameters:
original_name – Current label name in the URL path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
name – New label name, if renaming.
color – New color value.
- Returns:
Updated label.
- delete(*, name: str, owner: str | None = None, repo: str | None = None) None
Delete a repository label.
- Parameters:
name – Label name in the path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- clear_issue_labels(*, number: int | str, owner: str | None = None, repo: str | None = None) None
Remove all labels from an issue.
- Parameters:
number – Repository-local issue number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- replace_issue_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Replace all labels on an issue.
- Parameters:
number – Repository-local issue number.
labels – Complete new label set (JSON array body).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after replacement.
- list_enterprise(*, enterprise: str, search: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None, api_version: str = 'v5') List[Label]
List labels for an enterprise, optionally using a different API version.
- Parameters:
enterprise – Enterprise path or login.
search – Optional name search string.
direction – Sort direction for results.
page – Page number.
per_page – Page size.
api_version –
v5uses/api/v5/...; other values build/api/{version}/...on the same host.
- Returns:
Enterprise label definitions.
- class MembersResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous repository member endpoints.
Bind the resource to a synchronous API client.
- add_or_update(*, username: str, owner: str | None = None, repo: str | None = None, permission: str | None = None) RepoMember
Add or update repository member permissions.
- Parameters:
username – Collaborator login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
permission – Permission string (for example
pull,push,adminper GitCode API).
- Returns:
Collaborator record.
- remove(*, username: str, owner: str | None = None, repo: str | None = None) None
Remove a repository member.
- Parameters:
username – Collaborator login to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- list(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[RepoCollaborator]
List repository members (collaborators).
- 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:
Collaborators with permission metadata.
- get(*, username: str, owner: str | None = None, repo: str | None = None) RepositoryCollaboratorCheck
Check whether a user is a repository member.
- get_permission(*, username: str, owner: str | None = None, repo: str | None = None) RepoMemberPermission
Get repository member permissions.
- Parameters:
username – Collaborator login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Effective permission for the user on the repository.
- class MilestonesResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous milestone endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None, **params) List[Milestone]
List milestones for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
params – Query parameters accepted by the milestones listing (state, sort, pagination, etc.).
- Returns:
Milestones.
- get(*, number: int | str, owner: str | None = None, repo: str | None = None) Milestone
Get a single milestone.
- Parameters:
number – Milestone number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Milestone details.
- create(*, title: str, due_on: str, owner: str | None = None, repo: str | None = None, description: str | None = None) Milestone
Create a milestone.
- Parameters:
title – Milestone title.
due_on – Due date string in the format expected by the API (often ISO 8601).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
description – Optional description.
- Returns:
Created milestone.
- update(*, number: int | str, title: str, due_on: str, owner: str | None = None, repo: str | None = None, description: str | None = None, state: str | None = None) Milestone
Update a milestone.
- Parameters:
number – Milestone number.
title – Updated title.
due_on – Updated due date.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
description – Updated description.
state – Milestone state such as
openorclosedper API.
- Returns:
Updated milestone.
- delete(*, number: int | str, owner: str | None = None, repo: str | None = None) None
Delete a milestone.
- Parameters:
number – Milestone number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- class OAuthResource(client: SyncAPIClient)
Bases:
SyncResourceHelpers for GitCode OAuth URLs and token exchange.
Bind the resource to a synchronous API client.
- build_authorize_url(*, client_id: str, redirect_uri: str, scope: str | None = None, state: str | None = None, response_type: str = 'code') str
Build the GitCode OAuth authorization URL.
- Parameters:
client_id – OAuth application client ID.
redirect_uri – Registered redirect URI.
scope – Optional OAuth scopes.
state – Optional CSRF protection value.
response_type – OAuth response type, defaults to
"code".
- Returns:
Browser URL for the authorization step.
- exchange_token(*, code: str, client_id: str, client_secret: str) OAuthToken
Exchange an authorization code for an OAuth token.
- Parameters:
code – Authorization code returned by GitCode.
client_id – OAuth application client ID.
client_secret – OAuth application client secret.
- Returns:
OAuth access token payload.
- refresh_token(*, refresh_token: str) OAuthToken
Refresh an OAuth token.
- Parameters:
refresh_token – Refresh token previously issued by GitCode.
- Returns:
Refreshed OAuth token payload.
- class OrgsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous organization and enterprise endpoints.
Bind the resource to a synchronous API client.
- list_for_user(*, username: str, page: int | None = None, per_page: int | None = None) List[OrganizationSummary]
List organizations for a user.
- Parameters:
username – GitCode username or login.
page – Page number.
per_page – Page size.
- Returns:
Organizations the user belongs to.
- list_authenticated(*, page: int | None = None, per_page: int | None = None, admin: bool | None = None) List[OrganizationSummary]
List organizations for the authenticated user.
- Parameters:
page – Page number.
per_page – Page size.
admin – Optional admin-only filter.
- Returns:
Organizations visible to the authorized user.
- get_member(*, org: str, username: str) OrganizationMembership
Get an organization member profile.
- Parameters:
org – Organization path or login.
username – Member username or login.
- Returns:
Organization membership details.
- get(*, org: str) Organization
Get an organization.
- Parameters:
org – Organization path or login.
- Returns:
Organization details.
- list_repos(*, org: str, type: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories for an organization.
- Parameters:
org – Organization path or login.
type – Repository type filter such as
all,public, orprivate.page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- create_repo(*, org: str, name: str, **payload) Repository
Create an organization repository.
Additional payload fields match the organization repository creation endpoint, such as
description,homepage,private,public,auto_init, anddefault_branch.- Parameters:
org – Organization path or login.
name – Repository name.
payload – Additional repository creation fields.
- Returns:
Created repository metadata.
- get_enterprise_member(*, enterprise: str, username: str) EnterpriseMember
Get a member profile for an enterprise.
- Parameters:
enterprise – Enterprise path or login.
username – Member username or login.
- Returns:
Enterprise membership details.
- get_membership(*, org: str) OrganizationMembership
Get the authenticated user’s membership in an organization.
- Parameters:
org – Organization path or login.
- Returns:
Membership details for the current user.
- list_members(*, org: str, page: int | None = None, per_page: int | None = None, role: str | None = None) List[User]
List members of an organization.
- Parameters:
org – Organization path or login.
page – Page number.
per_page – Page size.
role – Optional role filter such as
all,admin, ormember.
- Returns:
Organization members.
- list_enterprise_members(*, enterprise: str, page: int | None = None, per_page: int | None = None, role: str | None = None) List[EnterpriseMember]
List members of an enterprise.
- Parameters:
enterprise – Enterprise path or login.
page – Page number.
per_page – Page size.
role – Optional role filter.
- Returns:
Enterprise members.
- remove_member(*, org: str, username: str) EmptyResponse
Remove a member from an organization.
- Parameters:
org – Organization path or login.
username – Member username or login.
- Returns:
API response payload, if any.
- list_followers(*, owner: str, page: int | None = None, per_page: int | None = None) List[User]
List followers of an organization.
- Parameters:
owner – Organization path.
page – Page number.
per_page – Page size.
- Returns:
Followers of the organization.
- get_issue_extend_settings(*, org: str) List[APIObject]
Get extended issue type and status settings for an organization.
- Parameters:
org – Organization path or login.
- Returns:
Extended issue configuration entries.
- invite_member(*, org: str, username: str, permission: str | None = None, role_id: str | None = None) User
Invite a user to an organization.
- Parameters:
org – Organization path or login.
username – Member username or login.
permission – Permission level such as
pull,push, oradmin.role_id – Custom role identifier when using a customized permission.
- Returns:
Invited user information with permissions.
- update_enterprise_member(*, enterprise: str, username: str, role: str) EnterpriseMember
Update the role of an enterprise member.
- Parameters:
enterprise – Enterprise path or login.
username – Member username or login.
role – Enterprise role such as
viewer,developer, oradmin.
- Returns:
Updated enterprise membership.
- update(*, org: str, **payload) Organization
Update organization metadata.
- Parameters:
org – Organization path or login.
payload – Updatable fields such as
name,email, ordescription.
- Returns:
Updated organization details.
- leave(*, org: str) None
Leave an organization as the authenticated user.
- Parameters:
org – Organization path or login.
- class PullsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous pull request endpoints.
Bind the resource to a synchronous API client.
- list(*, owner: str | None = None, repo: str | None = None, state: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None, **params) List[PullRequest] | PullRequestCount
List pull requests for a repository.
When
only_countis true inparams(or passed via**params), the API returns a JSON object with counts per state instead of an array (see Pull Request API).- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path (name). Uses the client default when omitted.
state – PR state filter:
all,open,closed,locked,merged(defaultallin API).sort – Sort field, typically
createdorupdated.direction –
ascordesc(API default is usuallydesc).page – Current page number.
per_page – Page size (max 100 per API documentation).
params – Extra query parameters from the Pull Request API, for example
base,since,author,assignee,reviewer,milestone_number,labels(comma-separated),merged_after,merged_before,created_after,created_before,updated_after,updated_before,only_count(boolean), and ISO 8601 timestamps (URL-encoded when sent).
- Returns:
A list of pull requests, or an
APIObjectfor count-only responses.
- get(*, number: int | str, owner: str | None = None, repo: str | None = None) PullRequest
Get a single pull request.
- Parameters:
number – Pull request number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull request details.
- create(*, title: str, head: str, base: str, owner: str | None = None, repo: str | None = None, body: str | None = None, draft: bool | None = None, assignees: List[str] | None = None, testers: List[str] | None = None, labels: List[str] | None = None, milestone_number: int | None = None, issue: str | None = None, prune_source_branch: bool | None = None, squash: bool | None = None, squash_commit_message: str | None = None, fork_path: str | None = None) PullRequest
Create a pull request.
- Parameters:
title – Pull request title.
head – Source branch ref (head branch, in forks use
owner:branchlike “SushiNinja:develop”).base – Target branch ref (base branch).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
body – Description body.
draft – Whether to create as draft.
assignees – Assignee logins; sent as a comma-separated string per API.
testers – Tester logins; comma-separated in the JSON body.
labels – Label names; comma-separated in the JSON body.
milestone_number – Target milestone number.
issue – Related issue reference when supported by the API.
prune_source_branch – Whether to delete the source branch after merge when applicable.
squash – Squash-merge preference where supported.
squash_commit_message – Custom squash commit message.
fork_path – Fork
owner/repowhen opening a PR from a fork, like “SushiNinja/agent-core-contrib”.
- Returns:
Created pull request.
- update(*, number: int | str, owner: str | None = None, repo: str | None = None, title: str | None = None, body: str | None = None, state: str | None = None, base: str | None = None, labels: List[str] | None = None, draft: bool | None = None) PullRequest
Update a pull request.
- Parameters:
number – Pull request number in the repository.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
title – New title.
body – New description.
state – New state as accepted by the API (for example close or reopen semantics).
base – New base branch name.
labels – Replacement labels; comma-separated in the JSON body.
draft – Draft flag.
- Returns:
Updated pull request.
- merge(*, number: int | str, owner: str | None = None, repo: str | None = None, merge_commit_message: str | None = None, squash: bool | None = None) MergeResult
Merge a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
merge_commit_message – Optional merge commit message.
squash – Whether to squash merge when supported.
- Returns:
Merge result payload.
- get_merge_status(*, number: int | str, owner: str | None = None, repo: str | None = None) MergeStatus
Get mergeability status for a pull request (GET on the merge resource).
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Merge status / mergeability information.
- list_commits(*, number: int | str, owner: str | None = None, repo: str | None = None) List[APIObject]
List commits included in a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Commit objects (wrapped as
APIObject).
- list_files(*, number: int | str, owner: str | None = None, repo: str | None = None) List[PullRequestFile]
List files changed by a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
File change entries.
- list_comments(*, number: int | str, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[PullRequestComment]
List comments on a pull request.
- Parameters:
number – Pull request number.
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:
Pull request review comments.
- create_comment(*, number: int | str, body: str, owner: str | None = None, repo: str | None = None, commit_id: str | None = None, path: str | None = None, position: int | None = None) PullRequestComment
Create a pull request (review) comment.
- Parameters:
number – Pull request number.
body – Comment body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
commit_id – Commit SHA the comment applies to.
path – File path in the diff.
position – Line or diff position as defined by the API.
- Returns:
Created comment.
- get_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) PullRequestComment
Get a single pull request comment by id (global comment endpoint).
- Parameters:
comment_id – Comment id.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Pull request comment.
- update_comment(*, comment_id: int | str, body: str, owner: str | None = None, repo: str | None = None) PullRequestComment
Update a pull request comment.
- Parameters:
comment_id – Comment id.
body – Updated body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Updated comment.
- delete_comment(*, comment_id: int | str, owner: str | None = None, repo: str | None = None) None
Delete a pull request comment.
- Parameters:
comment_id – Comment id.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- list_labels(*, number: int | str, owner: str | None = None, repo: str | None = None) List[Label]
List labels attached to a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels on the pull request.
- add_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Add labels to a pull request.
- Parameters:
number – Pull request number.
labels – Label names (JSON array body per API).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after the operation.
- replace_labels(*, number: int | str, labels: List[str], owner: str | None = None, repo: str | None = None) List[Label]
Replace all labels on a pull request.
- Parameters:
number – Pull request number.
labels – Complete new label set (JSON array body).
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Labels after replacement.
- remove_label(*, number: int | str, label: str, owner: str | None = None, repo: str | None = None) None
Remove a label from a pull request.
- Parameters:
number – Pull request number.
label – Label name to remove.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- request_review(*, number: int | str, owner: str | None = None, repo: str | None = None, event: str, body: str | None = None) None
Submit a pull request review event (approve, request changes, etc., per API).
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
event – Review event name as required by GitCode (for example
APPROVE; see API docs).body – Optional comment body accompanying the event.
- Returns:
Review result object.
- list_operation_logs(*, number: int | str, owner: str | None = None, repo: str | None = None, **params) List[PullRequestOperationLog]
List operation logs for a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
params – Additional query parameters accepted by the operate_logs endpoint.
- Returns:
Log entries as generic API objects.
- request_test(*, number: int | str, owner: str | None = None, repo: str | None = None, **payload) None
Request testing for a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
payload – JSON fields required by the test request endpoint.
- Returns:
Test request result.
- update_testers(*, number: int | str, testers: List[str], owner: str | None = None, repo: str | None = None) None
Replace pull request testers.
- Parameters:
number – Pull request number.
testers – New tester list; serialized as a comma-separated
testersfield in JSON.owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- add_testers(*, number: int | str, testers: List[str], owner: str | None = None, repo: str | None = None) List[UserSummary]
Add testers to a pull request.
- Parameters:
number – Pull request number.
testers – Usernames to add; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- update_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) None
Replace pull request assignees.
- Parameters:
number – Pull request number.
assignees – New assignee list; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- add_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) PullRequestAssigneeCount
Add assignees to a pull request.
- Parameters:
number – Pull request number.
assignees – Usernames to add; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
API response payload.
- remove_assignees(*, number: int | str, assignees: List[str], owner: str | None = None, repo: str | None = None) None
Remove assignees from a pull request.
- Parameters:
number – Pull request number.
assignees – Usernames to remove; comma-separated in the JSON body.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- list_issues(*, number: int | str, owner: str | None = None, repo: str | None = None) List[Issue]
List issues linked to a pull request.
- Parameters:
number – Pull request number.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Linked issues.
- list_enterprise(*, enterprise: str, **params) List[PullRequest]
List enterprise pull requests.
- Parameters:
enterprise – Enterprise path or login.
params – Query parameters for the enterprise pull_requests listing.
- Returns:
Pull requests in the enterprise scope.
- list_org(*, org: str, **params) List[PullRequest]
List pull requests for an organization scope.
- Parameters:
org – Organization path (
GET .../org/{org}/pull_requests).params – Query parameters accepted by that listing.
- Returns:
Organization-scoped pull requests.
- list_issue_pull_requests(*, enterprise: str, number: int | str) List[PullRequest]
List pull requests associated with an enterprise issue.
- Parameters:
enterprise – Enterprise path or login.
number – Enterprise issue number or id in the path.
- Returns:
Related pull requests.
- list_templates(*, owner: str | None = None, repo: str | None = None) List[RepositoryGitCodeTemplate]
List active pull request templates under
.gitcode/for this repository.Resolution tries the repository, then the owner’s
.gitcoderepository, then any parent main andparent/.gitcodepairs discovered from forks (each candidate is inspected withGET /repos/{owner}/{repo}; whenforkis true, its parent’s repos are appended, deduplicated, and visited in order). The first source with matching templates wins.Version 1.2.19: Now also supporting GitHub-mirrored repos with a
.github/folder.- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Template metadata entries (paths and SHAs); empty when none match.
- get_template(*, path: str, owner: str | None = None, repo: str | None = None, encoding: str = 'utf-8', **decoding_kwargs) str
Load a single pull request template file body from the default branch.
Uses the same resolution order as
list_templates(). The path must match the active pull request template naming convention (see GitCode.gitcodedocumentation).- Parameters:
path – Repository-relative path such as
.gitcode/PULL_REQUEST_TEMPLATE.md.owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
encoding – Codec to use when decoding raw file bytes. Default
utf-8.decoding_kwargs – Keyword arguments forwarded to
bytes.decode(), such aserrors("strict","ignore", or"replace").
- Returns:
Decoded template file contents.
- class RepoContentsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous repository contents endpoints.
Bind the resource to a synchronous API client.
- get(*, path: str, owner: str | None = None, repo: str | None = None, ref: str | None = None) ContentObject
Get a file or directory entry from a repository.
- Parameters:
path – Repository-relative file path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref – Optional branch, tag, or commit SHA.
- Returns:
Content metadata and payload details.
- create(*, path: str, content: str, message: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Create a file in a repository.
- Parameters:
path – Repository-relative file path.
content – File content, typically base64-encoded for this API.
message – Commit message.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- update(*, path: str, content: str, message: str, sha: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Update a file in a repository.
- Parameters:
path – Repository-relative file path.
content – Updated file content, typically base64-encoded.
message – Commit message.
sha – Current blob SHA required by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- delete(*, path: str, message: str, sha: str, owner: str | None = None, repo: str | None = None, branch: str | None = None, author_name: str | None = None, author_email: str | None = None) CommitResult
Delete a file from a repository.
- Parameters:
path – Repository-relative file path.
message – Commit message.
sha – Current blob SHA required by the API.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
branch – Optional target branch.
author_name – Optional commit author name.
author_email – Optional commit author email.
- Returns:
Commit result payload.
- list_paths(*, owner: str | None = None, repo: str | None = None, ref_name: str | None = None, file_name: str | None = None) List[str]
List repository paths known to GitCode.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref_name – Optional ref name to inspect.
file_name – Optional filename filter.
- Returns:
Matching repository paths.
- get_tree(*, sha: str, owner: str | None = None, repo: str | None = None, recursive: int | None = None, page: int | None = None, per_page: int | None = None) Tree
Get a Git tree object.
- Parameters:
sha – Tree SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
recursive – Pass
1to fetch the tree recursively (query parameter per Repository API).page – Page number for large trees.
per_page – Page size for large trees.
- Returns:
Tree metadata and entries.
- get_blob(*, sha: str, owner: str | None = None, repo: str | None = None) Blob
Get a Git blob object by SHA.
- Parameters:
sha – Blob SHA.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Blob metadata and content.
- get_raw(*, path: str, owner: str | None = None, repo: str | None = None, ref: str | None = None) bytes
Download raw file bytes from a repository.
- Parameters:
path – Repository-relative file path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
ref – Optional branch, tag, or commit SHA.
- Returns:
Raw file bytes.
- class ReleasesResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous release endpoints.
Bind the resource to a synchronous API client.
- create(*, tag: str, name: str, body: str, owner: str | None = None, repo: str | None = None, target_commitish: str | None = None, release_status: str | None = None) Release
Create a repository release.
- Parameters:
tag – Tag name for the release.
name – Release title.
body – Release description.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
target_commitish – Branch name or commit SHA for creating a missing tag.
release_status – Release status, such as
preorlatest.
- Returns:
Created release payload.
- update(*, tag: str, name: str, body: str, owner: str | None = None, repo: str | None = None, release_status: str | None = None) Release
Update a repository release.
- Parameters:
tag – Tag name in the release URL path.
name – Release name.
body – Release description.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
release_status – Release status, such as
preorlatest.
- Returns:
Updated release payload.
- get_upload_url(*, tag: str, file_name: str, owner: str | None = None, repo: str | None = None) ReleaseUploadURL
Get a pre-signed URL for uploading a release attachment.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name to upload.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Upload URL and required headers.
- upload(*, tag: str, file_name: str, content: bytes | str, owner: str | None = None, repo: str | None = None, upload_timeout: float | None = 300.0) None
Upload a release attachment through the pre-signed upload URL.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name to upload.
content – Attachment bytes, or a local file path to read as bytes.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
upload_timeout – Timeout for upload operation. Default to 300 (5 minutes).
- 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, direction: str | None = None, page: int | None = None, per_page: int | 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.
direction – Sort direction, for example
ascordesc.page – Page number.
per_page – Page size, up to 100.
- Returns:
Releases ordered as returned by the API.
- get_latest(*, owner: str | None = None, repo: str | None = None, type: str | None = None) Release
Get the latest repository release.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
type – Selection type, either
updatedorlatest.
- Returns:
Latest release metadata.
- get(*, tag: str, owner: str | None = None, repo: str | None = None, temp_download_url: bool | str | None = None) Release
Get a repository release by tag path.
- Parameters:
tag – Tag name in the release URL path.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
temp_download_url – Whether to return temporary source package and attachment URLs.
- Returns:
Release metadata.
- download_attachment(*, tag: str, file_name: str, owner: str | None = None, repo: str | None = None) bytes
Download a release attachment as bytes.
- Parameters:
tag – Tag name in the release URL path.
file_name – Attachment file name.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository path. Uses the client default when omitted.
- Returns:
Attachment bytes.
- class ReposResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous repository endpoints.
Bind the resource to a synchronous API client.
- get(*, owner: str | None = None, repo: str | None = None) Repository
Get a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Repository metadata.
- list_user(*, visibility: str | None = None, affiliation: str | None = None, type: str | None = None, sort: str | None = None, direction: str | None = None, q: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories visible to the authenticated user.
- Parameters:
visibility – Visibility filter such as
public,private, orall.affiliation – Ownership filter accepted by the REST API.
type – Repository type filter.
sort – Sort field such as
createdorfull_name.direction – Sort direction.
q – Optional keyword filter.
page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- list_for_owner(*, owner: str, type: str | None = None, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List public repositories for a user or owner path.
- Parameters:
owner – Repository owner path or username.
type – Repository type filter.
sort – Sort field.
direction – Sort direction.
page – Page number.
per_page – Page size.
- Returns:
Matching repositories.
- create_personal(*, name: str, description: str | None = None, path: str | None = None, private: bool | None = None, auto_init: bool | None = None, has_issues: bool | None = None, has_wiki: bool | None = None, default_branch: str | None = None, gitignore_template: str | None = None, license_template: str | None = None) Repository
Create a repository for the authenticated user.
- Parameters:
name – Repository name.
description – Repository description.
path – Optional repository path.
private – Whether the repository should be private.
auto_init – Whether to initialize the repository with a README.
has_issues – Whether issues are enabled.
has_wiki – Whether wiki support is enabled.
default_branch – Default branch name when initializing.
gitignore_template – Optional gitignore template.
license_template – Optional license template.
- Returns:
Created repository metadata.
- create_for_org(*, org: str, name: str, description: str | None = None, homepage: str | None = None, path: str | None = None, private: bool | None = None, public: int | None = None, auto_init: bool | None = None, has_issues: bool | None = None, has_wiki: bool | None = None, can_comment: bool | None = None, default_branch: str | None = None, gitignore_template: str | None = None, license_template: str | None = None) Repository
Create a repository under an organization.
- Parameters:
org – Organization path or login.
name – Repository name.
description – Repository description.
homepage – Repository homepage URL.
path – Optional repository path.
private – Whether the repository should be private.
public – Visibility mode used by the GitCode API.
auto_init – Whether to initialize the repository with a README.
has_issues – Whether issues are enabled.
has_wiki – Whether wiki support is enabled.
can_comment – Whether comments are enabled.
default_branch – Default branch name when initializing.
gitignore_template – Optional gitignore template.
license_template – Optional license template.
- Returns:
Created repository metadata.
- update(*, owner: str | None = None, repo: str | None = None, **changes) Repository
Update repository metadata.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
changes – Repository fields accepted by the update endpoint.
- Returns:
Updated repository metadata.
- delete(*, owner: str | None = None, repo: str | None = None) None
Delete a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- fork(*, owner: str | None = None, repo: str | None = None, namespace: str | None = None, path: str | None = None, name: str | None = None) Repository
Fork a repository.
- Parameters:
owner – Source repository owner path.
repo – Source repository name.
namespace – Optional destination namespace.
path – Optional destination repository path.
name – Optional destination repository name.
- Returns:
Forked repository metadata.
- list_forks(*, owner: str | None = None, repo: str | None = None, sort: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List forks of a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
sort – Optional sort field.
page – Page number.
per_page – Page size.
- Returns:
Fork repositories.
- list_contributors(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[Contributor]
List repository contributors.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Contributors for the repository.
- list_languages(*, owner: str | None = None, repo: str | None = None) Dict[str, int]
List language statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Mapping of language names to byte counts.
- list_stargazers(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[UserSummary]
List users who starred a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Users who starred the repository.
- list_subscribers(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[UserSummary]
List users watching a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Subscribers for the repository.
- update_module_settings(*, owner: str | None = None, repo: str | None = None, **settings) ApiStatusResponse
Update repository module settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
settings – Module settings accepted by the GitCode API.
- Returns:
API response payload.
- update_reviewer_settings(*, owner: str | None = None, repo: str | None = None, **settings) RepositoryReviewerSettingsUpdate
Update repository reviewer settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
settings – Reviewer settings accepted by the GitCode API.
- Returns:
API response payload.
- set_org_repo_status(*, org: str, repo: str, **payload) ApiStatusResponse
Update organization repository status metadata.
- Parameters:
org – Organization path.
repo – Repository path.
payload – Status fields accepted by the API.
- Returns:
API response payload.
- transfer_to_org(*, org: str, repo: str, **payload) ApiStatusResponse
Transfer a repository to an organization.
- Parameters:
org – Destination organization path.
repo – Repository path.
payload – Transfer options accepted by the API.
- Returns:
API response payload.
- get_transition(*, owner: str | None = None, repo: str | None = None) RepositoryPermissionMode
Get repository transition settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Transition configuration.
- update_transition(*, owner: str | None = None, repo: str | None = None, **payload) ApiStatusResponse
Update repository transition settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Transition settings accepted by the API.
- Returns:
API response payload.
- update_push_config(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryPushConfig
Update repository push configuration.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Push configuration values accepted by the API.
- Returns:
API response payload.
- get_push_config(*, owner: str | None = None, repo: str | None = None) RepositoryPushConfig
Get repository push configuration.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Push configuration payload.
- upload_image(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryUploadResult
Upload an image asset for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Upload fields accepted by the API.
- Returns:
Uploaded image metadata.
- upload_file(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryUploadResult
Upload a file asset for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Upload fields accepted by the API.
- Returns:
Uploaded file metadata.
- update_repo_settings(*, owner: str | None = None, repo: str | None = None, **payload) RepositorySettings
Update repository settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Settings fields accepted by the API.
- Returns:
API response payload.
- get_repo_settings(*, owner: str | None = None, repo: str | None = None) RepositorySettings
Get repository settings.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Repository settings payload.
- get_pull_request_settings(*, owner: str | None = None, repo: str | None = None) PullRequestSettings
Get pull request settings for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Pull request settings payload.
- update_pull_request_settings(*, owner: str | None = None, repo: str | None = None, **payload) PullRequestSettings
Update pull request settings for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Pull request settings accepted by the API.
- Returns:
API response payload.
- set_member_role(*, username: str, owner: str | None = None, repo: str | None = None, permission: str | None = None) RepoMember
Set a repository member role.
- Parameters:
username – Member username or login.
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
permission – Permission or role name accepted by the API.
- Returns:
API response payload.
- transfer(*, owner: str | None = None, repo: str | None = None, **payload) RepositoryTransferResult
Transfer a repository to another owner or namespace.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
payload – Transfer options accepted by the API.
- Returns:
API response payload.
- list_customized_roles(*, owner: str | None = None, repo: str | None = None) List[RepositoryCustomizedRole]
List customized roles for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Customized role definitions.
- get_download_statistics(*, owner: str | None = None, repo: str | None = None, **params) RepositoryDownloadStatistics
Get download statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
params – Query parameters accepted by the statistics endpoint.
- Returns:
Download statistics payload.
- get_contributor_statistics(*, owner: str | None = None, repo: str | None = None) List[ContributorStatistics]
Get code contribution statistics for a repository.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
- Returns:
Contributor statistics payload.
- list_events(*, owner: str | None = None, repo: str | None = None, page: int | None = None, per_page: int | None = None) List[APIObject]
List repository events.
- Parameters:
owner – Repository owner path. Uses the client default when omitted.
repo – Repository name. Uses the client default when omitted.
page – Page number.
per_page – Page size.
- Returns:
Repository event payloads.
- class SearchResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous search endpoints.
Bind the resource to a synchronous API client.
- users(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None) List[SearchUser]
Search users.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field such as
joined_at.order – Sort order, usually
ascordesc.
- Returns:
Matching user search results.
- issues(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None, repo: str | None = None, state: str | None = None) List[SearchIssue]
Search issues.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field.
order – Sort order, usually
ascordesc.repo – Optional repository path filter.
state – Optional issue state filter.
- Returns:
Matching issue search results.
- repositories(*, q: str, page: int | None = None, per_page: int | None = None, sort: str | None = None, order: str | None = None, owner: str | None = None, fork: str | None = None, language: str | None = None) List[SearchRepository]
Search repositories.
- Parameters:
q – Search keywords.
page – Page number.
per_page – Page size.
sort – Optional sort field such as
stars_count.order – Sort order, usually
ascordesc.owner – Optional owner path filter.
fork – Optional fork visibility filter.
language – Optional programming language filter.
- Returns:
Matching repository search results.
- class TagsResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous 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 UsersResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous user and account endpoints.
Bind the resource to a synchronous API client.
- get(*, username: str) User
Get a user profile.
- Parameters:
username – GitCode username or login.
- Returns:
User profile details.
- list_emails() List[Email]
List email addresses for the authenticated user.
- Returns:
Email records associated with the current account.
- list_events(*, username: str, year: str | None = None, next: str | None = None) UserEventsResponse
List activity events for a user.
- Parameters:
username – GitCode username or login (path segment, see User API).
year – Optional start year filter (query
year, e.g.2024per documentation).next – Optional end date / pagination cursor (query
next; often an ISO timestamp from a prior page).
- Returns:
Event payload grouped by date.
- list_repos(*, username: str, **params) List[Repository]
List public repositories owned by a user.
Supported filters follow the user repository API documentation, such as
type,sort,direction,page, andper_page.- Parameters:
username – GitCode username or login.
params – Query parameters accepted by the REST endpoint.
- Returns:
Matching repositories.
- create_key(*, key: str, title: str) PublicKey
Add a public SSH key for the authenticated user.
- Parameters:
key – Public key material.
title – Human-readable key name.
- Returns:
Created key metadata.
- list_keys(*, page: int | None = None, per_page: int | None = None) List[APIObject]
List public SSH keys for the authenticated user.
- Parameters:
page – Page number.
per_page – Page size.
- Returns:
Public key records.
- delete_key(*, key_id: int | str) None
Delete a public SSH key.
- Parameters:
key_id – Public key identifier.
- get_key(*, key_id: int | str) PublicKey
Get a single public SSH key.
- Parameters:
key_id – Public key identifier.
- Returns:
Public key metadata.
- get_namespace(*, path: str) Namespace
Resolve namespace information for the authenticated user.
- Parameters:
path – Namespace path to look up.
- Returns:
Namespace details.
- list_starred(*, sort: str | None = None, direction: str | None = None, page: int | None = None, per_page: int | None = None) List[Repository]
List repositories starred by the authenticated user.
- Parameters:
sort – Sort field such as
createdorupdated.direction – Sort direction, usually
ascordesc.page – Page number.
per_page – Page size.
- Returns:
Starred repositories.
- class WebhooksResource(client: SyncAPIClient)
Bases:
SyncResourceSynchronous 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.