@@ -496,34 +496,67 @@ Conditions-Reviewers management
496496 Bitbucket Cloud
497497---------------
498498
499+ Bitbucket Cloud and Bitbucket Server/Data Center have different REST API
500+ models. Use :class: `atlassian.bitbucket.cloud.Cloud ` for Cloud: it starts from
501+ ``workspaces `` and then navigates to repositories. Use ``Bitbucket `` or
502+ :class: `atlassian.bitbucket.server.Server ` for Server/Data Center project
503+ endpoints. Do not pass a Cloud URL to the legacy Server/Data Center methods.
504+
505+ Use an Atlassian account email and a scoped Bitbucket API token with the
506+ required repository and workspace permissions. The client uses HTTP Basic
507+ authentication automatically. App passwords were retired by Bitbucket Cloud in
508+ July 2026, so new integrations must use API tokens.
509+
510+ .. code-block :: python
511+
512+ import os
513+
514+ from atlassian.bitbucket import Cloud
515+
516+ cloud = Cloud(
517+ username = os.environ[" ATLASSIAN_EMAIL" ],
518+ password = os.environ[" BITBUCKET_API_TOKEN" ],
519+ )
520+
521+ # /2.0/user/workspaces is the supported listing route. ``each()`` resolves
522+ # each entry and yields full workspace objects.
523+ for workspace in cloud.workspaces.each():
524+ print (workspace.slug)
525+
526+ # Restrict the list to workspaces administered by the authenticated user.
527+ admin_workspaces = list (cloud.workspaces.each(administrator = True ))
528+
529+ repository = cloud.workspaces.get(" workspace-slug" ).repositories.get(" repository-slug" )
530+ print (repository.name)
531+
499532 .. code-block :: python
500533
501- # Get a list of workplaces:
534+ # Get a list of workspaces.
502535 cloud.workspaces.each()
503536
504- # Get a single workplace by workplace slug
505- workplace = cloud.workspaces.get(workspace_slug)
537+ # Get a single workspace by workspace slug.
538+ workspace = cloud.workspaces.get(workspace_slug)
506539
507540 # Get a list of permissions in a workspace (this may not work depending on the size of your workspace)
508- workplace .permissions.each():
541+ workspace .permissions.each()
509542
510543 # Get a list of repository permissions in a workspace (this may not work depending on the size of your workspace)
511- workplace .permissions.repositories():
544+ workspace .permissions.repositories()
512545
513546 # Get a single repository permissions in a workspace
514- workplace .permissions.repositories(repo_slug):
547+ workspace .permissions.repositories(repo_slug)
515548
516549 # Get a list of projects in a workspace
517- workplace .projects.each():
550+ workspace .projects.each()
518551
519- # Get a single project from a workplace by project key
520- project = workplace .projects.get(project_key)
552+ # Get a single project from a workspace by project key
553+ project = workspace .projects.get(project_key)
521554
522555 # Get a list of repos from a project
523- project.repositories.each():
556+ project.repositories.each()
524557
525558 # Get a repository
526- repository = workplace .repositories.get(repository_slug)
559+ repository = workspace .repositories.get(repository_slug)
527560
528561 # Read raw bytes from a file at a branch, tag, or commit SHA
529562 readme = repository.get_source_file(" main" , " README.md" )
@@ -532,13 +565,13 @@ Bitbucket Cloud
532565 source_entries = repository.get_source_directory(" main" , " src" )[" values" ]
533566
534567 # Get a list of deployment environments from a repository
535- repository.deployment_environments.each():
568+ repository.deployment_environments.each()
536569
537570 # Get a single deployment environment from a repository by deployment environment key
538571 deployment_environment = repository.deployment_environments.get(deployment_environment_key)
539572
540573 # Get a list of deployment environment variables from a deployment environment
541- deployment_environment_variables = deployment_environment.deployment_environment_variables.each():
574+ deployment_environment_variables = deployment_environment.deployment_environment_variables.each()
542575
543576 # Create a new deployment environment variable with a name of 'KEY', value of 'VALUE' and is not secured.
544577 new_deployment_environment_variable = deployment_environment.deployment_environment_variables.create(" KEY" , " VALUE" , False )
@@ -553,13 +586,13 @@ Bitbucket Cloud
553586 updated_deployment_environment_variable.delete()
554587
555588 # Get a list of group permissions from a repository
556- repository.group_permissions.each():
589+ repository.group_permissions.each()
557590
558591 # Get a single group permission from a repository by group slug
559592 repository.group_permissions.get(group_slug)
560593
561594 # Get a list of repository variables from a repository
562- repository.repository_variables.each():
595+ repository.repository_variables.each()
563596
564597 # Get a single repository variable from a repository by repository variable key
565598 repository_variable = repository.repository_variables.get(repository_variable_key)
@@ -577,7 +610,7 @@ Bitbucket Cloud
577610 repository_variable.delete()
578611
579612 # Get a list of hooks from a repository
580- repository.hooks.each():
613+ repository.hooks.each()
581614
582615 # Create a hook for a repository
583616 hook = repo.hooks.create(url = " endpoint-url" , description = " description" , active = True , events = [" a-repository-event" ])
@@ -592,11 +625,11 @@ Bitbucket Cloud
592625 hook.delete()
593626
594627 # Get a list of workspace members
595- workplace .members.each()
628+ workspace .members.each()
596629
597630 # Get a specific workspace member
598- workplace .members.get(" a-user-account-id" )
599- workplace .members.get(" {a-user-uuid}" )
631+ workspace .members.get(" a-user-account-id" )
632+ workspace .members.get(" {a-user-uuid}" )
600633
601634 Pipelines management
602635--------------------
0 commit comments