Giter Site home page Giter Site logo

atlassian-api / atlassian-python-api Goto Github PK

View Code? Open in Web Editor NEW
1.3K 42.0 630.0 2.21 MB

Atlassian Python REST API wrapper

Home Page: https://atlassian-python-api.readthedocs.io

License: Apache License 2.0

Python 99.82% Makefile 0.18%
atlassian jira confluence bamboo api rest python bitbucket jira-service-desk portfolio

atlassian-python-api's People

Contributors

astromatt avatar austinmh12 avatar cattz avatar copolycube avatar dephekt avatar djachkov avatar djgoku avatar flichtenheld avatar gkowalc avatar gonchik avatar infame-io avatar isaac-philip avatar jensvog avatar kevindejong-tomtom avatar martinrakovec-comap avatar martynbristow avatar nmikhalaki avatar noorul avatar offa avatar pablotoledo avatar rjlardizabal avatar slrover avatar spacetown avatar sreway avatar sti0 avatar stranljip avatar svyotov avatar woklex avatar ysfiqbl avatar yugohino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atlassian-python-api's Issues

Authenticating with App Password on public bitbucket.

Hi.

I'm trying to authenticate like this on the public bitbucket site:

        username = os.environ['CRONOHUB_BITBUCKET_USERNAME']
        password = os.environ['CRONOHUB_BITBUCKET_PASSWORD']
        url = os.environ['CRONOHUB_BITBUCKET_URL']
        bitbucket = Bitbucket(
                url=url,
                username=username,
                password=password)
        data = bitbucket.project_list()

