BitBucket module

Complete API reference

The workflow sections below cover common operations. The source-backed references list every public method and current signature for the compatible, Cloud OO, and Server/Data Center clients.

class atlassian.bitbucket.Bitbucket(url, *args, **kwargs)
add_branch_restriction(workspace, repository_slug, kind, branch_match_kind='glob', branch_pattern='*', branch_type=None, users=None, groups=None, value=None)

Add a new branch restriction.

Parameters:
  • workspace

  • repository_slug

  • value

  • kind – One of require_tasks_to_be_completed, force, restrict_merges, enforce_merge_checks, require_approvals_to_merge, delete, require_all_dependencies_merged, push, require_passing_builds_to_merge, reset_pullrequest_approvals_on_change, require_default_reviewer_approvals_to_merge

  • branch_match_kind – branching_model or glob, if branching_model use param branch_type otherwise branch_pattern.

  • branch_pattern – A glob specifying the branch this restriction should apply to (supports * as wildcard).

  • branch_type – The branch type specifies the branches this restriction should apply to. One of: feature, bugfix, release, hotfix, development, production.

  • users – List of user objects that are excluded from the restriction. Minimal: {“username”: “<username>”}

  • groups – List of group objects that are excluded from the restriction. Minimal: {“owner”: {“username”: “<teamname>”}, “slug”: “<groupslug>”}

add_code_insights_annotations_to_report(project_key, repository_slug, commit_id, report_key, annotations)

Adds annotations to an existing insight report. For further information visit: https://docs.atlassian.com/bitbucket-server/rest/6.6.1/bitbucket-code-insights-rest.html :project_key: str :repository_slug: str :commit_id: str :report_key: str :annotations: list

add_default_reviewer(workspace, repository_slug, user)

Add user as default reviewer to the repository. Can safely be called multiple times with the same user, only adds once.

Parameters:
  • workspace

  • repository_slug

  • user – The username or account UUID to add as default_reviewer.

add_pull_request_blocker_comment(project_key: str, repository_slug: str, pull_request_id: int, text: dict, severity: str) dict

Add a comment to a pull request that blocks the merge :param project_key: The project key :param repository_slug: The repository key :param pull_request_id: The pull request id :param text: The text of the comment :param severity: The severity of the comment :return:

add_pull_request_comment(project_key, repository_slug, pull_request_id, text, parent_id=None)

Add comment into pull request :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :param text comment text :param parent_id parent comment id

Returns:

add_task(anchor, text)

Add task to the comment :param anchor: ID of the comment, :param text: task text :return:

all_branches_permissions(project_key, permission_id, repository_slug=None)

Get branches permissions from a given repo :param project_key: :param permission_id :param repository_slug: :return:

all_project_administrators()

Get the list of project administrators

Returns:

A generator object containing a map with the project_key, project_name and project_administrators

all_project_repo_hook_settings(project_key, start=0, limit=None, filter_type=None)

Get all repository hooks for a given project :param project_key: The project key :param start: :param limit: OPTIONAL: The limit of the number of changes to return, this may be restricted by

fixed system limits. Default by built-in method: None

Parameters:

filter_type – OPTIONAL: PRE_RECEIVE|POST_RECEIVE if present, controls how repository hooks should be filtered.

Returns:

all_repo_hook_settings(project_key, repository_slug, start=0, limit=None, filter_type=None)

Get all repository hooks for a given repo :param project_key: The project key :param repository_slug: The repository key :param start: :param limit: OPTIONAL: The limit of the number of changes to return, this may be restricted by

fixed system limits. Default by built-in method: None

Parameters:

filter_type – OPTIONAL: PRE_RECEIVE|POST_RECEIVE if present, controls how repository hooks should be filtered.

Returns:

assign_pull_request_participant_role(project_key: str, repository_slug: str, pull_request_id: int, role: str, user: str) dict | None

Assign a role to a user for a pull request :param project_key: The project key :param repository_slug: The repository key :param pull_request_id: The pull request id :param role: The role to assign, currently it only accepts REVIEWER :param user: The user to assign the role to :return:

change_reviewed_status(project_key, repository_slug, pull_request_id, status, user_slug)

Change the current user’s status for a pull request. Implicitly adds the user as a participant if they are not already. If the current user is the author, this method will fail. :param project_key :param repository_slug: :param pull_request_id: :param status: :param user_slug: :return:

check_inbox_pull_requests(start=0, limit=None, role=None)

Get pull request in your inbox :param start: :param limit: :param role: :return:

check_inbox_pull_requests_count()
check_reindexing_status()

Check reindexing status :return:

configure_project_hook_script(project_key: str, script_id: int, trigger_ids: List[str] | None = None)

Configure a registered hook script for every repository in a project.

Requires project administrator permission. trigger_ids controls the hook triggers to which the script is bound.

configure_repo_hook_script(project_key: str, repository_slug: str, script_id: int, trigger_ids: List[str] | None = None)

Configure a registered hook script for a repository.

Requires repository administrator permission. trigger_ids controls the hook triggers to which the script is bound.

create_branch(project_key, repository_slug, name, start_point, message='')

Creates a branch using the information provided in the request.

The authenticated user must have REPO_WRITE permission for the context repository to call this resource.

Parameters:
  • project_key (str) – The project matching the projectKey supplied in the resource path as shown in URL.

  • repository_slug – Name of repository where branch is created (i.e. “my_repo”).

  • name (str) – Name of branch to create (i.e. “my_branch”).

  • start_point (str) – Name of branch to branch from.

  • message (str) – Branch message.

Returns:

200 - application/json (repository) 401 - application/json (errors) 404 - application/json (errors)

Return type:

requests.Response

create_code_insights_report(project_key, repository_slug, commit_id, report_key, report_title, **report_params)

Create a new insight report, or replace the existing one if a report already exists for the given repository_slug, commit, and report key. A request to replace an existing report will be rejected if the authenticated user was not the creator of the specified report. For further information visit: https://docs.atlassian.com/bitbucket-server/rest/6.6.1/bitbucket-code-insights-rest.html :projectKey: str :repositorySlug: str :commitId: str :report_key: str :report_title: str :report_params:

create_hook_script(content: bytes, name: str, hook_type: str, description: str | None = None)

Register a global hook script on Bitbucket Data Center.

hook_type must be PRE or POST. The caller must be a system administrator, and Bitbucket Data Center 8.18+ requires hook scripts to be explicitly enabled with feature.hook.scripts=true.

The API expects a multipart form. content is the executable script bytes; no temporary file is created by the client.

create_issue(workspace, repository_slug, title, description='', kind='bug', priority='major')

Create a new issue in the issue tracker of the given repository. :param workspace: :param repository_slug: :param title: :param description: :param kind: one of: bug, enhancement, proposal, task :param priority: one of: trivial, minor, major, critical, blocker

create_project(key, name, description='')

Create project :param key: The project key :param name: The project name :param description: The project description

Returns:

The value of the post request.

create_project_condition(project_key, condition)

Request type: POST Create a new condition for this project. For further information visit:

ProjectKey:

str- project key involved

Data:

condition: dictionary object

Example condition:
‘{“sourceMatcher”:

{“id”:”any”, “type”:{“id”:”ANY_REF”}}, “targetMatcher”:{“id”:”refs/heads/master”,”type”:{“id”:”BRANCH”}}, “reviewers”:[{“id”: 12}],”requiredApprovals”:”0”

}’

Returns:

create_pull_request(project_key, repository_slug, data)
Parameters:
  • project_key

  • repository_slug

  • data – json body

Returns:

create_repo(project_key, repository_slug, forkable=False, is_private=True)

Create a new repository.

Requires an existing project in which this repository will be created. The only parameters which will be used are name and scmId.

The authenticated user must have PROJECT_ADMIN permission for the context project to call this resource.

Parameters:
  • project_key (str) – The project matching the projectKey supplied in the resource path as shown in URL.

  • repository_slug – Name of repository to create (i.e. “My repo”).

  • forkable (bool) – Set the repository to be forkable or not.

  • is_private (bool) – Set the repository to be private or not.

Returns:

201 - application/json (repository) 400 - application/json (errors) 401 - application/json (errors) 409 - application/json (errors)

Return type:

requests.Response

create_repo_condition(project_key, repo_key, condition)

Request type: POST Create a new condition for this repository slug inside project specified. For further information visit:

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

Data:

condition: dictionary object

Example condition:
‘{“sourceMatcher”:

{“id”:”any”, “type”:{“id”:”ANY_REF”}}, “targetMatcher”:{“id”:”refs/heads/master”,”type”:{“id”:”BRANCH”}}, “reviewers”:[{“id”: 12}],”requiredApprovals”:”0”

}’

Returns:

create_webhook(project_key, repository_slug, name, events, webhook_url, active, secret=None)

Creates a webhook using the information provided in the request.

The authenticated user must have REPO_ADMIN permission for the context repository to call this resource.

Parameters:
  • project_key – The project matching the projectKey supplied in the resource path as shown in URL.

  • repository_slug

  • name – Name of webhook to create.

  • events – List of event. (i.e. [“repo:refs_changed”, “pr:merged”, “pr:opened”])

  • webhook_url

  • active

  • secret – The string is used to verify data integrity between Bitbucket and your endpoint.

Returns:

decline_pull_request(project_key, repository_slug, pr_id, pr_version)

Decline a pull request. The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Parameters:
  • project_key – PROJECT

  • repository_slug – my_shiny_repo

  • pr_id – 2341

  • pr_version – 12

