### Install and Connect with Atlassian Python API Source: https://atlassian-python-api.readthedocs.io/_sources/index Installs the atlassian-python-api package using pip and demonstrates how to establish connections to Jira, Confluence, Crowd, Bitbucket, Service Desk, and Xray using basic username and password authentication. This is the most common way to start using the API. ```python pip install atlassian-python-api ``` ```python from atlassian import Jira from atlassian import Confluence from atlassian import Crowd from atlassian import Bitbucket from atlassian import ServiceDesk from atlassian import Xray jira = Jira( url='http://localhost:8080', username='admin', password='admin') confluence = Confluence( url='http://localhost:8090', username='admin', password='admin') crowd = Crowd( url='http://localhost:4990', username='app-name', password='app-password' ) bitbucket = Bitbucket( url='http://localhost:7990', username='admin', password='admin') service_desk = ServiceDesk( url='http://localhost:8080', username='admin', password='admin') xray = Xray( url='http://localhost:8080', username='admin', password='admin') ``` -------------------------------- ### Python: Connect to Atlassian Services with Kerberos Source: https://atlassian-python-api.readthedocs.io/index Connects to Atlassian services using Kerberos authentication. Requires the `kerberos` extra to be installed. This method is suitable for environments with existing Kerberos infrastructure. ```python jira = Jira( url='http://localhost:8080', kerberos={}) confluence = Confluence( url='http://localhost:8090', kerberos={}) bitbucket = Bitbucket( url='http://localhost:7990', kerberos={}) service_desk = ServiceDesk( url='http://localhost:8080', kerberos={}) xray = Xray( url='http://localhost:8080', kerberos={}) ``` -------------------------------- ### Initialize Cloud Admin Module in Python Source: https://atlassian-python-api.readthedocs.io/index Demonstrates how to initialize the Cloud Admin module for managing Atlassian Cloud organizations and users using an admin API key. This requires the `atlassian-python-api` library. ```python from atlassian import CloudAdminOrgs, CloudAdminUsers cloud_admin_orgs = CloudAdminOrgs( admin-api-key=admin-api-key) cloud_admin_users = CloudAdminUsers( admin-api-key=admin-api-key) ``` -------------------------------- ### Python: Connect to Atlassian Services with Username/Password Source: https://atlassian-python-api.readthedocs.io/index Establishes connections to various Atlassian services (Jira, Confluence, Crowd, Bitbucket, Service Desk, Xray) using provided URLs, usernames, and passwords. This is a fundamental connection method for self-hosted instances. ```python from atlassian import Jira from atlassian import Confluence from atlassian import Crowd from atlassian import Bitbucket from atlassian import ServiceDesk from atlassian import Xray jira = Jira( url='http://localhost:8080', username='admin', password='admin') confluence = Confluence( url='http://localhost:8090', username='admin', password='admin') crowd = Crowd( url='http://localhost:4990', username='app-name', password='app-password' ) bitbucket = Bitbucket( url='http://localhost:7990', username='admin', password='admin') service_desk = ServiceDesk( url='http://localhost:8080', username='admin', password='admin') xray = Xray( url='http://localhost:8080', username='admin', password='admin') ``` -------------------------------- ### Python: Connect to Atlassian Services with OAuth Source: https://atlassian-python-api.readthedocs.io/index Connects to Atlassian services using OAuth authentication. Requires a dictionary containing access token, secret, consumer key, and certificate. This method is suitable for applications requiring delegated access. ```python oauth_dict = { 'access_token': 'access_token', 'access_token_secret': 'access_token_secret', 'consumer_key': 'consumer_key', 'key_cert': 'key_cert'} 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) xray = Xray( url='http://localhost:8080', oauth=oauth_dict) ``` -------------------------------- ### List Repository Pipelines Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Get a list of pipeline results for a repository. Supports pagination and sorting by creation date. ```python # Get first ten Pipelines results for repository r.pipelines.each() # Get twenty last Pipelines results for repository r.pipelines.each(sort="-created_on", pagelen=20) ``` -------------------------------- ### Retrieve All Pages from a Space Source: https://atlassian-python-api.readthedocs.io/_sources/confluence Code examples for fetching all pages, blog posts, or drafts from a specific Confluence space. It includes options for filtering by status, expanding content properties, and handling pagination using start and limit parameters. A generator version for efficient iteration is also provided. ```python # 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 all pages from space as Generator confluence.get_all_pages_from_space_as_generator(space, start=0, limit=100, status=None, expand=None, content_type='page') # Get list of pages from trash confluence.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 Confluence confluence.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 Confluence confluence.get_all_draft_pages_from_space_through_cql(space, start=0, limit=500, status='draft') # Get all pages by label confluence.get_all_pages_by_label(label, start=0, limit=50, expand=None) ``` -------------------------------- ### Python: Connect to Atlassian Cloud Services (Jira, Confluence, Service Desk) Source: https://atlassian-python-api.readthedocs.io/index Authenticates to Atlassian Cloud services like Jira, Confluence, and Service Desk using an API token obtained from Atlassian's security settings. Requires `cloud=True` and specific cloud URLs. ```python # Obtain an API token from: https://id.atlassian.com/manage-profile/security/api-tokens # You cannot log-in with your regular password to these services. jira = Jira( url='https://your-domain.atlassian.net', username=atlassian_username, password=atlassian_api_token, cloud=True) confluence = Confluence( url='https://your-domain.atlassian.net', username=atlassian_username, password=atlassian_api_token, cloud=True) service_desk = ServiceDesk( url='https://your-domain.atlassian.net', username=atlassian_username, password=atlassian_api_token, cloud=True) ``` -------------------------------- ### Retrieve Confluence Space Information using Python Source: https://atlassian-python-api.readthedocs.io/_sources/confluence This section provides Python code examples for fetching detailed information about Confluence spaces. It covers retrieving all spaces with optional expansion of metadata, getting a specific space by its key, accessing space content, and retrieving space permissions and export URLs. The `expand` parameter allows for detailed retrieval of information like descriptions and homepages. ```python # Get all spaces with provided limit # additional info, e.g. metadata, icon, description, homepage confluence.get_all_spaces(start=0, limit=500, expand=None) # Get information about a space through space key confluence.get_space(space_key, expand='description.plain,homepage') # Get space content (configuring by the expand property) confluence.get_space_content(space_key, depth="all", start=0, limit=500, content_type=None, expand="body.storage") # Get Space permissions set based on json-rpc call confluence.get_space_permissions(space_key) # Get Space export download url confluence.get_space_export(space_key, export_type) ``` -------------------------------- ### Manage Workspace Members with Python Source: https://atlassian-python-api.readthedocs.io/bitbucket Examples for retrieving a list of workspace members and fetching a specific member using their account ID or UUID. ```python workplace.members.each() workplace.members.get("a-user-account-id") workplace.members.get("{a-user-uuid}") ``` -------------------------------- ### Get Specific Deployment Environment Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Retrieve a single deployment environment from a repository using its unique key. This allows for detailed management of specific environments. ```python # Get a single deployment environment from a repository by deployment environment key deployment_environment = repository.deployment_environments.get(deployment_environment_key) ``` -------------------------------- ### Get Pipeline Steps Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Retrieve a list of all steps within a specific pipeline, identified by its UUID. This provides insight into the pipeline's execution flow. ```python # Get steps of Pipeline specified by UUID pl.steps() ``` -------------------------------- ### Get Jira Health Checks (On-Prem Edition) Source: https://atlassian-python-api.readthedocs.io/jira Retrieves the health status of the Jira instance for on-premises installations. ```python jira.health_check() ``` -------------------------------- ### Manage Repository Hooks with Python Source: https://atlassian-python-api.readthedocs.io/bitbucket Demonstrates how to create, retrieve, update, and delete hooks for a repository. This includes setting the URL, description, active status, and events. ```python hook = repo.hooks.create(url="endpoint-url", description="description", active=True, events=["a-repository-event"]) hook = repo.hooks.get("a-webhook-id") hook.update(url="endpoint-url", description="description", active=True, events=["a-repository-event"]) hook.delete() ``` -------------------------------- ### Manage BitBucket Projects with Python API Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket This snippet demonstrates how to manage Bitbucket projects using the atlassian-python-api library. It covers listing projects, repos, retrieving project information, creating new projects, managing users and groups with permissions, and project summaries. Ensure the 'bitbucket' object is initialized and authenticated. ```python # 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) ``` -------------------------------- ### Get Bitbucket Users Source: https://atlassian-python-api.readthedocs.io/bitbucket Retrieves a list of users from Bitbucket. The `user_filter` parameter can be used to specify particular users. It supports pagination with `limit` and `start` parameters. ```python bitbucket.get_users(user_filter="username", limit=25, start=0) ``` -------------------------------- ### GET All Project Issues Source: https://atlassian-python-api.readthedocs.io/_sources/jira Retrieves all issues within a project, with options to specify fields to return, start index, and maximum number of results. ```APIDOC ## GET All Project Issues ### Description Retrieves all issues for a project. ### Method GET ### Endpoint `/project/{project}/issues` ### Parameters #### Path Parameters - **project** (string) - Required - The project key. #### Query Parameters - **fields** (string) - Optional - Fields to return (default: '*all'). - **start** (integer) - Optional - Starting index. - **limit** (integer) - Optional - Maximum number of results. ### Request Example ``` None ``` ### Response #### Success Response (200) - **issues** (array) - A list of issues. #### Response Example ```json [ { "key": "PROJECT-1", "summary": "First issue" }, { "key": "PROJECT-2", "summary": "Second issue" } ] ``` ``` -------------------------------- ### Manage Bitbucket Repositories Source: https://atlassian-python-api.readthedocs.io/bitbucket Provides functions to list, create, and manage repositories within a Bitbucket project. Creating a repository requires `PROJECT_ADMIN` permission and specifies the repository name and SCM ID. The authenticated user needs `PROJECT_ADMIN` permission for the context project. ```python # Get repositories list from project bitbucket.repo_list(project_key, limit=25) ``` ```python # 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) ``` -------------------------------- ### List Repository Deployment Environments Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Retrieve a list of all deployment environments configured for a repository. This is useful for managing deployment configurations. ```python # Get a list of deployment environments from a repository repository.deployment_environments.each() ``` -------------------------------- ### Get Attachment History Source: https://atlassian-python-api.readthedocs.io/confluence Retrieves the version history for a specific attachment. Requires the attachment ID. Optional parameters include limit and start for pagination. ```python confluence.get_attachment_history(attachment_id, limit=200, start=0) ``` -------------------------------- ### Confluence Module Initialization Source: https://atlassian-python-api.readthedocs.io/_sources/confluence Illustrates how to initialize ConfluenceCloud and ConfluenceServer objects. ```APIDOC ## Confluence Module Initialization ### Description Initializes the Confluence API client for either Cloud or Server environments. ### Method Initialization ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from atlassian.confluence import ConfluenceCloud, ConfluenceServer # For Confluence Cloud confluence_cloud = ConfluenceCloud( url="https://your-domain.atlassian.net", token="your-api-token" ) # For Confluence Server confluence_server = ConfluenceServer( url="https://your-confluence-server.com", username="your-username", password="your-password" ) ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Get All Confluence Spaces Source: https://atlassian-python-api.readthedocs.io/confluence Retrieves a list of all spaces in Confluence. Optional parameters for pagination (start, limit) and expansion of additional information (metadata, icon, description, homepage). ```python confluence.get_all_spaces(start=0, limit=500, expand=None) ``` -------------------------------- ### Create Repository Hook Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Create a new hook for a repository. Requires endpoint URL, description, active status, and a list of events. ```python # Create a hook for a repository hook = repo.hooks.create(url="endpoint-url", description="description", active=True, events=["a-repository-event"]) ``` -------------------------------- ### Get Jira Field Metadata Source: https://atlassian-python-api.readthedocs.io/jira Retrieves metadata for specific fields within a project and issue type. Allows for paginated results using 'start' and 'limit'. This helps in understanding field requirements for issue creation. ```python jira.issue_createmeta_fieldtypes(project, issue_type_id, start=None, limit=None) ``` -------------------------------- ### Get Jira Issue Types Metadata Source: https://atlassian-python-api.readthedocs.io/jira Fetches a list of issue types available for creation within a specific project. Supports pagination with 'start' and 'limit' parameters. Useful for understanding available issue types before issue creation. ```python jira.issue_createmeta_issuetypes(project, start=None, limit=None) ``` -------------------------------- ### Initialize Confluence Cloud and Server Clients Source: https://atlassian-python-api.readthedocs.io/_sources/confluence Demonstrates how to instantiate Confluence clients for both Cloud and Server platforms using their respective authentication methods. The Cloud version uses an API token, while the Server version uses username and password. ```python from atlassian.confluence import ConfluenceCloud, ConfluenceServer # For Confluence Cloud confluence_cloud = ConfluenceCloud( url="https://your-domain.atlassian.net", token="your-api-token" ) # For Confluence Server confluence_server = ConfluenceServer( url="https://your-confluence-server.com", username="your-username", password="your-password" ) ``` -------------------------------- ### Bitbucket Cloud Deployment Environments Source: https://atlassian-python-api.readthedocs.io/bitbucket APIs for managing and retrieving information about deployment environments within a Bitbucket Cloud repository. ```APIDOC ## Bitbucket Cloud Deployment Environments ### Get a list of deployment environments from a repository - **Description**: Retrieves a list of all deployment environments for a repository. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: None. ### Get a single deployment environment from a repository by deployment environment key - **Description**: Retrieves a specific deployment environment using its key. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: - `deployment_environment_key` (string) - Required - The key of the deployment environment. ``` -------------------------------- ### Jira Service Desk: Get Approvals Source: https://atlassian-python-api.readthedocs.io/service_desk Retrieves all approvals for a given request ID or key, with options to specify the start index and limit for pagination. It also allows fetching a specific approval by its ID. ```python sd.get_approvals(issue_id_or_key, start=0, limit=50) sd.get_approval_by_id(issue_id_or_key, approval_id) ``` -------------------------------- ### Python: Connect to Bitbucket Cloud with OAuth 2.0 Source: https://atlassian-python-api.readthedocs.io/index Authenticates to Bitbucket Cloud using OAuth 2.0. The `oauth2_dict` must contain `client_id` and a `token` dictionary with at least `access_token` and `token_type`. This is for cloud-based Bitbucket instances. ```python from atlassian.bitbucket import Cloud # token is a dictionary and must at least contain "access_token" # and "token_type". oauth2_dict = { "client_id": client_id, "token": token} bitbucket_cloud = Cloud( oauth2=oauth2_dict) # For a detailed example see bitbucket_oauth2.py in # examples/bitbucket ``` -------------------------------- ### Upload Jira Plugin Source: https://atlassian-python-api.readthedocs.io/jira Uploads a Jira plugin to the Jira instance from a specified file path. ```python upload_plugin(plugin_path) ``` -------------------------------- ### Manage Bitbucket Branches Source: https://atlassian-python-api.readthedocs.io/bitbucket Enables operations related to branches within a Bitbucket repository, including getting branches, creating new branches from a specified starting point, and deleting branches. Creating branches requires `REPO_WRITE` permission, while deleting requires `REPO_WRITE` permission. ```python # Get branches from repo bitbucket.get_branches(project, repository, filter='', limit=99999, details=True, boost_matches=False) ``` ```python # 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) ``` ```python # Delete branch from related repo bitbucket.delete_branch(project, repository, name, end_point=None) ``` -------------------------------- ### Bitbucket Cloud Deployment Environments Management Source: https://atlassian-python-api.readthedocs.io/bitbucket Functions to manage deployment environments and their variables within a Bitbucket Cloud repository. This includes listing and creating deployment environment variables. ```python # Get a list of deployment environments from a repository repository.deployment_environments.each(): # Get a single deployment environment from a repository by deployment environment key deployment_environment = repository.deployment_environments.get(deployment_environment_key) # Get a list of deployment environment variables from a deployment environment deployment_environment_variables = deployment_environment.deployment_environment_variables.each(): # Create a new deployment environment variable with a name of 'KEY', value of 'VALUE' and is not secured. new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create("KEY", "VALUE", False) ``` -------------------------------- ### Transitions API Source: https://atlassian-python-api.readthedocs.io/service_desk Manage transitions for customer requests, including viewing available transitions and performing them. ```APIDOC ## Transitions API ### Description APIs for managing transitions on customer requests. You can view the transitions that customers are allowed to perform on a request and execute specific transitions. Note that these functions are experimental. ### Method GET, POST ### Endpoint `/jira/servicedesk/request/{issue_id_or_key}/transitions` (Conceptual endpoint for module functions) ### Functions - **`sd.get_customer_transitions(issue_id_or_key)`**: Gets a list of transitions that customers can perform on a specific request. - **`sd.perform_transition(issue_id_or_key, transition_id, comment=None)`**: Performs a specified transition on a customer request. An optional comment can be provided. ### Request Body Example (for `perform_transition`) ```json { "issue_id_or_key": "PROJ-123", "transition_id": "456", "comment": "Request completed successfully." } ``` ``` -------------------------------- ### List Repository Hooks Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket Retrieve a list of all hooks configured for a repository. Hooks are used for event-driven actions. ```python # Get a list of hooks from a repository repository.hooks.each() ``` -------------------------------- ### Python: Connect to Atlassian Services using Cookie File Source: https://atlassian-python-api.readthedocs.io/index Establishes connections to Atlassian services by parsing a cookie file. The `utils.parse_cookie_file` function is used to load cookies, which can then be passed to the service constructors. This is useful for reusing existing browser session cookies. ```python from atlassian import utils cookie_dict = utils.parse_cookie_file("cookie.txt") jira = Jira( url='http://localhost:8080', cookies=cookie_dict) confluence = Confluence( url='http://localhost:8090', cookies=cookie_dict) bitbucket = Bitbucket( url='http://localhost:7990', cookies=cookie_dict) service_desk = ServiceDesk( url='http://localhost:8080', cookies=cookie_dict) xray = Xray( url='http://localhost:8080', cookies=cookie_dict) ``` -------------------------------- ### Python: Connect to Jira/Confluence with Personal Access Token Source: https://atlassian-python-api.readthedocs.io/index Connects to Jira and Confluence (server/data center editions prior to 7.9) using a Personal Access Token. This method is simpler than username/password for certain self-hosted scenarios. Cloud instances have different token requirements. ```python jira = Jira( url='https://your-jira-instance.company.com', token=jira_access_token ) confluence = Confluence( url='https://your-confluence-instance.company.com', token=confluence_access_token ) ``` -------------------------------- ### Bitbucket Cloud Deployment Environment Variables Source: https://atlassian-python-api.readthedocs.io/bitbucket APIs for managing and retrieving deployment environment variables. ```APIDOC ## Bitbucket Cloud Deployment Environment Variables ### Get a list of deployment environment variables - **Description**: Retrieves a list of deployment environment variables for a deployment environment. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: None. ### Create a new deployment environment variable - **Description**: Creates a new deployment environment variable. - **Method**: Not specified (likely POST). - **Endpoint**: Not specified. - **Parameters**: - `name` (string) - Required - The name of the variable (e.g., 'KEY'). - `value` (string) - Required - The value of the variable (e.g., 'VALUE'). - `is_secured` (boolean) - Required - Whether the variable is secured (False for not secured). ``` -------------------------------- ### Manage Repository Variables with Python Source: https://atlassian-python-api.readthedocs.io/bitbucket Examples for creating, updating, retrieving, and deleting repository variables. These operations involve specifying keys, values, and security settings. ```python updated_deployment_environment_variable = new_deployment_environment_variable.update(key="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_KEY") updated_deployment_environment_variable = new_deployment_environment_variable.update(value="UPDATED_DEPLOYMENT_ENVIRONMENT_VARIABLE_VALUE") updated_deployment_environment_variable.delete() repository_variable = repository.repository_variables.get(repository_variable_key) updated_repository_variable = repository_variable.update(key="UPDATED_REPOSITORY_VARIABLE_KEY") updated_repository_variable = repository_variable.update(value="UPDATED_REPOSITORY_VARIABLE_VALUE") repository_variable.delete() new_repository_variable = repository.repository_variables.create("KEY", "VALUE", False) ``` -------------------------------- ### Manage Bitbucket Groups and Admins with Python API Source: https://atlassian-python-api.readthedocs.io/bitbucket This snippet shows how to manage groups and administrators within Bitbucket using the Python API. It includes functions to retrieve lists of groups (optionally filtered), get members of a specific group, and retrieve all project administrators. Ensure the `bitbucket` library is installed and configured. ```python # 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() ``` -------------------------------- ### Customer Management Source: https://atlassian-python-api.readthedocs.io/service_desk Endpoints for creating new customers and managing their information within Jira Service Desk. ```APIDOC ## Customer Management API ### Description Endpoints for creating new customers and managing their information within Jira Service Desk. Note that the `create_customer` function is experimental and may change. ### Method POST (for `create_customer`) ### Endpoint `/jira/servicedesk/customer` (Conceptual endpoint for module functions) ### Functions - **`sd.create_customer(full_name, email)`**: EXPERIMENTAL. Creates a new customer with the provided full name and email. ### Request Body (for `create_customer`) ```json { "full_name": "string", "email": "string" } ``` ### Response (for `create_customer`) Details of the newly created customer. ``` -------------------------------- ### Python: Connect to Bitbucket Cloud with Username/Password or App Password Source: https://atlassian-python-api.readthedocs.io/index Authenticates to Bitbucket Cloud using either an email/username with a regular password or a username with an App Password. App Passwords are recommended for security and can be generated from Bitbucket account settings. Note that login with E-Mail and App password is not supported. ```python # Log-in with E-Mail / Username and regular password # or with Username and App password. # Get App password from https://bitbucket.org/account/settings/app-passwords/. # Log-in with E-Mail and App password not possible. # Username can be found here: https://bitbucket.org/account/settings/ from atlassian.bitbucket import Cloud bitbucket = Cloud( username=bitbucket_email, password=bitbucket_password, cloud=True) bitbucket_app_pw = Cloud( username=bitbucket_username, password=bitbucket_app_password, cloud=True) ``` -------------------------------- ### Request Actions Source: https://atlassian-python-api.readthedocs.io/service_desk Manage customer requests, including creation, retrieval, status checking, and commenting. ```APIDOC ## Request Actions API ### Description Provides a comprehensive set of functionalities for managing customer requests within Jira Service Desk, including creating requests, retrieving them by ID, fetching all requests for the current user, checking request status, and managing comments. ### Method POST, GET ### Endpoint `/jira/servicedesk/request` (Conceptual endpoint for module functions) ### Functions - **`sd.create_customer_request(service_desk_id, request_type_id, values_dict, raise_on_behalf_of=None, request_participants=None)`**: Creates a new customer request. - **`sd.get_customer_request(issue_id_or_key)`**: Retrieves a customer request by its ID or key. - **`sd.get_my_customer_requests()`**: Retrieves all customer requests associated with the current user. - **`sd.get_customer_request_status(issue_id_or_key)`**: Gets the current status of a customer request. - **`sd.create_request_comment(issue_id_or_key, body, public=True)`**: Creates a comment on a customer request. The `public` parameter determines visibility (default is True). - **`sd.get_request_comments(issue_id_or_key, start=0, limit=50, public=True, internal=True)`**: Retrieves comments for a customer request, with options for pagination and filtering by visibility. - **`sd.get_request_comment_by_id(issue_id_or_key, comment_id)`**: Retrieves a specific comment on a customer request by its ID. ### Request Body Example (for `create_customer_request`) ```json { "service_desk_id": "1", "request_type_id": "abc-123", "values_dict": { "summary": "My request summary", "description": "Detailed description of the request." } } ``` ### Response Example (for `get_customer_request`) ```json { "id": "10001", "key": "PROJ-123", "summary": "Example Request", "status": "Open" } ``` ``` -------------------------------- ### Jira Service Desk: Add Customers Source: https://atlassian-python-api.readthedocs.io/service_desk Adds one or more existing customers to a specified service desk. Requires appropriate project administration permissions or agent status if public signups are enabled. ```python sd.add_customers(service_desk_id, list_of_usernames) ``` -------------------------------- ### Retrieve Bitbucket Commit and File Information with Python Source: https://atlassian-python-api.readthedocs.io/_sources/bitbucket This snippet shows how to retrieve commit and file-related information from a Bitbucket repository using Python. It includes fetching diffs between commits, getting a list of commits, retrieving a changelog between two references, and getting the raw content of a file. ```python # 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. ``` -------------------------------- ### Project Conditions Management Source: https://atlassian-python-api.readthedocs.io/bitbucket APIs for managing review conditions and associated reviewers at the project level. ```APIDOC ## Project Conditions Management ### Get all project conditions - **Description**: Retrieves all review conditions for a specific project, including reviewers. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: - `project_key` (string) - Required - The key of the project. ### Get a project condition - **Description**: Retrieves a specific review condition for a project, including reviewers. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: - `project_key` (string) - Required - The key of the project. - `id_condition` (string/integer) - Required - The ID of the condition. ### Create project condition - **Description**: Creates a new review condition with associated reviewers for a project. - **Method**: Not specified (likely POST). - **Endpoint**: Not specified. - **Parameters**: - `project_key` (string) - Required - The key of the project. - `condition` (object) - Required - The condition object, including reviewers. Example: `{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}` ### Update a project condition - **Description**: Updates an existing review condition for a project. - **Method**: Not specified (likely PUT). - **Endpoint**: Not specified. - **Parameters**: - `project_key` (string) - Required - The key of the project. - `condition` (object) - Required - The updated condition object. Example: `{"sourceMatcher":{"id":"any","type":{"id":"ANY_REF"}},"targetMatcher":{"id":"refs/heads/master","type":{"id":"BRANCH"}},"reviewers":[{"id": 12}],"requiredApprovals":"0"}` - `id_condition` (string/integer) - Required - The ID of the condition to update. ### Delete a project condition - **Description**: Deletes a review condition from a project. - **Method**: Not specified (likely DELETE). - **Endpoint**: Not specified. - **Parameters**: - `project_key` (string) - Required - The key of the project. - `id_condition` (string/integer) - Required - The ID of the condition to delete. ``` -------------------------------- ### Get Confluence Page Information in Python Source: https://atlassian-python-api.readthedocs.io/confluence Provides Python code snippets for various operations related to retrieving Confluence page information, such as checking existence, getting content by type or ID, and retrieving labels. These functions interact with a Confluence instance via the 'atlassian-python-api' library. ```python # Check page exists # type of the page, 'page' or 'blogpost'. Defaults to 'page' confluence.page_exists(space, title, type=None) # Provide content by type (page, blog, comment) confluence.get_page_child_by_type(page_id, type='page', start=None, limit=None, expand=None) # Provide content id from search result by title and space confluence.get_page_id(space, title) # Provide space key from content id confluence.get_page_space(page_id) # Returns the list of labels on a piece of Content confluence.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] # 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 results confluence.get_page_by_id(page_id, expand=None, status=None, version=None) # The list of labels on a piece of Content confluence.get_page_labels(page_id, prefix=None, start=None, limit=None) # Get draft page by ID confluence.get_draft_page_by_id(page_id, status='draft') # Get all page by label confluence.get_all_pages_by_label(label, start=0, limit=50, expand=None) # 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 all pages from space as Generator confluence.get_all_pages_from_space_as_generator(space, start=0, limit=100, status=None, expand=None, content_type='page') # Get list of pages from trash confluence.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 Confluence confluence.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 Confluence confluence.get_all_draft_pages_from_space_through_cql(space, start=0, limit=500, status='draft') # Info about all restrictions by operation confluence.get_all_restrictions_for_content(content_id) ``` -------------------------------- ### Bitbucket Pipelines Management Source: https://atlassian-python-api.readthedocs.io/bitbucket APIs for managing Bitbucket Pipelines, including retrieving pipeline results, triggering pipelines, and managing pipeline steps. ```APIDOC ## Bitbucket Pipelines API ### Description APIs for managing Bitbucket Pipelines, including retrieving pipeline results, triggering pipelines, and managing pipeline steps. ### Endpoints #### Get most recent Pipelines results for repository - **Method**: GET - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines` - **Description**: Retrieves the most recent pipeline results for a given repository. #### Trigger default Pipeline on the latest revision of the master branch - **Method**: POST - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines` - **Description**: Triggers the default pipeline on the latest revision of the master branch. #### Trigger default Pipeline on the latest revision of the develop branch - **Method**: POST - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines` - **Query Parameters**: - **branch** (string) - Optional - The branch to trigger the pipeline on. - **Description**: Triggers the default pipeline on the latest revision of a specified branch. #### Trigger default Pipeline on a specific revision of the develop branch - **Method**: POST - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines` - **Query Parameters**: - **branch** (string) - Required - The branch to trigger the pipeline on. - **revision** (string) - Required - The specific revision hash to trigger the pipeline on. - **Description**: Triggers the default pipeline on a specific revision of a specified branch. #### Trigger specific Pipeline on a specific revision of the master branch - **Method**: POST - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines` - **Query Parameters**: - **revision** (string) - Required - The specific revision hash to trigger the pipeline on. - **name** (string) - Required - The name of the specific pipeline to trigger. - **Description**: Triggers a specific named pipeline on a specific revision of the master branch. #### Get specific Pipeline by UUID - **Method**: GET - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines/{uuid}` - **Description**: Retrieves details of a specific pipeline identified by its UUID. #### Stop specific Pipeline by UUID - **Method**: POST - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines/{uuid}/stop` - **Description**: Stops a specific pipeline identified by its UUID. #### Get steps of Pipeline specified by UUID - **Method**: GET - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines/{uuid}/steps` - **Description**: Retrieves all steps for a specific pipeline identified by its UUID. #### Get step of Pipeline specified by UUIDs - **Method**: GET - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines/{pipeline_uuid}/steps/{step_uuid}` - **Description**: Retrieves details of a specific step within a pipeline, identified by their UUIDs. #### Get log of step of Pipeline specified by UUIDs - **Method**: GET - **Endpoint**: `/workspace/{workspace}/repositories/{repository}/pipelines/{pipeline_uuid}/steps/{step_uuid}/log` - **Description**: Retrieves the log output for a specific step within a pipeline, identified by their UUIDs. ``` -------------------------------- ### Get Organizations and Managed Accounts (Python) Source: https://atlassian-python-api.readthedocs.io/_sources/cloud_admin This snippet demonstrates how to retrieve a list of organizations and manage accounts within a specific organization using the Atlassian Python API. It includes functions for getting organization details, listing managed accounts, and searching users by various criteria. Ensure the 'cloud_admin_orgs' object is properly initialized. ```python # Returns a list of your organizations cloud_admin_orgs.get_organizations() # Returns information about a single organization by ID cloud_admin_orgs.get_organization(org_id) # Returns a list of accounts managed by the organization cloud_admin_orgs.get_managed_accounts_in_organization(org_id, cursor=None) # Returns a list of accounts in the organization that match the search criteria. cloud_admin_orgs.search_users_in_organization(org_id, account_ids=None, account_types=None,account_statuses=None, name_or_nicknames=None, email_usernames=None, email_domains=None, is_suspended=None, cursor=None, limit=10000, expand=None) ``` -------------------------------- ### Jira Reindexing Source: https://atlassian-python-api.readthedocs.io/jira Manage Jira reindexing operations, including starting a reindex and checking its status. ```APIDOC ## Jira Reindexing ### Description Manages the reindexing process for Jira to ensure data consistency. Supports different reindexing modes. ### Method POST ### Endpoint /rest/api/2/reindex ### Parameters #### Request Body - **indexing_type** (string) - Optional - Specifies the reindexing mode. Options: 'FOREGROUND', 'BACKGROUND', 'BACKGROUND_PREFERRED'. Defaults to 'BACKGROUND_PREFERRED'. - FOREGROUND: Runs a lock/full reindexing. - BACKGROUND: Runs a background reindexing. Returns 409 Conflict if JIRA fails to finish. - BACKGROUND_PREFERRED: Attempts background reindexing, falls back to foreground if index is inconsistent. ### Request Example ```json { "indexing_type": "BACKGROUND_PREFERRED" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the reindexing operation. #### Response Example ```json { "status": "Reindexing started successfully." } ``` ## Reindex Status ### Description Checks the current status of the Jira reindexing process. ### Method GET ### Endpoint /rest/api/2/reindex/status ### Response #### Success Response (200) - **status** (string) - The current status of the reindexing. #### Response Example ```json { "status": "NOT_RUNNING" } ``` ``` -------------------------------- ### Bitbucket Cloud Workspaces Source: https://atlassian-python-api.readthedocs.io/bitbucket APIs for managing and retrieving information about Bitbucket Cloud workspaces. ```APIDOC ## Bitbucket Cloud Workspaces ### Get a list of workplaces - **Description**: Retrieves a list of all accessible workplaces. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: None. ### Get a single workplace by workspace slug - **Description**: Retrieves a specific workplace using its slug. - **Method**: Not specified (likely GET). - **Endpoint**: Not specified. - **Parameters**: - `workspace_slug` (string) - Required - The slug of the workplace. ``` -------------------------------- ### GET Issue Deleted Source: https://atlassian-python-api.readthedocs.io/_sources/jira Checks if a JIRA issue with the specified key has been deleted. ```APIDOC ## GET Issue Deleted ### Description Checks if an issue has been deleted. ### Method GET ### Endpoint `/issue/{issue_key}/deleted` ### Parameters #### Path Parameters - **issue_key** (string) - Required - The issue key. ### Request Example ``` None ``` ### Response #### Success Response (200) - **deleted** (boolean) - True if the issue has been deleted, false otherwise. #### Response Example ```json { "deleted": false } ``` ``` -------------------------------- ### Build and Deployment Queue API Source: https://atlassian-python-api.readthedocs.io/bamboo Endpoints for retrieving information about build and deployment queues. ```APIDOC ## Get build queue ### Description Retrieves the current build queue, with an option to expand queued builds. ### Method GET ### Endpoint /rest/api/builds/queue ### Parameters #### Query Parameters - **expand** (string) - Optional - Specifies related data to expand, e.g., 'queuedBuilds'. ## Get deployment queue ### Description Retrieves the current deployment queue, with an option to expand queued deployments. ### Method GET ### Endpoint /rest/api/deployments/queue ### Parameters #### Query Parameters - **expand** (string) - Optional - Specifies related data to expand, e.g., 'queuedDeployments'. ``` -------------------------------- ### GET Issue Exists Source: https://atlassian-python-api.readthedocs.io/_sources/jira Checks if a JIRA issue with the specified key exists. ```APIDOC ## GET Issue Exists ### Description Checks if an issue exists. ### Method GET ### Endpoint `/issue/{issue_key}/exists` ### Parameters #### Path Parameters - **issue_key** (string) - Required - The issue key. ### Request Example ``` None ``` ### Response #### Success Response (200) - **exists** (boolean) - True if the issue exists, false otherwise. #### Response Example ```json { "exists": true } ``` ``` -------------------------------- ### Manage Pipelines with Python Source: https://atlassian-python-api.readthedocs.io/bitbucket Code for interacting with repository pipelines, including fetching lists, triggering pipelines with various options (branch, revision, variables), getting specific pipelines, stopping them, and retrieving step details and logs. ```python r = cloud.workspaces.get(workspace).repositories.get(repository) r.pipelines.each() r.pipelines.each(sort="-created_on", pagelen=20) r.pipelines.trigger() r.pipelines.trigger(branch="develop") r.pipelines.trigger(branch="develop", revision="<40-char hash>") r.pipelines.trigger(revision="<40-char hash>", name="style-check") r.pipelines.trigger(name="style-check", variables=[{ "key": "var-name", "value": "var-value" }]) pl = r.pipelines.get("{7d6c327d-6336-4721-bfeb-c24caf25045c}") pl.stop() pl.steps() s = pl.step("{56d2d8af-6526-4813-a22c-733ec6ecabf3}") s.log() ``` -------------------------------- ### Jira Issue Retrieval Source: https://atlassian-python-api.readthedocs.io/jira Retrieve issues from Jira using a JQL query and get all related fields. ```APIDOC ## Jira Issue Retrieval ### Description Retrieves issues from Jira based on a JQL query and includes all associated fields. ### Method POST ### Endpoint /rest/api/2/search ### Parameters #### Request Body - **jql** (string) - Required - The JQL query to search for issues. ### Request Example ```json { "jql": "project = DEMO AND status NOT IN (Closed, Resolved) ORDER BY issuekey" } ``` ### Response #### Success Response (200) - **issues** (array) - A list of issues matching the JQL query. #### Response Example ```json { "issues": [ { "id": "10001", "key": "DEMO-1", "fields": { ... } } ] } ``` ```