where username is my username, the password is an App password that I generated ( I don't have a password since I created my account via Google Oauth ) and url is https://bitbucket.org.

All I get back is this:

b''
HTTP Error occurred
Response is: b''
Expecting value: line 1 column 1 (char 0)

Which tells me nothing.

Incorrect logging level

The update_or_create function logs the URL of the updated or created page. While this might be important information, it is being logged at WARNING level, which means it is printed out by default.

I do not believe this information should be logged at WARNING level, or printed out by default, as that assumes how the function is being used; i.e., it's being run from somewhere that the user will always see the output, it's only used on a handful of pages at a time, etc...

title passed as body in self.create_page

this line in Confluence.update_or_create

result = self.create_page(space, parent_id, title, body)

should be

result = self.create_page(space=space, parent_id=parent_id, title=title, body=body)

because

def create_page(self, space, title, body, parent_id = None, type='page')

as it currently is, parent_id get passed in as title, title as body etc.
I am free to submit a PR to fix this right? Working on it.

Uploaded *.PNG attachment have 'application/octet-stream' content type

After uploading *.png file it have 'application/octet-stream' content type. And displayed incorrectly in Confluence Web UI.

I fixed it with replacing (here):
return self.post(path=path, data=data, headers=headers, files={'file': infile})
with
return self.post(path=path, data=data, headers=headers, files={'file': (filename, infile, content_type)})

HTTP error with incorrect username and password

Hi ,

I am having problems while doing a confluence search with cql. If the username and password are correct everything is great. However if the username or password are incorrect i get a HTTP error. I want to capture this so it can just display authentication error rather than the full stack out put.

Can you advise where i capture this so that i can handle it as an except. Sorry if this is a little obvious, but i am new to python.

Thanks

Jonathan

Confluence - Get Child Pages

Please add support for getting child pages of a given page by its ID or Title.

My use case is that I want to create a load of pages based upon a confluence pages from Jira JQL (one page per Epic), then label each one so I can easily create a Page Properties table.

Page update without overwrite

Hi,
function "confluence.update_page" and "confluence.update_or_create" is overwriting the content.
Is there any way where we append the new content with the existing content in the page?

How do you disable SSL certificate checking?

Hi. I like your python api frontend. One question though. How do you disable SSL certificate checking. Do you have a value that can be set that's passed onto the request module?

Thanks!

Glen Collins

Compatible with Atlassian cloud?

Hi,

Is this library compatible with the Atlassian Cloud?
Please include this info into the documentation too, thanks!

Regards,
Akos

Bamboo API

You seem to be demonstrating some usage examples of JIRA and Confluence, however, it doesn't look like there is any mention of Bamboo API however, is Bamboo portion complete?

Confluence CQL question

Hi,

I am attempting to use cql to search for keywords throughout Confluence. I define the space key to search and then iterate over the results. Using the following simple search works to some extent:

cql = "space.key= {}".format(space)

However this only produces the 'excerpt' value in the resulting JSON and not the full page. So I am trying to expand the body in each page. Using the following search in the browser against the api returns the full page details as required:

/rest/api/content/search?cql=space.key=S2&expand=space,body.view

However calling 'cql' via the atlassian-python-api gives the following:

cql = "space.key={} +and+expand=space,body.view".format(space)

{'statusCode': 400, 'data': {'authorized': False, 'valid': True, 'allowedInReadOnlyMode': True, 'errors': [], 'successful': False}, 'message': 'Could not parse cql : space.key=X +and+expand=space,body.view', 'reason': 'Bad Request'}

So it appears to be having trouble parsing the request - though the equivalent works in the browser. Is this a bug perhaps or am I missing something simple?

Many thanks

creating a confluence page

Hello,

It seems like your README file is out of sync with your code. We are now required to provide the parent_id of the page we wish to create, however, even when I provide the page_id of the parent page, the page still doesn't get created..

Limitation of 1000 in function repo_list?

Hi There.

We have a bitbucket Project with more than 1000 Repositories. When I run the function repo_lists with a limit of 99999 it only shows me 1000 Repositories
data = bitbucket.repo_list(project_key, limit=99999 )

Is there a limitation in your code or in the api?

it would be great if the limitation would be raised and if there were a possiblity to filter the results in the repo_list function like this:
data = bitbucket.repo_list(project_key, filter='MyFilter' )

Thanks
Markus

OAuth2 instead of BasicAuth?

While I understand that Basic Auth is quite simple to use at first hand, I think it would be nice (and much more secure) to have the opportunity to use other Authentification Methods offered by the Atlassian APIs, such as OAuth2.

Did you try implementing OAuth2 yet?

Several syntax bugs in confluence.py update_page method

There are several syntax errors in the latest update_page method in confluence.py.
The code below resolves these issues this does make parent_id none optional again but I didn't want to change the method signature

    def update_page(self, parent_id, page_id, title, body, type='page'):
        log.info('Updating {type} "{title}"'.format(title=title, type=type))
        if self.is_page_content_is_already_updated(page_id, body):
            return self.get_page_by_id(page_id)
        else:
            version = self.history(page_id)['lastUpdated']['number'] + 1

            data = {
                'id': page_id,
                'type': type,
                'title': title,
                'body': {'storage': {
                    'value': body,
                    'representation': 'storage'}},
                'version': {'number': version}
            }

            if parent_id is not None:
                data['ancestors'] = [{'type': 'page', 'id': parent_id}]
            return self.put('/rest/api/content/{0}'.format(page_id), data=data)

In confluence module missing /wiki in api_root

I am using atlassian-python-api==1.12.6

This call

pprint(confluence.get_space('MYSPACE'))

returns
Received: 404 Not Found {'message': 'null for uri: ' 'https://mycompany.atlassian.net/rest/api/space/MYSPACE?expand=description.plain,homepage', 'status-code': 404}

And indeed, the API docs says that the api root is wiki/rest/api and not rest/api.
Overriding the api_root did not change anything:

Confluence(username=user,
           password=api_token,
           api_root='wiki/rest/api',
           url='https://mycompany.atlassian.net'

But the return value of get_space() is the same.

Could you please check / suggest?

Summary is required when updating a jira issue

Maybe I just want to update another field and because there's loggin on the function using provided summary, I'll have to fetch the previous summary even if I'm not changing anything on it or else this throws an error

Could we make it optional? Say, if there's no summary provided, log the first field being provided on the argument.

If Yes, I would be happy to make that change.

while trying to update conflunce page , geting below mention error

Traceback (most recent call last):
File "con_update.py", line 37, in
parent_id=22028117
File "C:\Python36-32\lib\site-packages\atlassian\confluence.py", line 76, in update_page
'version': {'number': version}})
File "C:\Python36-32\lib\site-packages\atlassian_init_.py", line 57, in put
return self.request('PUT', path=path, data=data, headers=headers).json()
File "C:\Python36-32\lib\site-packages\atlassian_init_.py", line 42, in request
response.raise_for_status()
File "C:\Python36-32\lib\site-packages\requests\models.py", line 851, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error``