Returns:

delete_announcement_banner()

Gets the announcement banner, if one exists and is available to the user :return:

delete_branch(project_key, repository_slug, name, end_point=None)

Delete branch from related repo :param self: :param project_key: :param repository_slug: :param name: :param end_point: :return:

delete_branch_permission(project_key, permission_id, repository_slug=None)

Deletes a restriction as specified by a restriction id. The authenticated user must have REPO_ADMIN permission or higher to call this resource.

Parameters:
  • project_key

  • repository_slug

  • permission_id

Returns:

delete_branch_restriction(workspace, repository_slug, id)

Delete an existing branch restriction identified by id.

delete_code_insights_report(project_key, repository_slug, commit_id, report_key)

Delete a report for the given commit. Also deletes any annotations associated with this report. :projectKey: str :repositorySlug: str :commit_id: str :report_key: str

delete_default_reviewer(workspace, repository_slug, user)

Remove user as default reviewer from the repository.

Parameters:
  • repository_slug

  • workspace

  • user – The username or account UUID to delete as default reviewer.

delete_hook_script(script_id: int)

Delete the registered global hook script with script_id.

delete_issue(workspace, repository_slug, id)

Delete the issue specified by id.

delete_project_condition(project_key, id_condition)

Delete a specific condition for this repository slug inside project. For further information visit:

Request type: DELETE :projectKey: str- project key involved :idCondition: int - condition id involved :return:

delete_project_hook_script(project_key: str, script_id: int)

Remove a hook-script configuration from a project.

delete_pull_reques_comment(project_key, repository_slug, pull_request_id, comment_id, comment_version)

Deprecated name since 2.4.2. Let’s use the get_pull_request()

delete_pull_request(project_key, repository_slug, pull_request_id, pull_request_version)

Delete a pull request.

Parameters:
  • project_key – the project key

  • repository_slug – the repository slug

  • pull_request_id – the ID of the pull request within the repository

  • pull_request_version – the version of the pull request

Returns:

delete_pull_request_comment(project_key, repository_slug, pull_request_id, comment_id, comment_version)

Delete a comment. Only the repository admin or user who created a comment may update it.

Note: the supplied JSON object must contain a version that must match the server’s version of the comment or delete will fail.

delete_repo(project_key, repository_slug)

Delete a specific repository from a project. This operates based on slug not name which may be confusing to some users. :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :return: Dictionary of request response

delete_repo_condition(project_key, repo_key, id_condition)

Delete a specific condition for this repository slug inside project. For further information visit:

Request type: DELETE :projectKey: str- project key involved :repoKey: str - repo key involved :idCondition: int - condition id involved :return:

delete_repo_hook_script(project_key: str, repository_slug: str, script_id: int)

Remove a hook-script configuration from a repository.

delete_tag(project_key, repository_slug, tag_name)

Creates a tag using the information provided in the {@link RestCreateTagRequest request} The authenticated user must have REPO_WRITE permission for the context repository to call this resource. :param project_key: :param repository_slug: :param tag_name: :return:

delete_task(task_id)

Delete task by ID :param task_id: :return:

delete_webhook(project_key, repository_slug, webhook_id)

Delete a webhook. The authenticated user must have REPO_ADMIN permission for the context repository to call this resource. :param project_key: :param repository_slug: :param webhook_id: the ID of the webhook within the repository :return:

disable_branching_model(project_key, repository_slug)

Disable branching model :param project_key: :param repository_slug: :return:

disable_project_repo_hook_settings(project_key, hook_key)

Disable a repository hook for a given project :param project_key: The project key :param hook_key: The repository hook key :return:

disable_repo_forking(project_key, repository_slug)

Disable forking for a Server/Data Center repository.

disable_repo_hook_settings(project_key, repository_slug, hook_key)

Disable a repository hook for a given repo :param project_key: The project key :param repository_slug: The repository key :param hook_key: The repository hook key :return:

download_repo_archive(project_key, repository_slug, dest_fd, at=None, filename=None, format=None, path=None, prefix=None, chunk_size=128)

Downloads a repository archive. Note that the data is written to the specified file-like object, rather than simply being returned. For further information visit:

Parameters:
  • project_key

  • repository_slug

  • dest_fd – a file-like object to which the archive will be written

  • at – string: Optional, the commit to download an archive of; if not supplied, an archive of the default branch is downloaded

  • filename – string: Optional, a filename to include the “Content-Disposition” header

  • format – string: Optional, the format to stream the archive in; must be one of: zip, tar, tar.gz or tgz. If not specified, then the archive will be in zip format.

  • path – string: Optional, path to include in the streamed archive

  • prefix – string: Optional, a prefix to apply to all entries in the streamed archive; if the supplied prefix does not end with a trailing /, one will be added automatically

  • chunk_size – int: Optional, download chunk size. Defeault is 128

enable_branching_model(project_key, repository_slug)

Enable branching model by setting it with default configuration :param project_key: :param repository_slug: :return:

enable_project_repo_hook_settings(project_key, hook_key)

Enable a repository hook for a given project :param project_key: The project key :param hook_key: The repository hook key :return:

enable_repo_forking(project_key, repository_slug)

Enable forking for a Server/Data Center repository.

enable_repo_hook_settings(project_key, repository_slug, hook_key)

Enable a repository hook for a given repo :param project_key: The project key :param repository_slug: The repository key :param hook_key: The repository hook key :return:

fork_repository(project_key, repository_slug, new_repository_slug)

Forks a repository within the same project. :param project_key: :param repository_slug: :param new_repository_slug: :return:

fork_repository_new_project(project_key, repository_slug, new_project_key, new_repository_slug)

Forks a repository to a separate project. :param project_key: Origin Project Key :param repository_slug: Origin repository slug :param new_project_key: Project Key of target project :param new_repository_slug: Target Repository slug :return:

get_announcement_banner()

Gets the announcement banner, if one exists and is available to the user :return:

get_associated_build_statuses(commit)

To get the build statuses associated with a commit. :commit: str- commit id :return:

get_branch_permission(project_key, permission_id, repository_slug=None)

Returns a restriction as specified by a restriction id. The authenticated user must have REPO_ADMIN permission or higher to call this resource.

Parameters:
  • project_key

  • repository_slug

  • permission_id

Returns:

get_branch_restrictions(workspace, repository_slug, kind=None, pattern=None, number=10)

Get all branch permissions.

get_branches(project_key, repository_slug, base=None, filter=None, start=0, limit=None, details=True, order_by='MODIFICATION', boost_matches=False)

Retrieve the branches matching the supplied filterText param. The authenticated user must have REPO_READ permission for the specified repository to call this resource. :param start: :param project_key: :param repository_slug: :param base: base branch/tag to compare each branch to (for the metadata providers that uses that information) :param filter: :param limit: OPTIONAL: The limit of the number of branches to return, this may be restricted by

fixed system limits. Default by built-in method: None

Parameters:
  • details – whether to retrieve plugin-provided metadata about each branch

  • order_by – OPTIONAL: ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)

  • boost_matches – Controls whether exact and prefix matches will be boosted to the top

Returns:

get_branches_permissions(project_key, permission_id, repository_slug=None, start=0, limit=25)

Get branches permissions from a given repo :param project_key: :param permission_id: :param repository_slug: :param start: :param limit: :return:

get_branching_model(project_key, repository_slug)

Get branching model :param project_key: :param repository_slug: :return:

get_categories(project_key, repository_slug=None)

Get a list of categories assigned to a project or repository. :param project_key: The project key as shown in URL. :param repository_slug: The repository as shown in URL (optional). :return: If ‘repository_slug’, returns the list with categories of the repository, otherwise, returns the list with the categories of the project ‘project_key’

get_changelog(project_key, repository_slug, ref_from, ref_to, start=0, limit=None)

Get change log between 2 refs :param start: :param project_key: :param repository_slug: :param ref_from: :param ref_to: :param limit: OPTIONAL: The limit of the number of changes to return, this may be restricted by

fixed system limits. Default by built-in method: None

Returns:

get_cluster_info()

Get system information for the Bitbucket Data Center cluster.

This administrative endpoint is available on Bitbucket Server/Data Center only and requires the appropriate administrator permission.

get_code_insights_report(project_key, repository_slug, commit_id, report_key)

Retrieve the specified code-insights report. :projectKey: str :repositorySlug: str :commit_id: str :report_key: str

get_commit_changes(project_key, repository_slug, hash_newest=None, merges='include', commit_id=None)

Get commit list from repo :param project_key: :param repository_slug: :param hash_newest: :param merges: OPTIONAL: include|exclude|only if present, controls how merge commits should be filtered. :param commit_id :return:

get_commit_info(project_key, repository_slug, commit, path=None)

Retrieve a single commit identified by its ID>. In general, that ID is a SHA1. From 2.11, ref names like “refs/heads/master” are no longer accepted by this resource. The authenticated user must have REPO_READ permission for the specified repository to call this resource. :param project_key: :param repository_slug: :param commit: the commit ID to retrieve :param path :OPTIONAL an optional path to filter the commit by.

If supplied the details returned may not be for the specified commit. Instead, starting from the specified commit, they will be the details for the first commit affecting the specified path.

Returns:

get_commits(project_key, repository_slug, hash_oldest=None, hash_newest=None, follow_renames=False, ignore_missing=False, merges='include', with_counts=False, avatar_size=None, avatar_scheme=None, limit=None, until=None, since=None, path=None)

