davetcode / confluence-python-lib Goto Github PK
View Code? Open in Web Editor NEWA python library wrapping the Confluence REST API
License: MIT License
A python library wrapping the Confluence REST API
License: MIT License
The example code does not work, c is NoneType
from confluence.client import Confluence
with Confluence('https://site:8080/confluence', ('user', 'pass')) as c:
pages = c.search('ID=1')
The enter method does not return self.
https://github.com/DaveTCode/confluence-python-lib/blob/master/confluence/client.py#L45
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
When paginating through the confluence.client.Confluence.get_content()
method I am running into a KeyError
when trying to fetch the title
field from a content response. The rest of the fields in content appear on that record and the rest of my application works just fine except for this one bad item. I feel like title
should be a required field or at least be a blank string but now it just blows up in my face. I am running Confluence version 6.15.9
Traceback (most recent call last):
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/celery/app/trace.py", line 648, in __protected_call__
return self.run(*args, **kwargs)
File "/Users/jquick/Box/Projects/matrix/confluence_app/tasks.py", line 23, in confluence_spaces
confluence_space_content(space.key)
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/celery/local.py", line 191, in __call__
return self._get_current_object()(*a, **kw)
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/celery/app/trace.py", line 649, in __protected_call__
return orig(self, *args, **kwargs)
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/celery/app/task.py", line 394, in __call__
return self.run(*args, **kwargs)
File "/Users/jquick/Box/Projects/matrix/confluence_app/tasks.py", line 31, in confluence_space_content
for content in client.get_content(ctype, space_key, expand=['history']):
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/confluence/client.py", line 139, in _get_paged_results
yield item_type(result)
File "/Users/jquick/.virtualenvs/matrix-7HUYJ2hm/lib/python3.6/site-packages/confluence/models/content.py", line 69, in __init__
self.title = json['title'] # type: str
KeyError: 'title'
The site I am pulling this from is private but here is response content (with some info scrubbed for privacy)
{
"_expandable": {
"ancestors": "",
"body": "",
"children": "/rest/api/content/12345/child",
"container": "/rest/api/space/webDomain",
"descendants": "/rest/api/content/12345/descendant",
"metadata": "",
"operations": "",
"restrictions": "/rest/api/content/12345/restriction/byOperation",
"space": "/rest/api/space/webDomain",
"version": ""
},
"_links": {
"edit": "/pages/resumedraft.action?draftId=12345",
"self": "https://confluence.internal.com/rest/api/content/12345",
"tinyui": "/x/XXXXX",
"webui": "/pages/viewpage.action?pageId=12345"
},
"extensions": {
"position": "none"
},
"history": {
"_expandable": {
"contributors": "",
"lastUpdated": "",
"nextVersion": "",
"previousVersion": ""
},
"_links": {
"self": "https://confluence.internal.com/rest/api/content/12345/history"
},
"createdBy": {
"_expandable": {
"status": ""
},
"_links": {
"self": "https://confluence.internal.com/rest/api/user?key=0987654321"
},
"displayName": "Justin Quick",
"profilePicture": {
"height": 48,
"isDefault": false,
"path": "/download/attachments/555/user-jquick-ldap-image.png",
"width": 48
},
"type": "known",
"userKey": "0987654321",
"username": "jquick"
},
"createdDate": "2013-01-10T12:08:49.000-05:00",
"latest": true
},
"id": "12345",
"status": "current",
"type": "page"
}
I am trying to play around with this library but I am getting authentication error
import sys
from confluence.client import Confluence
from confluence.models.content import ContentType
def main():
with Confluence('https://pradeepchhetri.atlassian.net/wiki', ('[email protected]', 'xxx')) as c:
spaces = c.get_spaces(space_keys=['Core'])
print(len(list(spaces)))
if __name__ == '__main__':
sys.exit(main())
Traceback (most recent call last):
File "test.py", line 15, in <module>
sys.exit(main())
File "test.py", line 8, in main
print(len(list(spaces)))
File "/Library/Python/2.7/site-packages/confluence/client.py", line 126, in _get_paged_results
response = self._get(path, params, [])
File "/Library/Python/2.7/site-packages/confluence/client.py", line 112, in _get
Confluence._handle_response_errors(path, params, response)
File "/Library/Python/2.7/site-packages/confluence/client.py", line 84, in _handle_response_errors
raise ConfluenceAuthenticationError(path, params, response)
confluence.exceptions.authenticationerror.ConfluenceAuthenticationError: Authentication failure. This is most likely due to incorrect username/password
I am able to login with the same username and password in https://id.atlassian.com/login
Can you help me with some pointers to debug this issue.
Thank you.
The builds timeout because the confluence instance we spin up isn't responding.
Need to update the list of supported versions
In add_attachment method :
return self._post_return_multiple(Content,
'/content/{}/child/attachment'.format(content_id),
params=params,
files={'file': (file_name, f)},
data={})
You should remove the slash before 'content', like this : 'content/{}/child/attachment'.format(content_id) , because further, when you will concatenate this string with self._api_base , you will optain something like this: http;//<'adress to confluence'>/rest/api//content/<'content id'>/child/attachment
Hi !
I was trying the create_content method and i noticed that at some point it is called the _put method. In this method you check if params is not None, but in my opinion you should check if expand is not None
A 401 error isn't handled by this library so we end up with a downstream error like "Can't parse JSON".
https://github.com/DaveTCode/confluence-python-lib/blob/master/confluence/client.py#L214
The method update_content has optional arguments, but they do not have default values.
TypeError: update_content() missing 4 required positional arguments: 'status', 'new_title', 'new_parent', and 'new_status'
https://github.com/DaveTCode/confluence-python-lib/blob/master/confluence/models/contentbody.py
has a very low test coverage and all code that is not covered has copy&paste bugs.
Hello,
I want to have the URL for the end-user to be able to click to the Wiki page.
Seems the info is in _links.webui, but cannot retrieve that on a Content object.
Limited to Attachement ? seems to be so in code.
Can you please help here ?
While I don't really have a strong opinion on tests being installed when installing a package, I do mind when they get installed as a top-level package in my site-packages
! pip install tests
actually will install something.
Might I also recommend a rename of the top-level confluence
package? I know it's an ideal name right now but the deprecated xmlrpc library currently has the same name so after a pip install
, they'll be stepping on each others' toes on the filesystem.
The only attachment support at the moment is for creating/adding/deleting. This covers adding support for updates by attachment id
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.
Hi!
When I'm trying to create initial connection, I getting the following stacktrace:
requests.exceptions.SSLError: HTTPSConnectionPool(host='confluence.federated.fds', port=443): Max retries exceeded with url: /confluence/rest/api/content/search?cql=ID%3D1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)')))
Our confluence have an expired certificate and I can't update it right now, is there any way to provide verify=False to requests without monkey-patching?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.