from pprint import pprint
from atlassian import Confluence

confluence = Confluence(
    url='xxx',
    username='xxx',
    password='xxx')


status = confluence.update_page(
    parent_id=22028117,
    page_id=38284221,
	title='',
    body='<h1 id="WindowsSignatureSet2.4.131.3-2-HandoffinstructionstoOperations">Handoff instructions to Operations</h1>',
	
 )

print(status)

searching a project for issues in jira

Hi guys, i have been looking over the documentation and can cant quite work out how to search a project in jira for a project.

Any direct you could give would be great.

update failing without version

In updating a page, I am getting the error below. Is there a way to include an increment version in the confluence.update() function?

Update: I am updating the page with MarkUp. Plain text, works fine.

My code is as follows...

This works:
status = confluence.update_page(
parent_id=None,
page_id=123456,
title='Proof of Concept',
body = 'Some text here')

This does not work (although works fine for a create_page):
status = confluence.update_page(
parent_id=None,
page_id=123456,
title='Proof of Concept',
body={'storage': {'value': str(pageBody),'representation': 'wiki'}})

where pageBody is MarkUp

Error:
{'statusCode': 400, 'data': {'authorized': False, 'valid': True, 'allowedInReadOnlyMode': True, 'errors': [], 'successful': False}, 'message': 'Must supply an incremented version when updating Content. No version supplied.', 'reason': 'Bad Request'}

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

[Jira] Deactivating a user not working

Using the API I make a call to jira.user_deactivate with the user name via an admin user and I get no errors, but when I log into the site, the user still has full site access. Is this method non-functional?

user_deactivate not working

I'm not able to get user_deactivate to work. I'm running this against a JIRA server version 7.3.1:

from atlassian import Jira
import sys
import os

jira = Jira(
    url='https://jira.example.com',
    username=os.environ['JIRA_USERNAME'],
    password=os.environ['JIRA_PASSWORD'])

print(sys.argv[1])
jira.user_deactivate(sys.argv[1])

I'm getting back an enormous Java stack trace, wrapped in HTML. The most interesting part of the stack trace seems to be:

java.lang.NullPointerException
        at com.atlassian.jira.web.action.admin.user.EditUser.buildNewUser(EditUser.java:86) [classes/:?]
        at com.atlassian.jira.web.action.admin.user.EditUser.doValidation(EditUser.java:45) [classes/:?]

This JIRA server has been modified to work with Okta for SAML2 authentication, which involves disabling the jsp.login_jsp servlet. Is that the cause of the error I'm seeing?

jira-project-leaders.py

Cześć Matt,

Mam problem po uruchomieniu: jira-project-leaders.py
Jeżeli lider projektu ma login zawierający myślnik to skrypt się nie wykonuje. (np. admini-warszawa)
Wygląda na to że trzeba coś poprawić w jira,py

def project_leaders(self): for project in self.projects(): key = project['key'] project_data = self.project(key) lead = self.user(project_data['lead']['key']) yield { 'project_key': key, 'project_name': project['name'], 'lead_name': lead['displayName'], 'lead_key': lead['key'], 'lead_email': lead['emailAddress']}

z góry dzięki za pomoc

get_project_issues_count should escape project name

jira.py's get_project_issues_count def should escape project name. Otherwise one may face issues like this if project key contains reserved JQL words:

ERROR:atlassian:{'errors': {}, 'errorMessages': ["Error in the JQL Query: 'INPUT' is a reserved JQL word. You must surround it in quotation marks to use it in a query. (line 1, character 11)"]}

Question

Thanks @MattAgile for this nice start-up, I am wondering how can I send attachment files to a confluence page. I guess this is not included in your API. Any plans to do so? Thanks!

user_get_websudo() function

Hi there,
I tried to play around with this function, but this function always returns None object.
Could you specify how to use this function?

Regards

Searching for strings containing special characters

Hi,