Get commit list from repo :param project_key: :param repository_slug: :param hash_oldest: :param hash_newest: :param merges: OPTIONAL: include|exclude|only if present, controls how merge commits should be filtered. :param follow_renames: OPTIONAL: if true, the commit history of the specified file will be followed past renames :param ignore_missing: OPTIONAL: true to ignore missing commits, false otherwise :param with_counts: OPTIONAL: optionally include the total number of commits and total number of unique authors :param avatar_size: OPTIONAL: if present the service adds avatar URLs for commit authors. :param avatar_scheme: OPTIONAL: the desired scheme for the avatar URL :param limit: OPTIONAL: The limit of the number of commits to return, this may be restricted by

fixed system limits. Default by built-in method: None

Parameters:
  • until – OPTIONAL: The commit ID or ref (inclusively) to retrieve commits before

  • since – OPTIONAL: The commit ID or ref (exclusively) to retrieve commits after

  • path – OPTIONAL: An optional path to filter commits by

Returns:

get_content_of_file(project_key, repository_slug, filename, at=None, markup=None)

Retrieve the raw content for a file path at a specified revision. The authenticated user must have REPO_READ permission for the specified repository to call this resource. :param project_key: :param repository_slug: :param filename: :param at: OPTIONAL ref string :param markup: if present or “true”, triggers the raw content to be markup-rendered and returned as HTML;

otherwise, if not specified, or any value other than “true” the content is streamed without markup.

Returns:

get_current_license()

Retrieves details about the current license, as well as the current status of the system with regard to the installed license. The status includes the current number of users applied toward the license limit, as well as any status messages about the license (warnings about expiry or user counts exceeding license limits). The authenticated user must have ADMIN permission. Unauthenticated users, and non-administrators, are not permitted to access license details. :return:

get_dashboard_pull_requests(start=0, limit=None, closed_since=None, role=None, participant_status=None, state=None, order=None)

Get all pull requests where the current authenticated user is involved as either a reviewer, author or a participant :param start: :param limit: :param closed_since: OPTIONAL, defaults to returning pull

requests regardless of closed since date. Permits returning only pull requests with a closed timestamp set more recently that (now - closedSince). Units are in seconds. So for example if closed since 86400 is set only pull requests closed in the previous 24 hours will be returned.

Parameters:
  • role – OPTIONAL, defaults to returning pull requests for any role. If a role is supplied only pull requests where the authenticated user is a participant in the given role will be returned. Either REVIEWER, AUTHOR or PARTICIPANT.

  • participant_status – OPTIONAL, defaults to returning pull requests with any participant status. A comma separated list of participant status. That is, one or more of UNAPPROVED, NEEDS_WORK, or APPROVED.

  • state – OPTIONAL, defaults to returning pull requests in any state. If a state is supplied only pull requests in the specified state will be returned. Either OPEN, DECLINED or MERGED. Omit this parameter to return pull request in any state.

  • order – OPTIONAL, defaults to NEWEST, the order to return pull requests in, either OLDEST (as in: “oldest first”), NEWEST, PARTICIPANT_STATUS, or CLOSED_DATE. Where CLOSED_DATE is specified and the result set includes pull requests that are not in the closed state, these pull requests will appear first in the result set, followed by most recently closed pull requests.

Returns:

get_default_branch(project_key, repository_slug)

Get the default branch of the repository. The authenticated user must have REPO_READ permission for the specified repository to call this resource. :param project_key: The project key :param repository_slug: The repository key :return:

get_default_reviewers(workspace, repository_slug, number=10)

Get all default reviewers for the repository.

get_diff(project_key, repository_slug, path, hash_oldest, hash_newest)

Gets a diff of the changes available in the {@code from} commit but not in the {@code to} commit. If either the {@code from} or {@code to} commit are not specified, they will be replaced by the default branch of their containing repository. :param project_key: :param repository_slug: :param path: :param hash_oldest: the source commit (can be a partial/full commit ID or qualified/unqualified ref name) :param hash_newest: the target commit (can be a partial/full commit ID or qualified/unqualified ref name) :return:

get_file_list(project_key, repository_slug, sub_folder=None, query=None, start=0, limit=None)

Retrieve a page of files from particular directory of a repository. The search is done recursively, so all files from any subdirectory of the specified directory will be returned. The authenticated user must have REPO_READ permission for the specified repository to call this resource. :param start: :param project_key: :param repository_slug: :param sub_folder: a sub folder in the target repository to list the files from. :param query: the commit ID or ref (e.g. a branch or tag) to list the files at.

If not specified the default branch will be used instead.

Parameters:

limit – OPTIONAL

Returns:

get_groups(group_filter=None, limit=25, start=0)

Get list of bitbucket groups. Use ‘group_filter’ for get specific group or get all group if necessary.

Parameters:
  • group_filter – str - groupname

  • limit – int - paginated limit to retrieve

  • start – int - paginated point to start retrieving

Returns:

The collection as JSON with all relevant information about the group

get_hook_script(script_id: int)

Return the registered global hook script with script_id.

The result only contains the script metadata; use get_hook_script_content() to fetch the script body.

get_hook_script_content(script_id: int)

Return the raw body of the registered global hook script.

not_json_response is used because the endpoint returns the executable script as plain text rather than a JSON payload.

get_issue(workspace, repository_slug, id)

Get the issue specified by id.

get_issues(workspace, repository_slug, sort_by=None, query=None)

Get information about the issues tracked in the given repository. By default, the issues are sorted by ID in descending order. :param workspace: :param repository_slug: :param sort_by: optional key to sort available issues for :param query: optional query to filter available issues for. See

Returns:

List of issues (direct, i.e. without the ‘values’ key)

get_lfs_repo_status(project_key, repo)
get_mail_configuration()

Retrieves the current mail configuration. The authenticated user must have the SYS_ADMIN permission to call this resource. :return:

get_mail_sender_address()

Retrieves the server email address :return:

get_pipeline(workspace, repository_slug, uuid)

Get information about the pipeline specified by uuid. :param workspace: :param repository_slug: :param uuid: Pipeline identifier (with surrounding {}; NOT the build number)

get_pipeline_step(workspace, repository_slug, pipeline_uuid, step_uuid)

Get information about a step of a pipeline, specified by respective UUIDs. :param workspace: :param repository_slug: :param pipeline_uuid: Pipeline identifier (with surrounding {}; NOT the build number) :param step_uuid: Step identifier (with surrounding {})

get_pipeline_step_log(workspace, repository_slug, pipeline_uuid, step_uuid)

Get log of a step of a pipeline, specified by respective UUIDs. :param workspace: :param repository_slug: :param pipeline_uuid: Pipeline identifier (with surrounding {}; NOT the build number) :param step_uuid: Step identifier (with surrounding {}) :return: byte string log

get_pipeline_steps(workspace, repository_slug, uuid)

Get information about the steps of the pipeline specified by uuid. :param workspace: :param repository_slug: :param uuid: Pipeline identifier (with surrounding {}; NOT the build number)

get_pipelines(workspace, repository_slug, number=10, sort_by='-created_on')

Get information about latest pipelines runs.

Parameters:
  • workspace

  • repository_slug

  • sort_by

  • number – number of pipelines to fetch

  • :sort_by – optional key to sort available pipelines for

Returns:

List of pipeline data

get_project_audit_log(project_key, start=0, limit=None)

Get the audit log of the project :param start: :param limit: :param project_key: The project key :return: List of events of the audit log

get_project_condition(project_key, id_condition)

Request type: GET Return a specific condition with reviewers list that has been configured for this project. For further information visit:

ProjectKey:

str - project key involved

IdCondition:

int - condition id involved

Returns:

get_project_conditions(project_key)

Request type: GET Return a page of defaults conditions with reviewers list that have been configured for this project. For further information visit:

ProjectKey:

str

Returns:

get_project_hook_scripts(project_key: str, start: int = 0, limit: int | None = None)

Yield hook-script configurations for a project.

get_project_repo_hook_settings(project_key, hook_key)

Get a repository hook from a given project :param project_key: The project key :param hook_key: The repository hook key :return:

get_project_tags(project_key, repository_slug, tag_name=None)

Retrieve a tag in the specified repository. The authenticated user must have REPO_READ permission for the context repository to call this resource. Search uri is api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*} :param project_key: :param repository_slug: :param tag_name: OPTIONAL: :return:

get_pull_request(project_key, repository_slug, pull_request_id)

Retrieve a pull request. The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource. :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :return:

get_pull_request_comment(project_key, repository_slug, pull_request_id, comment_id)

Retrieves a pull request comment. The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource. :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :param comment_id: the ID of the comment to retrieve :return:

get_pull_request_settings(project_key, repository_slug)

Get pull request settings. :param project_key: :param repository_slug: :return:

get_pull_requests(project_key, repository_slug, state='OPEN', order='newest', limit=100, start=0, at=None, filter_text=None)

Get pull requests :param project_key: :param repository_slug: :param state: :param order: OPTIONAL: defaults to NEWEST the order to return pull requests in, either OLDEST

(as in: “oldest first”) or NEWEST.

Parameters:
  • limit

  • start

  • at

  • filter_text – (optional) If specified, only pull requests where the title or description contains the supplied string will be returned.

Returns:

get_pull_requests_activities(project_key, repository_slug, pull_request_id, start=0, limit=None)

Get pull requests activities :param limit: :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :param start: :return:

get_pull_requests_changes(project_key, repository_slug, pull_request_id, start=0, limit=None)

Get pull requests changes :param start: :param limit: :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :return:

