atlassian-python-api
atlassian-python-api copied to clipboard
Bitbcket cloud get
I tested and the user and password works
# coding=utf-8
from atlassian import Jira
from atlassian import Confluence
from atlassian import Bitbucket
from atlassian import ServiceDesk
from atlassian import Xray
from atlassian.bitbucket import Cloud
bitbucket = Cloud(url="https://api.bitbucket.org/", username="xxxx", password="xxxx")
print(bitbucket.all_project_administrators())
But I ahve this error when I try to execute a function:
python.exe .\main2.py Traceback (most recent call last): File "main2.py", line 14, in <module> print(bitbucket.all_project_administrators()) AttributeError: 'Cloud' object has no attribute 'all_project_administrators'
This function is implemented in the Bitbucket object and not in the neww OO interface Cloud. Replace Cloud with Bitbucket and add the kwarg cloud=True.
Thanks @Spacetown I tried it but i have the following error:
`from atlassian import Bitbucket
bitbucket = Bitbucket( url='https://api.bitbucket.org', username=xxxxxx', password='xxxxxx', cloud=True)
data = bitbucket.project_list() print(data)`
python.exe .\main.py <generator object BitbucketBase._get_paged at 0x000001A3901CDA50>
Try putting the request in a list(). That'll make it printable with print.
data = list(bitbucket.project_list())
It is actually not an error. The function just returns a generator object, which you can iterate through. But printing it will just output that it is a generator. The list function converts it to a list, which can be printed well.
@jensvog @Spacetown I tried it but it has a 404. I am using Btbucket Cloud, Is it works in cloud?
`from atlassian import Bitbucket
bitbucket = Bitbucket(
url='https://api.bitbucket.org',
username='xxx',
password='xxxxxq',
cloud=True)
data = list(bitbucket.project_list())
print(data)`
.
python.exe .\main.py
Traceback (most recent call last):
File "C:\projects\zenfolio\bitbucket\main.py", line 9, in <module>
data = list(bitbucket.project_list())
File "C:\Users\Max\AppData\Local\Programs\Python\Python39\lib\site-packages\atlassian\bitbucket\base.py", line 59, in _get_paged
response = self.get(url, trailing=trailing, params=params, data=data, flags=flags, absolute=absolute)
File "C:\Users\Max\AppData\Local\Programs\Python\Python39\lib\site-packages\atlassian\rest_client.py", line 264, in get
response = self.request(
File "C:\Users\Max\AppData\Local\Programs\Python\Python39\lib\site-packages\atlassian\rest_client.py", line 236, in request
self.raise_for_status(response)
File "C:\Users\Max\AppData\Local\Programs\Python\Python39\lib\site-packages\atlassian\rest_client.py", line 386, in raise_for_status
response.raise_for_status()
File "C:\Users\Max\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.bitbucket.org/2.0/projects
That's because the cloud path seems to be outdated. I think only the functions which have a workspace as argument and the Cloud object are working.
@Spacetown Do you know where i can et the documentation about cloud?
Please check the example https://github.com/atlassian-api/atlassian-python-api/blob/master/examples/bitbucket/bitbucket_cloud_oo.py and the tests.