If I use the CQL search to look for a string containing a special character then I get a status code 400.
For example searching for the word 'C#ess' fails with status code 400 and:
'message': 'Could not parse cql'

Searching for the same string via the Confluence UI seems to parse the special character by replacing with %23. For example:
cql=siteSearch+~+"C%23ess"

I've tried escaping the special characters to no avail and also used CQL to search directly for C%23ess - but then I run into the problem of using another special character so it still won't work.

Am I missing something here or is this a bug?

Thanks very much

confluence.update_or_create shows exception in log when page is not existent

I'm creating a Confluence page using confluence.update_or_create function and it shows list index out of range in output. Seems like the exception occurs when page is not exist and should be created. This error is a bit confusing because page is being created without any problems, so this error doesn't actually indicate something went wrong.

DEBUG:atlassian:curl --silent -X GET -u 'confluence_user':'********' -H 'Content-Type: application/json' -H 'Accept: application/json'  'https://confluence.example.com/rest/api/content/123833032?expand=space'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): confluence.example.com:443
DEBUG:urllib3.connectionpool:https://confluence.example.com:443 "GET /rest/api/content/123833032?expand=space HTTP/1.1" 200 None
DEBUG:atlassian:Received: 200
 {'id': '123833032', 'type': 'page', 'status': 'current', 'title': 'KB pages', 'space': {'id': 68452369, 'key': '~confluence_user', 'name': 'User, Confluence', 'type': 'personal', '_expandable': {'metadata': '', 'icon': '', 'description': '', 'homepage': '/rest/api/content/69927984'}, '_links': {'self': 'https://confluence.example.com/rest/api/space/~confluence_user', 'webui': '/spaces/viewspace.action?key=~confluence_user'}}, 'extensions': {'position': 'none'}, '_expandable': {'container': '/rest/api/space/~confluence_user', 'metadata': '', 'operations': '', 'children': '/rest/api/content/123833032/child', 'restrictions': '/rest/api/content/123833032/restriction/byOperation', 'history': '/rest/api/content/123833032/history', 'ancestors': '', 'body': '', 'version': '', 'descendants': '/rest/api/content/123833032/descendant'}, '_links': {'self': 'https://confluence.example.com/rest/api/content/123833032', 'base': 'https://confluence.example.com', 'context': '', 'collection': '/rest/api/content', 'webui': '/display/~confluence_user/KB+pages', 'edit': '/pages/resumedraft.action?draftId=123833032&draftShareId=39e02a1e-4681-4204-a438-b90ec259f650', 'tinyui': '/x/yIthBq'}}
DEBUG:atlassian:curl --silent -X GET -u 'confluence_user':'********' -H 'Content-Type: application/json' -H 'Accept: application/json'  'https://confluence.example.com/rest/api/content'
DEBUG:urllib3.connectionpool:https://confluence.example.com:443 "GET /rest/api/content?spaceKey=~confluence_user&title=example_confluence_page HTTP/1.1" 200 None
DEBUG:atlassian:Received: 200
 {'results': [], 'start': 0, 'limit': 25, 'size': 0, '_links': {'base': 'https://confluence.example.com', 'context': '', 'self': 'https://confluence.example.com/rest/api/content?spaceKey=~confluence_user&title=example_confluence_page'}}
ERROR:atlassian.confluence:list index out of range
INFO:atlassian.confluence:Page does not exist because did not find by title search

Upload Plugin For Jira Not Working

Hi,

Upload plugin for Jira is not working since creating url function removes trailing spaces but Atlassian's API not responding without trailing space. 🤦‍♂️

[Confluence]: Method to obtain page content

It would be nice to have a method to obtain the body of a given page.
You could then update a page, making modifications to its body.
This method will have as an input the page_id and return the page body content formatted as html.
I will soon submit a PR to fix this issue.

(If I am not mistaken, the current update_or_create() method replaces the content of the page.)

Kind regards,
Argyris

Commit #56 broke page_exists

Because of the change to the behavior of get_page_by_title, page_exists always return true, even if the page doesn't exist.

Logs password in plaintext

When logging is turned on, user's login information, including clear text password, is printed.

DEBUG: curl --silent -X GET -u '[email protected]':'Password1' -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://example.atlassian.net/wiki/rest/api/user?username=vt102'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.