get_pull_requests_commits(project_key, repository_slug, pull_request_id, start=0, limit=None)

Get pull requests commits :param start: :param limit: :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :start :limit :return:

get_pull_requests_contain_commit(project_key, repository_slug, commit)
get_pull_requests_participants(project_key, repository_slug, pull_request_id, start=0, limit=None)

Get all participants of a pull request :param start: :param limit: :param project_key: :param repository_slug: :param pull_request_id: :return:

get_pullrequest(*args, **kwargs)

Deprecated name since 1.15.1. Let’s use the get_pull_request()

get_repo(project_key, repository_slug)

Get a specific repository from a project. This operates based on slug not name which may be confusing to some users. :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :return: Dictionary of request response

get_repo_audit_log(project_key, repository_slug, start=0, limit=None)

Get the audit log of the repository :param start: :param limit: :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :return: List of events of the audit log

get_repo_condition(project_key, repo_key, id_condition)

Request type: GET Return a specific condition with reviewers list

that have been configured for this repository slug inside project specified.

For further information visit:

https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-default-reviewers-rest.html#idm52264927632

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

IdCondition:

int - condition id involved

Returns:

get_repo_conditions(project_key, repo_key)

Request type: GET Return a page of defaults conditions with reviewers list (type REPOSITORY or PROJECT) that have been configured for this repository slug inside project specified. For further information visit:

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

Returns:

get_repo_forkable(project_key, repository_slug)

Return whether a Bitbucket Server/Data Center repository is forkable.

Parameters:
  • project_key – Project key, or a ~user personal repository owner.

  • repository_slug – URL-compatible repository identifier.

Returns:

The repository’s forkable flag, or None when omitted by an older Bitbucket version.

get_repo_hook_scripts(project_key: str, repository_slug: str, start: int = 0, limit: int | None = None)

Yield hook-script configurations for a repository.

get_repo_hook_settings(project_key, repository_slug, hook_key)

Get a repository hook from a given repo :param project_key: The project key :param repository_slug: The repository key :param hook_key: The repository hook key :return:

get_repo_labels(project_key, repository_slug)

Get labels for a specific repository from a project. This operates based on slug not name which may be confusing to some users. (BitBucket Server only) :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :return: Dictionary of request response

get_repo_project_conditions(project_key, repo_key)

Request type: GET Return a page of repository conditions (only type PROJECT) with reviewers list associated that have been configured for this repository slug inside project specified. For further information visit:

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

Returns:

get_repo_repo_conditions(project_key, repo_key)

Request type: GET Return a page of repository conditions (only type REPOSITORY) with reviewers list associated that have been configured for this repository slug inside project specified. For further information visit:

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

Returns:

get_repositories(workspace, role=None, query=None, sort=None)

Get all repositories in a workspace.

Parameters:
  • workspace

  • role – Filters the result based on the authenticated user’s role on each repository. One of: member, contributor, admin, owner

  • query – Query string to narrow down the response.

  • sort – Field by which the results should be sorted.

get_required_reviewers_for_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, dest_branch)

Get required reviewers for PR creation :param source_project: the project that the PR source is from :param source_repo: the repository that the PR source is from :param source_branch: the branch name of the PR :param dest_project: the project that the PR destination is from :param dest_repo: the repository that the PR destination is from :param dest_branch: where the PR is being merged into :return:

get_ssh_settings()

Retrieve ssh settings for user :return:

get_tags(project_key, repository_slug, filter='', limit=1000, order_by=None, start=0)

Retrieve the tags matching the supplied filterText param. The authenticated user must have REPO_READ permission for the context repository to call this resource. :param project_key: :param repository_slug: :param filter: :param start: :param limit: OPTIONAL: The limit of the number of tags to return, this may be restricted by

fixed system limits. Default by built-in method: 1000

Parameters:

order_by – OPTIONAL: ordering of refs either ALPHABETICAL (by name) or MODIFICATION (last updated)

Returns:

get_task(task_id)

Get task information by ID :param task_id: :return:

get_tasks(project_key, repository_slug, pull_request_id)

Get all tasks for the pull request :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :return:

get_users(user_filter=None, limit=25, start=0)

Get list of bitbucket users. Use ‘user_filter’ for get specific users or get all users if necessary. :param user_filter: str - username, displayname or email :param limit: int - paginated limit to retrieve :param start: int - paginated point to start retreiving :return: The collection as JSON with all relevant information about the licensed user

get_users_info(user_filter=None, start=0, limit=25)

The authenticated user must have the LICENSED_USER permission to call this resource. :param user_filter: if specified only users with usernames, display name or email addresses

containing the supplied string will be returned

Parameters:
  • limit

  • start

Returns:

get_webhook(project_key, repository_slug, webhook_id)

Retrieve a webhook. The authenticated user must have REPO_ADMIN permission for the context repository to call this resource. :param project_key: :param repository_slug: :param webhook_id: the ID of the webhook within the repository :return:

get_webhooks(project_key, repository_slug, event=None, statistics=False)

Get webhooks :param project_key: :param repository_slug: :param event: OPTIONAL: defaults to None :param statistics: OPTIONAL: defaults to False :return:

group_members(group, start=0, limit=None)

Get group of members :param group: The group name to query :param start: :param limit: :return: A list of group members

health_check()

Get health status https://confluence.atlassian.com/jirakb/how-to-retrieve-health-check-results-using-rest-api-867195158.html :return:

is_default_reviewer(workspace, repository_slug, user)

Check if the user is a default reviewer of the repository.

Parameters:
  • workspace

  • repository_slug

  • user – The username or account UUID to check.

Returns:

True if present, False if not.

is_pull_request_can_be_merged(project_key, repository_slug, pr_id)

Test whether a pull request can be merged. A pull request may not be merged if: - there are conflicts that need to be manually resolved before merging; and/or - one or more merge checks have vetoed the merge. The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Parameters:
  • project_key – PROJECT

  • repository_slug – my_shiny_repo

  • pr_id – 2341

Returns:

markup_preview(data)

Preview generated HTML for the given markdown content. Only authenticated users may call this resource. :param data: :return:

merge_pull_request(project_key, repository_slug, pr_id, merge_message, close_source_branch=False, merge_strategy=MergeStrategy.MERGE_COMMIT, pr_version=None)

Merge pull request The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Parameters:
  • project_key – PROJECT

  • repository_slug – my_shiny_repo

  • pr_id – 2341

  • merge_message – “feat: add new file handler”

  • pr_version

  • close_source_branch – True

  • merge_strategy – “squash”

Returns:

open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers=None, include_required_reviewers=False)

Create a new pull request between two branches. The branches may be in the same repository_slug, or different ones. When using different repositories, they must still be in the same {@link Repository#getHierarchyId() hierarchy}. The authenticated user must have REPO_READ permission for the “from” and “to”repositories to call this resource. :param source_project: the project that the PR source is from :param source_repo: the repository that the PR source is from :param dest_project: the project that the PR destination is from :param dest_repo: the repository that the PR destination is from :param source_branch: the branch name of the PR :param destination_branch: where the PR is being merged into :param title: the title of the PR :param description: the description of what the PR does :param reviewers: the list of reviewers or a single reviewer of the PR :param include_required_reviewers: OPTIONAL defaults to False, include required reviewers for the PR :return:

project(key)

Provide project info :param key: The project key :return:

project_avatar(key, content_type='image/png')

Get project avatar :param key: The project key :param content_type: The content type to get

Returns:

Value of get request

project_default_permissions(project_key, permission)

Check if the specified permission is the default permission for a given project :param project_key: The project key :param permission: the project permissions available are ‘PROJECT_ADMIN’, ‘PROJECT_WRITE’ and ‘PROJECT_READ’ :return:

project_exists(project_key)

Check if project with the provided project key exists and available. :param project_key: Key of the project where to check for repository. :return: False is requested repository doesn’t exist in the project or not accessible to the requestor

project_grant_default_permissions(project_key, permission)

Grant the specified project permission to all users for a given project :param project_key: The project key :param permission: the project permissions available are ‘PROJECT_ADMIN’, ‘PROJECT_WRITE’ and ‘PROJECT_READ’ :return:

project_grant_group_permissions(project_key, group_name, permission)

Grant the specified project permission to a specific group :param project_key: The project key :param group_name: group to be granted :param permission: the project permissions available are ‘PROJECT_ADMIN’, ‘PROJECT_WRITE’ and ‘PROJECT_READ’ :return:

project_grant_user_permissions(project_key, username, permission)

Grant the specified project permission to a specific user :param project_key: The project key :param username: username to be granted :param permission: the project permissions available are ‘PROJECT_ADMIN’, ‘PROJECT_WRITE’ and ‘PROJECT_READ’ :return:

project_groups(key, start=0, limit=None, filter_str=None)

Get Project Groups :param limit: :param limit: :param start: :param key: The project key :param filter_str: OPTIONAL: group filter string :return:

project_groups_with_administrator_permissions(key)

Get groups with admin permissions :param key: :return:

project_keys(key, start=0, limit=None, filter_str=None)

Get SSH access keys added to the project :param start: :param limit: :param key: The project key :param filter_str: OPTIONAL: users filter string :return: The list of SSH access keys

project_list(start=0, limit=None)

Provide the project list

Returns:

A list of projects

project_remove_default_permissions(project_key, permission)

Revoke the specified project permission for all users for a given project :param project_key: The project key :param permission: the project permissions available are ‘PROJECT_ADMIN’, ‘PROJECT_WRITE’ and ‘PROJECT_READ’ :return:

project_remove_group_permissions(project_key, groupname)

Revoke all permissions for the specified project for a group. The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource. In addition, a user may not revoke a group’s permissions if it will reduce their own permission level. :param project_key: The project key :param groupname: group to be granted :return:

project_remove_user_permissions(project_key, username)

Revoke all permissions for the specified project for a user. The authenticated user must have PROJECT_ADMIN permission for the specified project or a higher global permission to call this resource. In addition, a user may not revoke their own project permissions if they do not have a higher global permission. :param project_key: The project key :param username: username to be granted :return:

project_summary(key)

Get a project summary :param key: The project key

Returns:

Map with the project information

project_users(key, start=0, limit=None, filter_str=None)

Get users with permission in project :param key: The project key :param filter_str: OPTIONAL: users filter string :param start: :param limit: :return: The list of project users

project_users_with_administrator_permissions(key)

Get project administrators for project :param key: The project key :return: List of project administrators

reindex()

Rebuild the bundled Elasticsearch indexes for Bitbucket Server :return:

reindex_repo(project_key, repository_slug)

Reindex repo :param project_key: :param repository_slug: :return:

reindex_repo_dev_panel(project_key, repository_slug)

Reindex all the Jira issues related to this repository_slug, including branches and pull requests. This automatically happens as part of an upgrade, and calling this manually should only be required if something unforeseen happens and the index becomes out of sync. The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource. :param project_key: :param repository_slug: :return:

remove_mail_sender_address()

Clears the server email address. The authenticated user must have the ADMIN permission to call this resource. :return:

reopen_pull_request(project_key, repository_slug, pr_id, pr_version)

Re-open a declined pull request. The authenticated user must have REPO_READ permission for the repository that this pull request targets to call this resource.

Parameters:
  • project_key – PROJECT

  • repository_slug – my_shiny_repo

  • pr_id – 2341

  • pr_version – 12

Returns:

repo_all_list(project_key)

Get all repositories list from project :param project_key: :return:

repo_exists(project_key, repository_slug)

Check if given combination of project and repository exists and available. :param project_key: Key of the project where to check for repository. :param repository_slug: url-compatible repository identifier to look for. :return: False is requested repository doesn’t exist in the project or not accessible to the requestor

repo_grant_group_permissions(project_key, repo_key, groupname, permission)

Grant the specified repository permission to a specific group Promote or demote a group’s permission level for the specified repository. Available repository permissions are:

REPO_READ REPO_WRITE REPO_ADMIN

See the Bitbucket Server documentation for a detailed explanation of what each permission entails. The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not demote a group’s permission level if their own permission level would be reduced as a result. :param project_key: The project key :param repo_key: The repository key (slug) :param groupname: group to be granted :param permission: the repository permissions available are ‘REPO_ADMIN’, ‘REPO_WRITE’ and ‘REPO_READ’ :return:

repo_grant_user_permissions(project_key, repo_key, username, permission)

Grant the specified repository permission to a specific user :param project_key: The project key :param repo_key: The repository key (slug) :param username: username to be granted :param permission: the repository permissions available are ‘REPO_ADMIN’, ‘REPO_WRITE’ and ‘REPO_READ’ :return:

repo_groups(project_key, repo_key, start=0, limit=None, filter_str=None)

Get repository Groups :param start: :param limit: :param project_key: The project key :param repo_key: The repository key :param filter_str: OPTIONAL: group filter string :return:

repo_groups_with_administrator_permissions(project_key, repo_key)

Get groups with admin permissions :param project_key: :param repo_key: :return:

repo_keys(project_key, repo_key, start=0, limit=None, filter_str=None)

Get SSH access keys added to the repository :param start: :param limit: :param project_key: The project key :param repo_key: The repository key :param filter_str: OPTIONAL: users filter string :return:

repo_list(project_key, start=0, limit=25)

Get repositories list from project

Parameters:
  • project_key – The project key

  • start

  • limit

Returns:

repo_remove_group_permissions(project_key, repo_key, groupname, permission)

Revoke all permissions for the specified repository for a group. The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not revoke a group’s permissions if it will reduce their own permission level. :param project_key: The project key :param repo_key: The repository key (slug) :param groupname: group to be granted :param permission: the repository permissions available are ‘REPO_ADMIN’, ‘REPO_WRITE’ and ‘REPO_READ’ :return:

repo_remove_user_permissions(project_key, repo_key, username)

Revoke all permissions for the specified repository for a user. The authenticated user must have REPO_ADMIN permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not revoke their own repository permissions if they do not have a higher project or global permission. :param project_key: The project key :param repo_key: The repository key (slug) :param username: username to be granted :return:

repo_users(project_key, repo_key, start=0, limit=None, filter_str=None)

Get users with permission in repository :param start: :param limit: :param project_key: The project key :param repo_key: The repository key :param filter_str: OPTIONAL: Users filter string :return:

repo_users_with_administrator_permissions(project_key, repo_key)

Get repository administrators for repository :param project_key: The project key :param repo_key: The repository key :return: List of repo administrators

search_code(team, search_query, page=1, limit=10)

Search repositories for matching code :team: str :search_query: str

search_pull_request_blocker_comment(project_key: str, repository_slug: str, pull_request_id: int) dict | None

Get all comments that block the merge of a pull request :param project_key: The project key :param repository_slug: The repository key :param pull_request_id: The pull request id :return:

set_announcement_banner(body)

Sets the announcement banner with the provided JSON. Only users authenticated as Admins may call this resource :param body

{

“id”: “https://docs.atlassian.com/jira/REST/schema/rest-announcement-banner#”, “title”: “Rest Announcement Banner”, “type”: “object”

}

Returns:

set_branches_permissions(project_key, multiple_permissions=False, matcher_type=None, matcher_value=None, permission_type=None, repository_slug=None, except_users=None, except_groups=None, except_access_keys=None, start=0, limit=25)

Create a restriction for the supplied branch or set of branches to be applied to the given repository. Allows creating multiple restrictions at once. To use multiple restrictions you should format payload manually - see the bitbucket-branch-restrictions.py example. Reference: https://docs.atlassian.com/bitbucket-server/rest/6.8.0/bitbucket-ref-restriction-rest.html :param project_key: :param multiple_permissions: :param matcher_type: :param matcher_value: :param permission_type: :param repository_slug: :param except_users: :param except_groups: :param except_access_keys: :param start: :param limit: :return:

set_branching_model(project_key, repository_slug, data)

Set branching model :param project_key: :param repository_slug: :param data: :return:

set_default_branch(project_key, repository_slug, ref_branch_name)

Update the default branch of a repository. The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource. :param project_key: The project key :param repository_slug: The repository key (slug) :param ref_branch_name: ref name like refs/heads/master :return:

set_lfs_repo_status(project_key, repo, enable=True)
set_project_avatar(key, icon, content_type='image/png')

Set project avatar :param key: The Project key :param icon: The icon file :param content_type: The content type of icon

Returns:

Value of post request

set_pull_request_settings(project_key, repository_slug, data)

Set pull request settings. :param project_key: :param repository_slug: :param data: json body :return:

set_repo_forkable(project_key, repository_slug, forkable)

Enable or disable forking for a Server/Data Center repository.

The caller requires repository administration permission. This uses the repository PUT endpoint and preserves the behavior of update_repo() for all other repository fields.

Parameters:
  • project_key – Project key, or a ~user personal repository owner.

  • repository_slug – URL-compatible repository identifier.

  • forkableTrue to allow forks or False to prohibit them.

Returns:

Updated repository representation.

set_repo_label(project_key, repository_slug, label_name)

Sets a label on a repository. (BitBucket Server only) The authenticated user must have REPO_ADMIN permission for the specified repository to call this resource. :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :param label_name: label name to apply :return:

set_tag(project_key, repository_slug, tag_name, commit_revision, description=None)

Creates a tag using the information provided in the {@link RestCreateTagRequest request} The authenticated user must have REPO_WRITE permission for the context repository to call this resource. :param project_key: :param repository_slug: :param tag_name: :param commit_revision: commit hash :param description: OPTIONAL: :return:

stop_pipeline(workspace, repository_slug, uuid)

Stop the pipeline specified by uuid. :param workspace: :param repository_slug: :param uuid: Pipeline identifier (with surrounding {}; NOT the build number)

See the documentation for the meaning of response status codes.

trigger_pipeline(workspace, repository_slug, branch='master', revision=None, name=None)

Trigger a new pipeline. The following options are possible (1 and 2 trigger the pipeline that the branch is associated with in the Pipelines configuration): 1. Latest revision of a branch (specify branch) 2. Specific revision on a branch (additionally specify revision) 3. Specific pipeline (additionally specify name) :return: the initiated pipeline; or error information

update_branch_restriction(workspace, repository_slug, id, **fields)

Update an existing branch restriction identified by id. Consult the official API documentation for valid fields.

update_file(project_key, repository_slug, content, message, branch, filename, source_commit_id)

Update existing file for given branch. :param project_key: :param repository_slug: :param content: :param message: :param branch: :param filename: :param source_commit_id: :return:

update_hook_script(script_id: int, content: bytes, name: str, hook_type: str, description: str | None = None)

Update a registered global hook script on Bitbucket Data Center.

hook_type must be PRE or POST. Like create_hook_script, the API expects a multipart form; content is the executable script bytes.

update_issue(workspace, repository_slug, id, **fields)

Update the fields of the issue specified by id. Consult the official API documentation for valid fields.

update_project(key, **params)

Update project :param key: The project key :return: The value of the put request.

update_project_condition(project_key, condition, id_condition)

Request type: PUT Update a new condition for this project. For further information visit:

ProjectKey:

str- project key involved

IdCondition:

int - condition id involved

Data:

condition: dictionary object

Example condition:
‘{“sourceMatcher”:

{“id”:”any”, “type”:{“id”:”ANY_REF”}}, “targetMatcher”:{“id”:”refs/heads/master”,”type”:{“id”:”BRANCH”}}, “reviewers”:[{“id”: 12}],”requiredApprovals”:”0”

}’

Returns:

update_pull_request(project_key, repository_slug, pull_request_id, data)

Update a pull request. The authenticated user must have REPO_WRITE permission for the repository that this pull request targets to call this resource. :param project_key: :param repository_slug: :param pull_request_id: the ID of the pull request within the repository :param data: json body :return:

update_pull_request_comment(project_key, repository_slug, pull_request_id, comment_id, comment, comment_version)

Update the text of a comment. Only the user who created a comment may update it.

Note: the supplied JSON object must contain a version that must match the server’s version of the comment or the update will fail.

update_repo(project_key, repository_slug, **params)

Update a repository in a project. This operates based on slug not name which may be confusing to some users. :param project_key: Key of the project you wish to look in. :param repository_slug: url-compatible repository identifier :return: The value of the put request.

update_repo_condition(project_key, repo_key, condition, id_condition)

Request type: PUT Update a specific condition for this repository slug inside project. For further information visit:

ProjectKey:

str- project key involved

RepoKey:

str - repo key involved

IdCondition:

int - condition id involved

Data:

condition: dictionary object

Example condition:
‘{“sourceMatcher”:

{“id”:”any”, “type”:{“id”:”ANY_REF”}}, “targetMatcher”:{“id”:”refs/heads/master”,”type”:{“id”:”BRANCH”}}, “reviewers”:[{“id”: 12}],”requiredApprovals”:”0”

}’

Returns:

update_task(task_id, text=None, state=None)

Update task by ID. It is possible to update state and/or text of the task :param task_id: :param text: :param state: OPEN, RESOLVED :return:

update_webhook(project_key, repository_slug, webhook_id, **params)

Update a webhook. The authenticated user must have REPO_ADMIN permission for the context repository to call this resource. :param project_key: :param repository_slug: :param webhook_id: the ID of the webhook within the repository :return:

upload_file(project_key, repository_slug, content, message, branch, filename)

Upload new file for given branch. :param project_key: :param repository_slug: :param content: :param message: :param branch: :param filename :return:

upload_plugin(plugin_path)

Provide plugin path for upload into BitBucket e.g. useful for auto deploy :param plugin_path: :return:

class atlassian.bitbucket.cloud.Cloud(url='https://api.bitbucket.org/', *args, **kwargs)

Bitbucket Cloud REST API wrapper

property repositories
property workspaces
class atlassian.bitbucket.server.Server(url, *args, **kwargs)

Class implementing parts of the REST API described in https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html

property groups

Property to access the global groups Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp62

personal_repositories(username)

Return repositories owned by a Bitbucket Server/Data Center user.

username may be supplied with or without the leading ~. The returned collection has the same API as project.repos and uses Bitbucket’s user-centric /users/{userSlug}/repos endpoint.

property projects

Property to access the projects Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp147

property users

Property to access the global users Reference: https://docs.atlassian.com/bitbucket-server/rest/7.8.0/bitbucket-rest.html#idp68

Server/Data Center pagination

Several Server/Data Center methods return Python generators, including project_list(), repo_list(), repo_all_list(), and get_pull_requests(). Iterate them to process every page lazily, or wrap them in list only when the entire result is small enough to hold in memory. Generators do not have a .json() method because each yielded value is already a Python dictionary.

for repository in bitbucket.repo_all_list("PROJ"):
    for pull_request in bitbucket.get_pull_requests("PROJ", repository["slug"], state="OPEN"):
        print(pull_request["title"])

advanced_mode=True is for callers that need raw requests.Response objects from individual requests. Do not enable it for the high-level paginated methods above; use their yielded dictionaries instead.

Personal repositories (Server/Data Center)

Repository methods accept a personal-project user slug in place of a project key. Prefix the Bitbucket username with ~ and the legacy client uses the user-centric /users/{userSlug}/repos/{repositorySlug} endpoint. This works for pull-request settings and every other repository method that accepts project_key and repository_slug.

owner = "~alice"
settings = bitbucket.get_pull_request_settings(owner, "personal-repository")
bitbucket.set_pull_request_settings(owner, "personal-repository", settings)

For the object-oriented Server/Data Center client, use personal_repositories(). It accepts either "alice" or "~alice".

from atlassian.bitbucket.server import Server

bitbucket = Server("https://bitbucket.example.com", username="admin", password="token")
repository = bitbucket.personal_repositories("alice").get("personal-repository")
print(repository.name)

Hook scripts (Data Center 8+)

Hook scripts are a Bitbucket Data Center feature, not Bitbucket Cloud. A system administrator first registers the global script, then a project or repository administrator configures the script for its target scope. Bitbucket Data Center 8.18 and newer disable this feature by default; enable feature.hook.scripts=true in bitbucket.properties and restart the cluster before use.

with open("hooks/audit-pushes.sh", "rb") as script_file:
    hook_script = bitbucket.create_hook_script(
        script_file.read(),
        name="Audit pushes",
        hook_type="POST",  # or "PRE"
        description="Records every push",
    )

bitbucket.configure_project_hook_script(
    "PROJ", hook_script["id"], trigger_ids=["repo:refs_changed"]
)
bitbucket.configure_repo_hook_script(
    "PROJ", "repository", hook_script["id"], trigger_ids=["repo:refs_changed"]
)

get_project_hook_scripts() and get_repo_hook_scripts() yield all configured scripts. delete_project_hook_script() and delete_repo_hook_script() remove only a scope configuration; they do not delete the global registered script.

The global registered script itself is managed with the server-level methods. get_hook_script() returns a script’s metadata, get_hook_script_content() returns its raw body, update_hook_script() replaces its body or metadata, and delete_hook_script() removes it entirely:

metadata = bitbucket.get_hook_script(hook_script["id"])
script = bitbucket.get_hook_script_content(hook_script["id"])

bitbucket.update_hook_script(
    hook_script["id"],
    content=script.replace(b"old", b"new"),
    name="Audit pushes (v2)",
    hook_type="POST",
    description="Records every push",
)
bitbucket.delete_hook_script(hook_script["id"])

Release report from two refs (Server/Data Center)

To report merged pull requests between two release tags or commit hashes, first iterate get_changelog() and then resolve the pull requests associated with each returned commit. A pull request can be associated with multiple commits, so retain the results by pull request ID to avoid duplicates.

merged_pull_requests = {}
for commit in bitbucket.get_changelog("PROJ", "repository", "refs/tags/v1.0", "refs/tags/v1.1"):
    for pull_request in bitbucket.get_pull_requests_contain_commit("PROJ", "repository", commit["id"]):
        if pull_request["state"] == "MERGED":
            merged_pull_requests[pull_request["id"]] = pull_request

for pull_request in merged_pull_requests.values():
    print(pull_request["title"])

See examples/bitbucket/bitbucket_server_release_report.py for a complete environment-variable-based script.

Commits belonging to an open pull request may not be reachable from the repository ref used by get_commits. To retrieve the commits that belong to a specific pull request on Server/Data Center, query the pull-request commits endpoint instead:

for commit in bitbucket.get_pull_requests_commits("PROJ", "repository", pull_request_id):
    print(commit["id"])

The Cloud object model provides the equivalent operation as repository.pullrequests.get(pull_request_id).commits. Use get_pull_requests_contain_commit when starting from an individual commit and looking up its associated pull requests.

Manage projects

# Project list
bitbucket.project_list()

# Repo list
bitbucket.repo_list(project_key)

# Project info
bitbucket.project(key)

# Create project
bitbucket.create_project(key, name, description="My pretty project")

# Get users who has permission in project
bitbucket.project_users(key, limit=99999, filter_str=None)

# Get project administrators for project
bitbucket.project_users_with_administrator_permissions(key)

# Get Project Groups
bitbucket.project_groups(key, limit=99999, filter_str=None)

# Get groups with admin permissions
bitbucket.project_groups_with_administrator_permissions(key)

# Project summary
bitbucket.project_summary(key)

# Check default permission for project
bitbucket.project_default_permissions(project_key, permission)

# Grant default permission for project
bitbucket.project_grant_default_permissions(project_key, permission)

# Grant project permission to a specific user
bitbucket.project_grant_user_permissions(project_key, username, permission)

# Grant project permission to a specific group
bitbucket.project_grant_group_permissions(project_key, group_name, permission)

# Remove default permission for project
bitbucket.project_remove_default_permissions(project_key, permission)

# Remove all project permissions for a specific user
bitbucket.project_remove_user_permissions(project_key, username)

# Remove all project permissions for a specific group
bitbucket.project_remove_group_permissions(project_key, groupname)

Manage repositories

# Get single repository
bitbucket.get_repo(project_key, repository_slug)

# Update single repository
bitbucket.update_repo(project_key, repository_slug, description="Repo description")

# Get labels for a single repository
bitbucket.get_repo_labels(project_key, repository_slug)

# Set label for a single repository
bitbucket.set_repo_label(project_key, repository_slug, label_name)

# Disable branching model
bitbucket.disable_branching_model(project_key, repo_key)

# Enable branching model
bitbucket.enable_branching_model(project_key, repo_key)

# Get branching model
bitbucket.get_branching_model(project_key, repo_key)

# Set branching model
data = {'development': {'refId': None, 'useDefault': True},
        'types': [{'displayName': 'Bugfix',
                   'enabled': True,
                   'id': 'BUGFIX',
                   'prefix': 'bugfix-'},
                  {'displayName': 'Feature',
                   'enabled': True,
                   'id': 'FEATURE',
                   'prefix': 'feature-'},
                  {'displayName': 'Hotfix',
                   'enabled': True,
                   'id': 'HOTFIX',
                   'prefix': 'hotfix-'},
                  {'displayName': 'Release',
                   'enabled': True,
                   'id': 'RELEASE',
                   'prefix': 'release/'}]}
bitbucket.set_branching_model(project_key, repo_key, data)

bitbucket.repo_users(project_key, repo_key, limit=99999, filter_str=None)

bitbucket.repo_groups(project_key, repo_key, limit=99999, filter_str=None)

# Grant repository permission to an specific user
bitbucket.repo_grant_user_permissions(project_key, repo_key, username, permission)

# Grant repository permission to an specific group
bitbucket.repo_grant_group_permissions(project_key, repo_key, groupname, permission)

# Delete a repository (DANGER!)
bitbucket.delete_repo(project_key, repository_slug)

# Fork repo inside same project
fork_repository(project_key, repository_slug, new_repository_slug)

# Fork repo to new project
fork_repository_new_project(project_key, repository_slug, new_project_key, new_repository_slug)

Manage Code Insights

# Delete an existing Code Insights report
bitbucket.delete_code_insights_report(project_key, repository_slug, commit_hash, report_key)

# Create a new Code Insights report
report = {
    'details': 'This is an example report',
    'result': 'FAIL',
    'reporter': 'Anonymous',
    'link': 'http://some-url',
    'logo-url': 'http://some-url',
    'data': [
        {
            'title': 'Example coverage',
            'type': 'PERCENTAGE',
            'value': 85
        }
    ]
}
bitbucket.create_code_insights_report(project_key, repository_slug, commit_hash, report_key, 'Code Insights Report', **report)

# Add annotations to a Code Insights report
annotations = [
    {
    'path': 'some/path/to/file',
    'line': 32,
    'message': 'Roses are red, Violets are blue, Unexpected { on line 32',
    'severity': 'MEDIUM'
    }
]
bitbucket.add_code_insights_annotations_to_report(project_key, repository_slug, commit_hash, report_key, **annotations)

Groups and admins

# Get groups. Use 'group_filter' parameter to get specific groups.
bitbucket.groups(group_filter="group", limit=99999)

# Get group of members
bitbucket.group_members(group, limit=99999)

# All project administrators
bitbucket.all_project_administrators()

# Get users. Use 'user_filter' parameter to get specific users.
bitbucket.get_users(user_filter="username", limit=25, start=0)

Manage code

# Get repositories list from project
bitbucket.repo_list(project_key, limit=25)

# Create a new repository.
# Requires an existing project in which this repository will be created. The only parameters which will be used
# are name and scmId.
# The authenticated user must have PROJECT_ADMIN permission for the context project to call this resource.
bitbucket.create_repo(project_key, repository, forkable=False, is_private=True)

# Bitbucket Server/Data Center: inspect or change whether a repository
# accepts forks. These calls require repository administration permission.
is_forkable = bitbucket.get_repo_forkable(project_key, repository)
bitbucket.set_repo_forkable(project_key, repository, forkable=True)
bitbucket.enable_repo_forking(project_key, repository)
bitbucket.disable_repo_forking(project_key, repository)

# Get branches from repo
bitbucket.get_branches(project, repository, filter='', limit=99999, details=True, boost_matches=False)

# Creates a branch using the information provided in the request.
# The authenticated user must have REPO_WRITE permission for the context repository to call this resource.
bitbucket.create_branch(project_key, repository, name, start_point, message)

# Delete branch from related repo
bitbucket.delete_branch(project, repository, name, end_point=None)

# Get pull requests
bitbucket.get_pull_requests(project, repository, state='OPEN', order='newest', limit=100, start=0)

# Get pull request activities
bitbucket.get_pull_requests_activities(project, repository, pull_request_id)

# Get pull request changes
bitbucket.get_pull_requests_changes(project, repository, pull_request_id)

# Get pull request commits
bitbucket.get_pull_requests_commits(project, repository, pull_request_id)

# Add comment into pull request
bitbucket.add_pull_request_comment(project, repository, pull_request_id, text)

# Reply to a comment of a pull request
bitbucket.add_pull_request_comment(project, repository, pull_request_id, text, parent_id=None)

# Get required reviewers for PR creation
bitbucket.get_required_reviewers_for_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, dest_branch)

# Create a new pull request between two branches.
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description)

# Create a new pull request between two branches with one reviewer
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers='name')

# Create a new pull request between two branches with multiple reviewers.
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, reviewers=['name1', 'name2'])

# Create a new pull request between two branches with required reviewers.
bitbucket.open_pull_request(source_project, source_repo, dest_project, dest_repo, source_branch, destination_branch, title, description, include_required_reviewers=True)

# Delete a pull request
bitbucket.delete_pull_request(project, repository, pull_request_id, pull_request_version)

# Get tags for related repo
bitbucket.get_tags(project, repository, filter='', limit=99999)

# Get project tags
# The authenticated user must have REPO_READ permission for the context repository to call this resource
bitbucket.get_project_tags(project, repository, tag_name)

# Set tag
# The authenticated user must have REPO_WRITE permission for the context repository to call this resource
bitbucket.set_tag(project, repository, tag_name, commit_revision, description=None)

# Delete tag
# The authenticated user must have REPO_WRITE permission for the context repository to call this resource
bitbucket.delete_tag(project, repository, tag_name)

# Get diff
bitbucket.get_diff(project, repository, path, hash_oldest, hash_newest)

# Get commit list from repo
bitbucket.get_commits(project, repository, hash_oldest, hash_newest, limit=99999)

# Get change log between 2 refs
bitbucket.get_changelog(project, repository, ref_from, ref_to, limit=99999)

# Get raw content of the file from repo
bitbucket.get_content_of_file(project, repository, filename, at=None, markup=None)
"""
    Retrieve the raw content for a file path at a specified revision.
    The authenticated user must have REPO_READ permission for the specified repository to call this resource.
"""

Branch permissions

# Set branches permissions
bitbucket.set_branches_permissions(project_key, multiple_permissions=False, matcher_type=None, matcher_value=None, permission_type=None, repository_slug=None, except_users=[], except_groups=[], except_access_keys=[], start=0, limit=25)

# Delete a single branch permission by permission id
bitbucket.delete_branch_permission(project_key, permission_id, repository_slug=None)

# Get a single branch permission by permission id
bitbucket.get_branch_permission(project_key, permission_id, repository_slug=None)

Pull Request management

# Decline pull request
bitbucket.decline_pull_request(project_key, repository, pr_id, pr_version)

# Check if pull request can be merged
bitbucket.is_pull_request_can_be_merged(project_key, repository, pr_id)

# Merge pull request
bitbucket.merge_pull_request(project_key, repository, pr_id, pr_version)

# Reopen pull request
bitbucket.reopen_pull_request(project_key, repository, pr_id, pr_version)

# Assign user as a reviewer of pull request
bitbucket.assign_pull_request_participant_role(project_key, repository, pr_id, "REVIEWER", username)

# Add a blocker comment to a pull request (create a new task)
bitbucket.add_pull_request_blocker_comment(project_key, repository, pr_id, "Input task text here", "BLOCKER")

# Get blocker comments for a pull request
bitbucket.search_pull_request_blocker_comment(project_key, repository, pr_id)

Conditions-Reviewers management

# Get all project conditions with reviewers list for specific project
bitbucket.get_project_conditions(project_key)

# Get a project condition with reviewers list for specific project
bitbucket.get_project_condition(project_key, id_condition)

# Create project condition with reviewers for specific project
# :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
bitbucket.create_project_condition(project_key, condition)

# Update a project condition with reviewers for specific project
# :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
bitbucket.update_project_condition(project_key, condition, id_condition)

# Delete a project condition for specific project
bitbucket.delete_project_condition(project_key, id_condition)

# Get all repository conditions with reviewers list for specific repository in project
bitbucket.get_repo_conditions(project_key, repo_key)

# Get repository conditions with reviewers list only only conditions type PROJECT for specific repository in project
bitbucket.get_repo_project_conditions(project_key, repo_key)

# Get repository conditions with reviewers list only conditions type REPOSITORY for specific repository in project
bitbucket.get_repo_repo_conditions(project_key, repo_key)

# Get a project condition with reviewers list for specific repository in project
bitbucket.get_repo_condition(project_key, repo_key, id_condition)

# Create project condition with reviewers for specific repository in project
# :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
bitbucket.create_repo_condition(project_key, repo_key, condition)

# Update a project condition with reviewers for specific repository in project
# :example condition: '{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}'
bitbucket.update_repo_condition(project_key, repo_key, condition, id_condition)

# Delete a project condition for specific repository in project
bitbucket.delete_repo_condition(project_key, repo_key, id_condition)

For Bitbucket Server/Data Center, administrators can inspect cluster node information with the legacy client:

from atlassian import Bitbucket

bitbucket = Bitbucket(
    url="https://bitbucket.example.com",
    username="admin",
    password="password",
)
cluster = bitbucket.get_cluster_info()

Bitbucket Cloud

Bitbucket Cloud and Bitbucket Server/Data Center have different REST API models. Use atlassian.bitbucket.cloud.Cloud for Cloud: it starts from workspaces and then navigates to repositories. Use Bitbucket or atlassian.bitbucket.server.Server for Server/Data Center project endpoints. Do not pass a Cloud URL to the legacy Server/Data Center methods.

Use an Atlassian account email and a scoped Bitbucket API token with the required repository and workspace permissions. The client uses HTTP Basic authentication automatically. App passwords were retired by Bitbucket Cloud in July 2026, so new integrations must use API tokens.

import os

from atlassian.bitbucket import Cloud

cloud = Cloud(
    username=os.environ["ATLASSIAN_EMAIL"],
    password=os.environ["BITBUCKET_API_TOKEN"],
)

# /2.0/user/workspaces is the supported listing route. ``each()`` resolves
# each entry and yields full workspace objects.
for workspace in cloud.workspaces.each():
    print(workspace.slug)

# Restrict the list to workspaces administered by the authenticated user.
admin_workspaces = list(cloud.workspaces.each(administrator=True))

repository = cloud.workspaces.get("workspace-slug").repositories.get("repository-slug")
print(repository.name)
# Get a list of workspaces.
cloud.workspaces.each()

# Get a single workspace by workspace slug.
workspace = cloud.workspaces.get(workspace_slug)

# Get a list of permissions in a workspace (this may not work depending on the size of your workspace)
workspace.permissions.each()

# Get a list of repository permissions in a workspace (this may not work depending on the size of your workspace)
workspace.permissions.repositories()

# Get a single repository permissions in a workspace
workspace.permissions.repositories(repo_slug)

# Get a list of projects in a workspace
workspace.projects.each()

# Get a single project from a workspace by project key
project = workspace.projects.get(project_key)

# Get a list of repos from a project
project.repositories.each()

# Get a repository
repository = workspace.repositories.get(repository_slug)

# Commit history supports include/exclude refs and a file-path filter.
commits = repository.commits.each(
    include="main",
    exclude="release",
    path="src/app.py",
)
for commit in commits:
    print(commit.hash)

The Cloud commits endpoint does not support arbitrary q expressions for filtering by author or date. Filter those fields in the returned commits, or use include, exclude and path when those server-side filters fit the use case.

# Read raw bytes from a file at a branch, tag, or commit SHA
readme = repository.get_source_file("main", "README.md")

# List directory entries at a branch, tag, or commit SHA
source_entries = repository.get_source_directory("main", "src")["values"]

# Get a list of deployment environments from a repository
repository.deployment_environments.each()

# Get a deployment environment by key
deployment_environment = repository.deployment_environments.get(deployment_environment_key)

# Get deployment environment variables from an environment
deployment_environment_variables = deployment_environment.deployment_environment_variables.each()

# Create a non-secured deployment environment variable.
new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create(
"KEY", "VALUE", False
)

# Update the 'key' field of repository_variable
updated_deployment_environment_variable = new_deployment_environment_variable.update(
key="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_KEY"
)

# Update the 'value' field of repository_variable
updated_deployment_environment_variable = new_deployment_environment_variable.update(
value="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_VALUE"
)

# Delete deployment environment variable
updated_deployment_environment_variable.delete()

# Get a list of group permissions from a repository
repository.group_permissions.each()

# Get a single group permission from a repository by group slug
repository.group_permissions.get(group_slug)

# Get a list of repository variables from a repository
repository.repository_variables.each()

# Get a repository variable by key
repository_variable = repository.repository_variables.get(
repository_variable_key
)

# Create a non-secured repository variable.
new_repository_variable = repository.repository_variables.create(
"KEY", "VALUE", False
)

# Update the 'key' field of repository_variable
updated_repository_variable = repository_variable.update(
key="UPDATED_REPOSITORY_VARIABLE_KEY"
)

# Update the 'value' field of repository_variable
updated_repository_variable = repository_variable.update(
value="UPDATED_REPOSITORY_VARIABLE_VALUE"
)

# Delete repository_variable
repository_variable.delete()

# Look up a repository pipeline variable by its name; the returned object
# exposes its UUID and can be updated without constructing a URL manually.
repository_variable = repository.repository_variables.get_by_key("qww")
if repository_variable is not None:
    print(repository_variable.uuid)
    repository.repository_variables.update_by_key(
        "qww",
        "new-value",
        secured=True,
    )

# Get a list of hooks from a repository
repository.hooks.each()

# Create a hook for a repository
hook = repo.hooks.create(
url="endpoint-url", description="description", active=True,
events=["a-repository-event"]
)

# Get a single hook for a repository
hook = repo.hooks.get("a-webhook-id")

# Update a specific hook for a repository
hook.update(
url="endpoint-url", description="description", active=True,
events=["a-repository-event"]
)

# Delete a speicifc hook for a repository
hook.delete()

# Get a list of workspace members
workspace.members.each()

# Get a specific workspace member
workspace.members.get("a-user-account-id")
workspace.members.get("{a-user-uuid}")

Pipelines management

# Object oriented:
    # Get the repository first
    r = cloud.workspaces.get(workspace).repositories.get(repository)

    # Get first ten Pipelines results for repository
    r.pipelines.each()

    # Get Pipelines results for repository, newest first
    r.pipelines.each(sort="-created_on")

    # Trigger default Pipeline on the latest revision of the master branch
    r.pipelines.trigger()

    # Trigger default Pipeline on the latest revision of the develop branch
    r.pipelines.trigger(branch="develop")

    # Trigger default Pipeline on a specific revision of the develop branch
    r.pipelines.trigger(branch="develop", commit="<40-char hash>")

    # Trigger specific Pipeline on a specific revision of the master branch
    r.pipelines.trigger(commit="<40-char hash>", pattern="style-check")

    # Trigger specific Pipeline of the master branch with specific variables
    r.pipelines.trigger(pattern="style-check", variables=[{ "key": "var-name", "value": "var-value" }])

    # Get specific Pipeline by UUID
    pl = r.pipelines.get("{7d6c327d-6336-4721-bfeb-c24caf25045c}")

    # Stop specific Pipeline by UUID
    pl.stop()

    # Get steps of Pipeline specified by UUID
    pl.steps()

    # Get step of Pipeline specified by UUIDs
    s = pl.step("{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

    # Get log of step of Pipeline specified by UUIDs
    s.log()

# or function oriented:
    # Get most recent Pipelines results for repository
    bitbucket.get_pipelines(workspace, repository)

    # Trigger default Pipeline on the latest revision of the master branch
    bitbucket.trigger_pipeline(workspace, repository)

    # Trigger default Pipeline on the latest revision of the develop branch
    bitbucket.trigger_pipeline(workspace, repository, branch="develop")

    # Trigger default Pipeline on a specific revision of the develop branch
    bitbucket.trigger_pipeline(workspace, repository, branch="develop", revision="<40-char hash>")

    # Trigger specific Pipeline on a specific revision of the master branch
    bitbucket.trigger_pipeline(workspace, repository, revision="<40-char hash>", name="style-check")

    # Get specific Pipeline by UUID
    bitbucket.get_pipeline(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

    # Stop specific Pipeline by UUID
    bitbucket.stop_pipeline(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

    # Get steps of Pipeline specified by UUID
    bitbucket.get_pipeline_steps(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}")

    # Get step of Pipeline specified by UUIDs
    bitbucket.get_pipeline_step(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}", "{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

    # Get log of step of Pipeline specified by UUIDs
    bitbucket.get_pipeline_step_log(workspace, repository, "{7d6c327d-6336-4721-bfeb-c24caf25045c}", "{56d2d8af-6526-4813-a22c-733ec6ecabf3}")

Manage issues

# Object oriented:
    # Get the repository first
    r = cloud.workspaces.get(workspace).repositories.get(repository)

    # Get all tracked issues
    r.issues.each()

    # Get all unassigned issues and sort them by priority
    r.issues.get(sort_by="priority", query='assignee = null')

    # Create a new issue of kind 'enhancement' and priority 'minor'
    r.issues.create("New idea", "How about this", kind="enhancement", priority="minor")

    # Update the 'priority' field of the issue 42
    r.issues.get(42).priority = "blocker"

    # Mark issue 42 as resolved
    r.issues.get(42).state = "resolved"

    # Get information about issue 1
    i = r.issues.get(1)

    # Delete issue 123
    r.issues.get(123).delete()

# or function oriented:
    # Get all tracked issues
    bitbucket.get_issues(workspace, repository)

    # Get all unassigned issues and sort them by priority
    bitbucket.get_issues(workspace, repository, sort_by="priority", query='assignee = null')

    # Create a new issue
    bitbucket.create_issue(workspace, repository, "The title", "The description")

    # Create a new issue of kind 'enhancement' and priority 'minor'
    bitbucket.create_issue(workspace, repository, "New idea", "How about this", kind="enhancement", priority="minor")

    # Update the 'priority' field of the issue 42
    bitbucket.update_issue(workspace, repository, 42, priority="blocker")

    # Mark issue 42 as resolved
    bitbucket.update_issue(workspace, repository, 42, state="resolved")

    # Get information about issue 1
    bitbucket.get_issue(workspace, repository, 1)

    # Delete issue 123
    bitbucket.delete_issue(workspace, repository, 123)