Atlassian Python API Documentation · Atlassian Python API Documentation, Release 1.15.3 (continued...
Transcript of Atlassian Python API Documentation · Atlassian Python API Documentation, Release 1.15.3 (continued...
Atlassian Python API DocumentationRelease 1.15.3
SLRover
Feb 29, 2020
Contents
1 Getting started 3
2 Key/Cert Based authentication 52.1 Jira module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 Confluence module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 BitBucket module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.4 Bamboo module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.5 Jira Service Desk module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
i
ii
Atlassian Python API Documentation, Release 1.15.3
Contents 1
Atlassian Python API Documentation, Release 1.15.3
2 Contents
CHAPTER 1
Getting started
Install package using pip:
pip install atlassian-python-api
Add a connection:
from atlassian import Jirafrom atlassian import Confluencefrom atlassian import Bitbucketfrom atlassian import ServiceDesk
jira = Jira(url='http://localhost:8080',username='admin',password='admin')
confluence = Confluence(url='http://localhost:8090',username='admin',password='admin')
bitbucket = Bitbucket(url='http://localhost:7990',username='admin',password='admin')
service_desk = ServiceDesk(url='http://localhost:8080',username='admin',password='admin')
3
Atlassian Python API Documentation, Release 1.15.3
4 Chapter 1. Getting started
CHAPTER 2
Key/Cert Based authentication
Add a connection using key/cert based authentication:
from atlassian import Jirafrom atlassian import Confluencefrom atlassian import Bitbucketfrom atlassian import ServiceDesk
jira = Jira(url='http://localhost:8080',key='/path/to/key',cert='/path/to/cert')
confluence = Confluence(url='http://localhost:8090',key='/path/to/key',cert='/path/to/cert')
bitbucket = Bitbucket(url='http://localhost:7990',key='/path/to/key',cert='/path/to/cert')
service_desk = ServiceDesk(url='http://localhost:8080',key='/path/to/key',cert='/path/to/cert')
Alternatively OAuth can be used:
oauth_dict = {'access_token': 'access_token','access_token_secret': 'access_token_secret','consumer_key': 'consumer_key','key_cert': 'key_cert'}
(continues on next page)
5
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
jira = Jira(url='http://localhost:8080',oauth=oauth_dict)
confluence = Confluence(url='http://localhost:8090',oauth=oauth_dict)
bitbucket = Bitbucket(url='http://localhost:7990',oauth=oauth_dict)
service_desk = ServiceDesk(url='http://localhost:8080',oauth=oauth_dict)
Or Kerberos (installation with kerberos extra necessary):
kerberos_service = 'HTTP/[email protected]'
jira = Jira(url='http://localhost:8080',kerberos=kerberos_service)
confluence = Confluence(url='http://localhost:8090',kerberos=kerberos_service)
bitbucket = Bitbucket(url='http://localhost:7990',kerberos=kerberos_service)
service_desk = ServiceDesk(url='http://localhost:8080',kerberos=kerberos_service)
Or reuse cookie file:
from atlassian import utilscookie_dict = utils.parse_cookie_file("cookie.txt")
jira = Jira(url='http://localhost:8080',cookie=cookie_dict)
confluence = Confluence(url='http://localhost:8090',cookie=cookie_dict)
bitbucket = Bitbucket(url='http://localhost:7990',cookie=cookie_dict)
service_desk = ServiceDesk(url='http://localhost:8080',cookie=cookie_dict)
6 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
2.1 Jira module
2.1.1 Get issues from jql search result with all related fields
jql_request = 'project = DEMO AND status NOT IN (Closed, Resolved) ORDER BY issuekey'issues = jira.jql(jql_request)print(issues)
2.1.2 Reindex Jira
# Reindexing Jirajira.reindex()
# Reindex statusjira.reindex_status()
# Reindex typejira.reindex_with_type(indexing_type="BACKGROUND_PREFERRED")"""FOREGROUND - runs a lock/full reindexingBACKGROUND - runs a background reindexing.
If JIRA fails to finish the background reindexing, respond with 409→˓Conflict (error message).BACKGROUND_PREFERRED - If possible do a background reindexing.
If it's not possible (due to an inconsistent index), do a→˓foreground reindexing."""
2.1.3 Manage users
# Get userjira.user(username)
# Remove userjira.user_remove(username)
# Deactivate user. Works from 8.3.0 releasejira.user_deactivate(username)
# Get web sudo cookies using normal http requestjira.user_get_websudo()
# Fuzzy search using username and display namejira.user_find_by_user_string(username, start=0, limit=50, include_inactive_→˓users=False)
2.1.4 Manage groups
# Create a groupjira.create_group(name)
(continues on next page)
2.1. Jira module 7
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Delete a group# If you delete a group and content is restricted to that group, the content will be→˓hidden from all users# To prevent this, use this parameter to specify a different group to transfer the→˓restrictions# (comments and worklogs only) tojira.remove_group(name, swap_group=None)
# Get all users from groupjira.get_all_users_from_group(group, include_inactive_users=False, start=0, limit=50)
# Add given user to a groupjira.add_user_to_group(username, group_name)
# Remove given user from a groupjira.remove_user_from_group(username, group_name)
2.1.5 Manage projects
# Get all projects# Returns all projects which are visible for the currently logged in user.jira.projects(included_archived=None)
# Get all project alternative call# Returns all projects which are visible for the currently logged in user.jira.get_all_projects(included_archived=None)
# Get projectjira.project(key)
# Get project components using project keyjira.get_project_components(key)
# Get a full representation of a the specified project's versionsjira.get_project_versions(key, expand=None)
# Returns all versions for the specified project. Results are paginated.# Results can be ordered by the following fields: sequence, name, startDate,→˓releaseDate.jira.get_project_versions_paginated(key, start=None, limit=None, order_by=None,→˓expand=None)
# Add missing version to projectjira.add_version(key, project_id, version, is_archived=False, is_released=False)
# Get project leadersjira.project_leaders()
# Get last project issuekeyjira.get_project_issuekey_last(project)
# Get all project issue keysjira.get_project_issuekey_all(project)
(continues on next page)
8 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Get project issues countjira.get_project_issues_count(project)
# Get all project issuesjira.get_all_project_issues(project, fields='*all')
# Get all assignable users for projectjira.get_all_assignable_users_for_project(project_key, start=0, limit=50)
# Update a projectjira.update_project(project_key, data, expand='lead,description')
# Get project permission scheme# Use 'expand' to get details (default is None)jira.get_project_permission_scheme(project_id_or_key, expand='permissions,user,group,→˓projectRole,field,all')
# Get the issue security scheme for project.# Returned if the user has the administrator permission or if the scheme is used in a→˓project in which the# user has the administrative permission.# Use only_levels=True for get the only levels entriesjira.get_project_issue_security_scheme(project_id_or_key, only_levels=False)
2.1.6 Manage issues
# Get issue by keyjira.issue(key)
# Get issue field valuejira.issue_field_value(key, field)
# Update issue fieldfields = {'summary': 'New summary'}jira.update_issue_field(key, fields)
# Get existing custom fields or find by filterget_custom_fields(self, search=None, start=1, limit=50):
# Rename sprintjira.rename_sprint(sprint_id, name, start_date, end_date)
# Check issue existsjira.issue_exists(issue_key)
# Check issue deletedjira.issue_deleted(issue_key)
# Update issuejira.issue_update(issue_key, fields)
# Create issuejira.issue_create(fields)
# Issue create or update(continues on next page)
2.1. Jira module 9
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
jira.issue_create_or_update(fields)
# Get issue transitionsjira.get_issue_transitions(issue_key)
# Get status ID from namejira.get_status_id_from_name(status_name)
# Get transition id to status namejira.get_transition_id_to_status_name(issue_key, status_name)
# Transition issuejira.issue_transition(issue_key, status)
# Set issue statusjira.set_issue_status(issue_key, status_name)
# Set issue status by transition_idjira.set_issue_status_by_transition_id(issue_key, transition_id)
# Get issue statusjira.get_issue_status(issue_key)
# Create or Update Issue Linksjira.create_or_update_issue_remote_links(issue_key, link_url, title, global_id=None,→˓relationship=None)
# Get Issue Link by link IDjira.get_issue_remote_link_by_id(issue_key, link_id)
# Update Issue Link by link IDjira.update_issue_remote_link_by_id(issue_key, link_id, url, title, global_id=None,→˓relationship=None)
# Delete Issue Linksjira.delete_issue_remote_link_by_id(issue_key, link_id)
2.1.7 Attachments actions
# Add attachment to issuejira.add_attachment(issue_key, filename)
2.1.8 Manage components
# Get componentjira.component(component_id)
# Create componentjira.create_component(component)
# Delete componentjira.delete_component(component_id)
10 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
2.1.9 Upload Jira plugin
upload_plugin(plugin_path)
2.1.10 Issue link types
# Get Issue link typesjira.get_issue_link_types():
# Create Issue link typesjira.create_issue_link_type(data):"""Create a new issue link type.
:param data:{
"name": "Duplicate","inward": "Duplicated by","outward": "Duplicates"
}
"""
# Get issue link type by idjira.get_issue_link_type(issue_link_type_id):
# Delete issue link typejira.delete_issue_link_type(issue_link_type_id):
# Update issue link typejira.update_issue_link_type(issue_link_type_id, data):
2.1.11 Issue security schemes
# Get all security schemes.# Returned if the user has the administrator permission or if the scheme is used in a→˓project in which the# user has the administrative permission.jira.get_issue_security_schemes()
# Get issue security scheme.# Returned if the user has the administrator permission or if the scheme is used in a→˓project in which the# user has the administrative permission.# Use only_levels=True for get the only levels entriesjira.get_issue_security_scheme(scheme_id, only_levels=False)
2.1.12 TEMPO
# Find existing worklogs with the search parameters.# Look at the tempo docs for additional information:# https://www.tempo.io/server-api-documentation/timesheets#operation/searchWorklogs# NOTE: check if you are using correct types for the parameters!
(continues on next page)
2.1. Jira module 11
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# :param from: string From Date# :param to: string To Date# :param worker: Array of strings# :param taskId: Array of integers# :param taskKey: Array of strings# :param projectId: Array of integers# :param projectKey: Array of strings# :param teamId: Array of integers# :param roleId: Array of integers# :param accountId: Array of integers# :param accountKey: Array of strings# :param filterId: Array of integers# :param customerId: Array of integers# :param categoryId: Array of integers# :param categoryTypeId: Array of integers# :param epicKey: Array of strings# :param updatedFrom: string# :param includeSubtasks: boolean# :param pageNo: integer# :param maxResults: integer# :param offset: integerjira.tempo_4_timesheets_find_worklogs(**params)
# :PRIVATE:# Get Tempo timesheet worklog by issue key or id.jira.tempo_timesheets_get_worklogs_by_issue(issue)
2.2 Confluence module
2.2.1 Get page info
# Check page existsconfluence.page_exists(space, title)
# Provide content by type (page, blog, comment)confluence.get_page_child_by_type(page_id, type='page', start=None, limit=None)
# Provide content id from search result by title and spaceconfluence.get_page_id(space, title)
# Provide space key from content idconfluence.get_page_space(page_id)
# Returns the list of labels on a piece of Contentconfluence.get_page_by_title(space, title, start=None, limit=None)
# Get page by ID# Example request URI(s):# http://example.com/confluence/rest/api/content/1234?expand=space,body.view,→˓version,container# http://example.com/confluence/rest/api/content/1234?status=any# page_id: Content ID# status: (str) list of Content statuses to filter results on. Default value:→˓[current]
(continues on next page)
12 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# version: (int)# expand: OPTIONAL: A comma separated list of properties to expand on the content.# Default value: history,space,version# We can also specify some extensions such as extensions.→˓inlineProperties# (for getting inline comment-specific properties) or extensions.→˓resolution# for the resolution status of each comment in the resultsconfluence.get_page_by_id(self, page_id, expand=None, status=None, version=None)
# The list of labels on a piece of Contentconfluence.get_page_labels(page_id, prefix=None, start=None, limit=None)
# Get draft page by IDconfluence.get_draft_page_by_id(page_id, status='draft')
# Get all page by labelconfluence.get_all_pages_by_label(label, start=0, limit=50)
# Get all pages from Space# content_type can be 'page' or 'blogpost'. Defaults to 'page'# expand is a comma separated list of properties to expand on the content.# max limit is 100. For more you have to loop over start values.confluence.get_all_pages_from_space(space, start=0, limit=100, status=None,→˓expand=None, content_type='page')
# Get list of pages from trashconfluence.get_all_pages_from_space_trash(space, start=0, limit=500, status='trashed',→˓ content_type='page')
# Get list of draft pages from space# Use case is cleanup old drafts from Confluenceconfluence.get_all_draft_pages_from_space(space, start=0, limit=500, status='draft')
# Search list of draft pages by space key# Use case is cleanup old drafts from Confluenceconfluence.get_all_draft_pages_from_space_through_cql(space, start=0, limit=500,→˓status='draft')
# Info about all restrictions by operationconfluence.get_all_restrictions_for_content(content_id)
2.2.2 Page actions
# Create page from scratchconfluence.create_page(space, title, body, parent_id=None, type='page',→˓representation='storage')
# This method removes a page, if it has recursive flag, method removes including→˓child pagesconfluence.remove_page(page_id, status=None, recursive=False)
# Remove any contentconfluence.remove_content(content_id):
(continues on next page)
2.2. Confluence module 13
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Remove page from trashconfluence.remove_page_from_trash(page_id)
# Remove page as draftconfluence.remove_page_as_draft(page_id)
# Update page if already existconfluence.update_page(page_id, title, body, parent_id=None, type='page',→˓representation='storage', minor_edit=False)
# Update page or create page if it is not existsconfluence.update_or_create(parent_id, title, body, representation='storage')
# Append body to page if already existconfluence.append_page(self, page_id, title, append_body, parent_id=None, type='page',→˓ representation='storage', minor_edit=False)
# Set the page (content) property e.g. add hash parametersconfluence.set_page_property(page_id, data)
# Delete the page (content) property e.g. delete key of hashconfluence.delete_page_property(page_id, page_property)
# Move pageconfluence.move_page(space_key, page_id, target_title, position="append")
# Get the page (content) property e.g. get key of hashconfluence.get_page_property(page_id, page_property_key)
# Get the page (content) propertiesconfluence.get_page_properties(page_id)
# Get page ancestorsconfluence.get_page_ancestors(page_id)
# Attach (upload) a file to a page, if it exists it will update the# automatically version the new file and keep the old oneconfluence.attach_file(filename, name=None, content_type=None, page_id=None,→˓title=None, space=None, comment=None)
# Attach (upload) a content to a page, if it exists it will update the# automatically version the new file and keep the old oneconfluence.attach_content(content, name=None, content_type=None, page_id=None,→˓title=None, space=None, comment=None)
# Remove completely a file if version is None or delete versionconfluence.delete_attachment(page_id, filename, version=None)
# Remove completely a file if version is None or delete versionconfluence.delete_attachment_by_id(attachment_id, version)
# Keep last versionsconfluence.remove_page_attachment_keep_version(page_id, filename, keep_last_versions)
# Get attachment historyconfluence.get_attachment_history(attachment_id, limit=200, start=0)
(continues on next page)
14 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Get attachment for contentconfluence.get_attachments_from_content(page_id, start=0, limit=50, expand=None,→˓filename=None, media_type=None)
# Check has unknown attachment error on pageconfluence.has_unknown_attachment_error(page_id)
# Export page as PDF# api_version needs to be set to 'cloud' when exporting from Confluence Cloud.confluence.export_page(page_id)
# Set a label on the pageconfluence.set_page_label(page_id, label)
# Delete Confluence page labelconfluence.remove_page_label(page_id, label)
# Add comment into pageconfluence.add_comment(page_id, text)
2.2.3 Get spaces info
# Get all spaces with provided limit# additional info, e.g. metadata, icon, description, homepageconfluence.get_all_spaces(start=0, limit=500, expand=None)
# Get information about a space through space keyconfluence.get_space(space_key, expand='description.plain,homepage')
2.2.4 Users and Groups
# Get all groups from Confluence User managementconfluence.get_all_groups(start=0, limit=1000)
# Get a paginated collection of users in the given groupconfluence.get_group_members(group_name='confluence-users', start=0, limit=1000)
# Get information about a user through usernameconfluence.get_user_details_by_username(username, expand=None)
# Get information about a user through user keyconfluence.get_user_details_by_userkey(userkey, expand=None)
2.2.5 CQL
# Get results from cql search result with all related fieldsconfluence.cql(cql, start=0, limit=None, expand=None, include_archived_spaces=None,→˓excerpt=None)
2.2. Confluence module 15
Atlassian Python API Documentation, Release 1.15.3
2.2.6 Other actions
# Clean all caches from cache managementconfluence.clean_all_caches()
# Clean caches from cache management# e.g.# com.gliffy.cache.gon# org.hibernate.cache.internal.StandardQueryCache_v5confluence.clean_package_cache(cache_name='com.gliffy.cache.gon')
# Convert to Confluence XHTML format from wiki styleconfluence.convert_wiki_to_storage(wiki)
# Get page historyconfluence.history(page_id)
# Get content history by version number. It works as experimental methodconfluence.get_content_history_by_version_number(content_id, version_number)
# Remove content history. It works as experimental methodconfluence.remove_content_history(page_id, version_number)
# Compare content and check is already updated or notconfluence.is_page_content_is_already_updated(page_id, body)
2.3 BitBucket module
2.3.1 Manage projects
# Project listbitbucket.project_list()
# Repo listbitbucket.repo_list(project_key)
# Project infobitbucket.project(key)
# Create projectbitbucket.create_project(key, name, description="My pretty project")
# Get users who has permission in projectbitbucket.project_users(key, limit=99999, filter_str=None)
# Get project administrators for projectbutbucket.project_users_with_administrator_permissions(key)
# Get Project Groupsbitbucket.project_groups(key, limit=99999, filter_str=None)
# Get groups with admin permissionsbitbucket.project_groups_with_administrator_permissions(key)
(continues on next page)
16 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Project summarybitbucket.project_summary(key)
# Grant project permission to an specific userbitbucket.project_grant_user_permissions(project_key, username, permission)
# Grant project permission to an specific groupbitbucket.project_grant_group_permissions(project_key, groupname, permission)
2.3.2 Manage repositories
# Get single repositorybitbucket.get_repo(project_key, repository_slug)
# Disable branching modelbitbucket.disable_branching_model(project_key, repo_key)
# Enable branching modelbitbucket.enable_branching_model(project_key, repo_key)
# Get branching modelbitbucket.get_branching_model(project_key, repo_key)
# Set branching modeldata = {'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 userbitbucket.repo_grant_user_permissions(project_key, repo_key, username, permission)
# Grant repository permission to an specific groupbitbucket.repo_grant_group_permissions(project_key, repo_key, groupname, permission)
# Delete a repository (DANGER!)bitbucket.delete_repo(project_key, repository_slug)
2.3. BitBucket module 17
Atlassian Python API Documentation, Release 1.15.3
2.3.3 Groups and admins
# Get group of membersbitbucket.group_members(group, limit=99999)
# All project administratorsbitbucket.all_project_administrators()
# Get users. Use 'user_filter' parameter to get specific users.bitbucket.get_users(user_filter="username")
2.3.4 Manage code
# Get repositories list from projectbitbucket.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)
# Get branches from repobitbucket.get_branches(project, repository, filter='', limit=99999, details=True)
# 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 repobitbucket.delete_branch(project, repository, name, end_point)
# Get pull requestsbitbucket.get_pull_requests(project, repository, state='OPEN', order='newest',→˓limit=100, start=0)
# Get pull request activitiesbitbucket.get_pull_requests_activities(project, repository, pull_request_id)
# Get pull request changesbitbucket.get_pull_requests_changes(project, repository, pull_request_id)
# Get pull request commitsbitbucket.get_pull_requests_commits(project, repository, pull_request_id)
# Add comment into pull requestbitbucket.add_pull_request_comment(project, repository, pull_request_id, text)
# 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)
(continues on next page)
18 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Get tags for related repobitbucket.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 resourcebitbucket.get_project_tags(project, repository, tag_name)
# Set tag# The authenticated user must have REPO_WRITE permission for the context repository→˓to call this resourcebitbucket.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 resourcebitbucket.delete_tag(project, repository, tag_name)
# Get diffbitbucket.get_diff(project, repository, path, hash_oldest, hash_newest)
# Get commit list from repobitbucket.get_commits(project, repository, hash_oldest, hash_newest, limit=99999)
# Get change log between 2 refsbitbucket.get_changelog(project, repository, ref_from, ref_to, limit=99999)
# Get raw content of the file from repobitbucket.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."""
2.3.5 Branch permissions
# Set branches permissionsbitbucket.set_branches_permissions(project_key, multiple_permissions=False, matcher_→˓type=None, matcher_value=None, permission_type=None, repository=None, except_→˓users=[], except_groups=[], except_access_keys=[], start=0, limit=25)
# Delete a single branch permission by premission idbitbucket.delete_branch_permission(project_key, permission_id, repository=None)
# Get a single branch permission by permission idbitbucket.get_branch_permission(project_key, permission_id, repository=None)
2.3.6 Pull Request management
# Decline pull requestbitbucket.decline_pull_request(project_key, repository, pr_id, pr_version)
(continues on next page)
2.3. BitBucket module 19
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Check if pull request can be mergedbitbucket.is_pull_request_can_be_merged(project_key, repository, pr_id)
# Merge pull requestbitbucket.merge_pull_request(project_key, repository, pr_id, pr_version)
# Reopen pull requestbitbucket.reopen_pull_request(project_key, repository, pr_id, pr_version)
2.3.7 Conditions-Reviewers management
# Get all project conditions with reviewers list for specific projectbitbucket.get_project_conditions(project_key)
# Get a project condition with reviewers list for specific projectbitbucket.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 projectbitbucket.delete_project_condition(project_key, id_condition)
# Get all repository conditions with reviewers list for specific repository in projectbitbucket.get_repo_conditions(project_key, repo_key)
# Get repository conditions with reviewers list only only conditions type PROJECT for→˓specific repository in projectbitbucket.get_repo_project_conditions(project_key, repo_key)
# Get repository conditions with reviewers list only conditions type REPOSITORY for→˓specific repository in projectbitbucket.get_repo_repo_conditions(project_key, repo_key)
# Get a project condition with reviewers list for specific repository in projectbitbucket.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"}'
(continues on next page)
20 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
bitbucket.update_repo_condition(project_key, repo_key, condition, id_condition)
# Delete a project condition for specific repository in projectbitbucket.delete_repo_condition(project_key, repo_key, id_condition)
2.4 Bamboo module
2.4.1 Projects & Plans
# Get all Projectsprojects(expand=None, favourite=False, clover_enabled=False, max_results=25)
# Get a single project by the keyproject(project_key, expand=None, favourite=False, clover_enabled=False)
# Get all build plans in a projectproject_plans(project_key)
# Get all build plansplans(expand=None, favourite=False, clover_enabled=False, start_index=0, max_→˓results=25)
# Get information about plan build directoryplan_directory_info(plan_key)
# Get plan informationget_plan(plan_key)
# Delete a plan (or a plan branch)delete_plan(plan_key)
# Disable plandisable_plan(plan_key)
# Enable planenable_plan(plan_key)
2.4.2 Branches
# Search Branchessearch_branches(plan_key, include_default_branch=True, max_results=25)
# Get all plan Branchesplan_branches(plan_key, expand=None, favourite=False, clover_enabled=False, max_→˓results=25)
# Get branch informationget_branch_info(plan_key, branch_name)
# Create new branch (vcs or simple)create_branch(plan_key, branch_name, vcs_branch=None, enabled=False, cleanup_→˓enabled=False)
(continues on next page)
2.4. Bamboo module 21
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Get VCS Branchesget_vcs_branches(plan_key, max_results=25)
2.4.3 Build results
# Get build results (Scalable from a single result to all build results)results(project_key=None, plan_key=None, job_key=None, build_number=None, expand=None,→˓ favourite=False,
clover_enabled=False, issue_key=None, label=None, start_index=0, max_→˓results=25, include_all_states=False)
# Get latest build resultslatest_results(expand=None, favourite=False, clover_enabled=False, label=None, issue_→˓key=None,
start_index=0, max_results=25, include_all_states=False)
# Get latest build results for the projectproject_latest_results(project_key, expand=None, favourite=False, clover_→˓enabled=False, label=None,
issue_key=None, start_index=0, max_results=25, include_all_→˓states=False)
# Get build results for a single planplan_results(project_key, plan_key, expand=None, favourite=False, clover_→˓enabled=False, label=None,
issue_key=None, start_index=0, max_results=25, include_all_→˓states=False)
# Get a single build resultbuild_result(build_key, expand=None, include_all_states=False)
# Get latest results for a planbuild_latest_result(plan_key, expand=None, include_all_states=False)
# Delete build resultdelete_build_result(build_key)
# Execute buildexecute_build(plan_key, stage=None, execute_all_stages=True, custom_revision=None,→˓**bamboo_variables)
2.4.4 Comments & Labels
# Get comments for the buildcomments(project_key, plan_key, build_number, start_index=0, max_results=25)
# Make a commentcreate_comment(project_key, plan_key, build_number, comment, author=None)
# Get labels for a buildlabels(project_key, plan_key, build_number, start_index=0, max_results=25)
(continues on next page)
22 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# Create a labelcreate_label(project_key, plan_key, build_number, label)
# Delete a labeldelete_label(project_key, plan_key, build_number, label)
2.4.5 Deployments
# Get deployment projectsdeployment_projects()
# Get deployments for a single projectdeployment_project(project_id)
# Get deployment environment resultsdeployment_environment_results(env_id, expand=None, max_results=25)
# Get deployment dashboarddeployment_dashboard(project_id=None)
2.4.6 Users & Groups
# Get users in global permissonsget_users_in_global_permissions(start=0, limit=25)
# Get Groupsget_groups(start=0, limit=25)
# Create Groupcreate_group(group_name)
# Delete Groupdelete_group(group_name)
# Add users into Groupadd_users_into_group(group_name, users)
# Remove users from Groupremove_users_from_group(group_name, users)
# Get users from Groupget_users_from_group(group_name, filter_users=None, start=0, limit=25)
# Get users without Groupget_users_not_in_group(group_name, filter_users='', start=0, limit=25)
2.4.7 Other actions
2.4. Bamboo module 23
Atlassian Python API Documentation, Release 1.15.3
# Get build queueget_build_queue(expand='queuedBuilds')
# Get server informationserver_info()
# Get agents statusesagent_status()
# Get activityactivity()
# Get custom expiryget_custom_expiry(limit=25)
# Get reportsreports(max_results=25)
# Get chartshart(report_key, build_keys, group_by_period, date_filter=None, date_from=None, date_→˓to=None,
width=None, height=None, start_index=9, max_results=25)
# Health checkhealth_check()
# Upload pluginupload_plugin(plugin_path)
2.5 Jira Service Desk module
2.5.1 Get info about Service Desk
# Get info about Service Desk appsd.get_info()
# Get all service desks in the JIRA Service Desk application with the option to→˓include archived service deskssd.get_service_desks()
# Get the service desk for a given service desk IDsd.get_service_desk_by_id(service_desk_id)
2.5.2 Create customer
EXPERIMENTAL (may change without notice)
sd.create_customer(full_name, email)
24 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
2.5.3 The Request actions
# Create customer requestsd.create_customer_request(service_desk_id, request_type_id, values_dict, raise_on_→˓behalf_of=None, request_participants=None)
# Get customer request by IDsd.get_customer_request(issue_id_or_key)
# Get customer requestssd.get_my_customer_requests()
# Get customer request statussd.get_customer_request_status(issue_id_or_key)
# Create comment. Optional argument public (True or False), default is Truesd.create_request_comment(issue_id_or_key, body, public=True)
# Get request commentssd.get_request_comments(issue_id_or_key)
# Get request commentsd.get_request_comment_by_id(issue_id_or_key, comment_id)
2.5.4 Manage a Participants
# Get request participantssd.get_request_participants(issue_id_or_key, start=0, limit=50)
# Add request participants# The calling user must have permission to manage participants for this customer→˓requestsd.add_request_participants(issue_id_or_key, users_list)
# Remove request participants# The calling user must have permission to manage participants for this customer→˓requestsd.remove_request_participants(issue_id_or_key, users_list)
2.5.5 Transitions
EXPERIMENTAL (may change without notice)
# Get customer transitions. A list of transitions that customers can perform on the→˓requestsd.get_customer_transitions(issue_id_or_key)
# Perform transition. Optional argument comment (string), default is Nonesd.perform_transition(issue_id_or_key, transition_id, comment=None)
2.5.6 Manage the Organizations
EXPERIMENTAL (may change without notice)
2.5. Jira Service Desk module 25
Atlassian Python API Documentation, Release 1.15.3
# Get a list of organizations in the JIRA instance# If the user is not an agent, the resource returns a list of organizations the user→˓is a member of# If service_desk_id is None, request returns all organizations# In service_desk_id is ID, request returns organizations from given Service Desk IDsd.get_organisations(service_desk_id=None, start=0, limit=50)
# Get an organization for a given organization IDsd.get_organization(organization_id)
# Get all the users of a specified organizationsd.get_users_in_organization(organization_id, start=0, limit=50)
# Create organizationsd.create_organization(name)
# Add an organization to a servicedesk for a given servicedesk ID (str) and→˓organization ID (int)sd.add_organization(service_desk_id, organization_id)
# Remove an organization from a servicedesk for a given servicedesk ID (str) and→˓organization ID (int)sd.remove_organization(service_desk_id, organization_id)
# Delete organizationsd.delete_organization(organization_id)
# Add users to organizationsd.add_users_to_organization(organization_id, users_list)
# Remove users from organizationsd.remove_users_from_organization(organization_id, users_list)
2.5.7 Attachment actions
EXPERIMENTAL (may change without notice)
# Create attachment (only single file) as a comment# You can choose type of attachment. public=True is Public attachment, public=False→˓is Internal attachment# Customers can only create public attachments# An additional comment may be provided which will be prepended to the attachmentssd.create_attachment(service_desk_id, issue_id_or_key, filename, public=True,→˓comment=None)
# Create temporary attachment, which can later be converted into permanent attachmentsd.attach_temporary_file(service_desk_id, filename)
# Add temporary attachment that were created using attach_temporary_file function to→˓a customer requestsd.add_attachment(issue_id_or_key, temp_attachment_id, public=True, comment=None)
26 Chapter 2. Key/Cert Based authentication
Atlassian Python API Documentation, Release 1.15.3
2.5.8 SLA actions
# Get the SLA information for a customer request for a given request ID or key# IMPORTANT: The calling user must be an agentsd.get_sla(issue_id_or_key, start=0, limit=50)
# Get the SLA information for a customer request for a given request ID or key and→˓SLA metric ID# IMPORTANT: The calling user must be an agentsd.get_sla_by_id(issue_id_or_key, sla_id)
2.5.9 Approvals
# Get all approvals on a request, for a given request ID/Keysd.get_approvals(issue_id_or_key, start=0, limit=50)
# Get an approval for a given approval IDsd.get_approval_by_id(issue_id_or_key, approval_id)
# Answer a pending approvalsd.answer_approval(issue_id_or_key, approval_id, decision)
2.5.10 Queues
# Get queue settings on projectsd.get_queue_settings(project_key)
EXPERIMENTAL (may change without notice)
# Returns a page of queues defined inside a service desk, for a given service desk ID.# The returned queues will include an issue count for each queue (represented in→˓issueCount field)# if the query param includeCount is set to true (defaults to false).# Permissions: The calling user must be an agent of the given service desk.sd.get_queues(service_desk_id, include_count=False, start=0, limit=50)
# Returns a page of issues inside a queue for a given queue ID.# Only fields that the queue is configured to show are returned.# For example, if a queue is configured to show only Description and Due Date,# then only those two fields are returned for each issue in the queue.# Permissions: The calling user must have permission to view the requested queue,# i.e. they must be an agent of the service desk that the queue belongs to.sd.get_issues_in_queue(service_desk_id, queue_id, start=0, limit=50)
2.5.11 Add customers to given Service Desk
EXPERIMENTAL (may change without notice)
# Adds one or more existing customers to the given service desk.# If you need to create a customer, see Create customer method.# Administer project permission is required, or agents if public signups
(continues on next page)
2.5. Jira Service Desk module 27
Atlassian Python API Documentation, Release 1.15.3
(continued from previous page)
# and invites are enabled for the Service Desk project.sd.add_customers(service_desk_id, list_of_usernames)
28 Chapter 2. Key/Cert Based authentication