gerrit.projects package
Submodules
gerrit.projects.branches module
- class gerrit.projects.branches.GerritProjectBranch(name: str, project: str, gerrit)[source]
Bases:
GerritBase
- get_file_content(file, decode=False)[source]
Gets the content of a file from the HEAD revision of a certain branch. The content is returned as base64 encoded string.
- Parameters:
file – the file path
decode – Decode bas64 to plain text.
- Returns:
- is_mergeable(input_)[source]
Gets whether the source is mergeable with the target branch.
input_ = { 'source': 'testbranch', 'strategy': 'recursive' } result = stable.is_mergeable(input_)
- Parameters:
input – the MergeInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#merge-input
- Returns:
- class gerrit.projects.branches.GerritProjectBranches(project, gerrit)[source]
Bases:
object
- branch_prefix = 'refs/heads/'
- create(name, input_)[source]
Creates a new branch.
input_ = { 'revision': '76016386a0d8ecc7b6be212424978bb45959d668' } project = client.projects.get('myproject') new_branch = project.branches.create('stable', input_)
- Parameters:
name – the branch name
input – the BranchInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#branch-info
- Returns:
- list(pattern_dispatcher=None, limit: int = 25, skip: int = 0)[source]
List the branches of a project.
- Parameters:
pattern_dispatcher – Dict of pattern type with respective pattern value: {(‘match’|’regex’) : value}
limit – Limit the number of branches to be included in the results.
skip – Skip the given number of branches from the beginning of the list.
- Returns:
gerrit.projects.commit module
- class gerrit.projects.commit.GerritProjectCommit(commit: str, project: str, gerrit)[source]
Bases:
GerritBase
- cherry_pick(input_)[source]
Cherry-picks a commit of a project to a destination branch.
input_ = { "message": "Implementing Feature X", "destination": "release-branch" } result = commit.cherry_pick(input_)
- Parameters:
input – the CherryPickInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#cherrypick-input
- Returns:
the resulting cherry-picked change
gerrit.projects.dashboards module
- class gerrit.projects.dashboards.GerritProjectDashboard(id: str, project: str, gerrit)[source]
Bases:
GerritBase
- class gerrit.projects.dashboards.GerritProjectDashboards(project, gerrit)[source]
Bases:
object
- create(id_, input_)[source]
Creates a project dashboard, if a project dashboard with the given dashboard ID doesn’t exist yet.
input_ = { "id": "master:closed", "commit_message": "Define the default dashboard" } new_dashboard = project.dashboards.create('master:closed', input_)
- Parameters:
id – the dashboard id
input – the DashboardInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#dashboard-input
- Returns:
gerrit.projects.labels module
- class gerrit.projects.labels.GerritProjectLabel(name: str, project: str, gerrit)[source]
Bases:
GerritBase
- delete()[source]
Deletes the definition of a label that is defined in this project. The calling user must have write access to the refs/meta/config branch of the project.
- Returns:
- set(input_)[source]
Updates the definition of a label that is defined in this project. The calling user must have write access to the refs/meta/config branch of the project. Properties which are not set in the input entity are not modified.
input_ = { "commit_message": "Ignore self approvals for Code-Review label", "ignore_self_approval": true } project = client.projects.get("MyProject") label = project.labels.get("foo") result = label.set(input_)
- Parameters:
input – the LabelDefinitionInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#label-definition-input
- Returns:
- class gerrit.projects.labels.GerritProjectLabels(project, gerrit)[source]
Bases:
object
- create(name, input_)[source]
Creates a new label definition in this project. The calling user must have write access to the refs/meta/config branch of the project. If a label with this name is already defined in this project, this label definition is updated (see Set Label).
input_ = { "values": { " 0": "No score", "-1": "I would prefer this is not merged as is", "-2": "This shall not be merged", "+1": "Looks good to me, but someone else must approve", "+2": "Looks good to me, approved" }, "commit_message": "Create Foo Label" } new_label = project.labels.create('foo', input_)
- Parameters:
name – label name
input – the LabelDefinitionInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#label-definition-input
- Returns:
- delete(name)[source]
Deletes the definition of a label that is defined in this project. The calling user must have write access to the refs/meta/config branch of the project.
- Parameters:
name – label name
- Returns:
gerrit.projects.project module
- class gerrit.projects.project.GerritProject(project_id: str, gerrit)[source]
Bases:
GerritBase
- ban_commits(input_)[source]
Marks commits as banned for the project.
input_ = { "commits": [ "a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96", "cf5b56541f84b8b57e16810b18daca9c3adc377b" ], "reason": "Violates IP" } project = client.projects.get('myproject') result = project.ban_commits(input_)
- Parameters:
input – the BanInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#ban-input
- Returns:
- property branches
List the branches of a project. except the refs/meta/config
- Returns:
- check_access(options)[source]
runs access checks for other users.
- Parameters:
options –
- Check Access Options
Account(account): The account for which to check access. Mandatory.
Permission(perm): The ref permission for which to check access. If not specified, read access to at least branch is checked.
Ref(ref): The branch for which to check access. This must be given if perm is
specified.
- Returns:
- check_consistency(input_)[source]
Performs consistency checks on the project.
input_ = { "auto_closeable_changes_check": { "fix": 'true', "branch": "refs/heads/master", "max_commits": 100 } } project = client.projects.get('myproject') result = project.check_consistency(input_)
- Parameters:
input – the CheckProjectInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#check-project-input
- Returns:
- property child_projects
List the direct child projects of a project.
- Returns:
- create_access_rights_change(input_)[source]
Sets access rights for the project using the diff schema provided by ProjectAccessInput This takes the same input as Update Access Rights, but creates a pending change for review. Like Create Change, it returns a ChangeInfo entity describing the resulting change. https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#create-access-change
- Parameters:
input – the ProjectAccessInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-access-input
- Returns:
- create_change(input_)[source]
Create Change for review. This endpoint is functionally equivalent to create change in the change API, but it has the project name in the URL, which is easier to route in sharded deployments. support this method since v3.3.0
input_ = { "subject": "Let's support 100% Gerrit workflow direct in browser", "branch": "stable", "topic": "create-change-in-browser", "status": "NEW" } project = client.projects.get('myproject') result = project.create_change(input_)
- Parameters:
input –
- Returns:
- property dashboards
gerrit dashboards operations
- Returns:
- get_config()[source]
Gets some configuration information about a project. Note that this config info is not simply the contents of project.config; it generally contains fields that may have been inherited from parent projects.
- Returns:
- get_parent()[source]
Retrieves the name of a project’s parent project. For the All-Projects root project an empty string is returned.
- Returns:
- index(input_)[source]
Adds or updates the current project (and children, if specified) in the secondary index. The indexing task is executed asynchronously in background and this command returns immediately if async is specified in the input.
input_ = { "index_children": "true" "async": "true" } project = client.projects.get('myproject') result = project.index(input_)
- Parameters:
input – the IndexProjectInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#index-project-input
- Returns:
- index_all_changes()[source]
Adds or updates the current project (and children, if specified) in the secondary index. The indexing task is executed asynchronously in background and this command returns immediately if async is specified in the input.
- Returns:
- property labels
gerrit labels or gerrit labels operations
- Returns:
- run_garbage_collection(input_)[source]
Run the Git garbage collection for the repository of a project.
input_ = { "show_progress": "true" } project = client.projects.get('myproject') result = project.run_garbage_collection(input_)
- Parameters:
input – the GCInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#gc-input
- Returns:
- set_access_rights(input_)[source]
Sets access rights for the project using the diff schema provided by ProjectAccessInput. https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#set-access
- Parameters:
input – the ProjectAccessInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-access-input
- Returns:
- set_config(input_)[source]
Sets the configuration of a project.
input_ = { "description": "demo project", "use_contributor_agreements": "FALSE", "use_content_merge": "INHERIT", "use_signed_off_by": "INHERIT", "create_new_change_for_all_not_in_target": "INHERIT", "enable_signed_push": "INHERIT", "require_signed_push": "INHERIT", "reject_implicit_merges": "INHERIT", "require_change_id": "TRUE", "max_object_size_limit": "10m", "submit_type": "REBASE_IF_NECESSARY", "state": "ACTIVE" } project = client.projects.get('myproject') result = project.set_config(input_)
- Parameters:
input – the ConfigInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#config-info
- Returns:
- set_description(input_)[source]
Sets the description of a project.
input_ = { "description": "Plugin for Gerrit that handles the replication.", "commit_message": "Update the project description" } project = client.projects.get('myproject') result = project.set_description(input_)
- Parameters:
input – the ProjectDescriptionInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-description-input
- Returns:
- set_head(input_)[source]
Sets HEAD for a project.
input_ = { "ref": "refs/heads/stable" } project = client.projects.get('myproject') result = project.set_HEAD(input_)
- Parameters:
input – The HeadInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#head-input
- Returns:
- set_parent(input_)[source]
Sets the parent project for a project.
input_ = { "parent": "Public-Plugins", "commit_message": "Update the project parent" } project = client.projects.get('myproject') result = project.set_parent(input_)
- Parameters:
input – The ProjectParentInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-parent-input
- Returns:
- property tags
List the tags of a project.
- Returns:
- property webhooks
gerrit webhooks operations, requires webhooks plugin
- Returns:
gerrit.projects.projects module
- class gerrit.projects.projects.GerritProjects(gerrit)[source]
Bases:
object
- create(project_name: str, input_: Dict[str, Any])[source]
Creates a new project.
input_ = { "description": "This is a demo project.", "submit_type": "INHERIT", "owners": [ "MyProject-Owners" ] } project = client.projects.create('MyProject', input_)
- Parameters:
project_name – the name of the project
input – the ProjectInput entity, https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-input
- Returns:
- delete(project_name: str)[source]
Delete the project, requires delete-project plugin
- Parameters:
project_name – project name
- Returns:
- list(is_all: bool = False, limit: int = 25, skip: int = 0, pattern_dispatcher: Dict | None = None, project_type: str | None = None, description: bool = False, branch: str | None = None, state: str | None = None) List [source]
Get list of all available projects accessible by the caller.
- Parameters:
is_all – boolean value, if True then all projects (including hidden ones) will be added to the results. May not be used together with the state option.
limit – Int value that allows to limit the number of projects to be included in the output results
skip – Int value that allows to skip the given number of projects from the beginning of the list
pattern_dispatcher – Dict of pattern type with respective pattern value: {(‘prefix’|’match’|’regex’) : value}
project_type – string value for type of projects to be fetched (‘code’|’permissions’|’all’)
description – boolean value, if True then description will be added to the output result
branch – Limit the results to the projects having the specified branch and include the sha1 of the branch in the results.
state – Get all projects with the given state. May not be used together with the all
option.
- Returns:
- search(query: str, limit: int = 25, skip: int = 0) List [source]
Queries projects visible to the caller. The query string must be provided by the query parameter. The start and limit parameters can be used to skip/limit results.
- query parameter
name:’NAME’ Matches projects that have exactly the name ‘NAME’.
parent:’PARENT’ Matches projects that have ‘PARENT’ as parent project.
inname:’NAME’ Matches projects that a name part that starts with
‘NAME’ (case insensitive).
description:’DESCRIPTION’ Matches projects whose description contains ‘DESCRIPTION’,
using a full-text search. * state:’STATE’ Matches project’s state. Can be either ‘active’ or ‘read-only’.
- Parameters:
query –
limit – Int value that allows to limit the number of accounts to be included in the output results
skip – Int value that allows to skip the given number of accounts from the beginning of the list
- Returns:
gerrit.projects.webhooks module
- class gerrit.projects.webhooks.GerritProjectWebHook(name: str, project: str, gerrit)[source]
Bases:
GerritBase
- class gerrit.projects.webhooks.GerritProjectWebHooks(project, gerrit)[source]
Bases:
object
- create(name, input_)[source]
Create or update a webhook for a project.
input_ = { "url": "https://foo.org/gerrit-events", "maxTries": "3", "sslVerify": "true" } project = client.projects.get('myproject') new_webhook = project.webhooks.create('test', input_)
- Parameters:
name – the webhook name
input – the RemoteInfo entity
- Returns: