atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.36k stars 664 forks source link

[Confluence] api_root arg in class Confluence() is not used. #744

Open sonr09 opened 3 years ago

sonr09 commented 3 years ago

Following REAS API doc: https://docs.atlassian.com/ConfluenceServer/rest/7.11.1/#api/content/{id}/child-childrenOfType Client can make requests with context and without: Example with context: http://example.com:8080/confluence/rest/api/space/ds Example without context: http://confluence.myhost.com:8095/rest/api/space/ds

Following code, I found that this is possible to define via arg api_root in parent for class Confluence. But this arg not used after that. So client can request only for hard coded api root = 'rest/api/'.

p.s. I have to idea why Atlassian provided requests with context and without :)

dotcs commented 3 years ago

I've experienced the same problems. I'm wondering if it would be sufficient to rewrite code parts that contain hardcoded rest/api such as

https://github.com/atlassian-api/atlassian-python-api/blob/f63efa747bfc91b8f70e295f875b2edc43ca438f/atlassian/confluence.py#L75

into

url = self.resource_url("content/{page_id}/child/{type}".format(page_id=page_id, type=type))

The resource_url function is defined in as follows:

https://github.com/atlassian-api/atlassian-python-api/blob/f63efa747bfc91b8f70e295f875b2edc43ca438f/atlassian/rest_client.py#L157-L162

I also noticed that it's not only the confluence module that has the problem, but also others, e.g.

https://github.com/atlassian-api/atlassian-python-api/blob/f63efa747bfc91b8f70e295f875b2edc43ca438f/atlassian/bamboo.py#L178

https://github.com/atlassian-api/atlassian-python-api/blob/f63efa747bfc91b8f70e295f875b2edc43ca438f/atlassian/jira.py#L54

Also in the bitbucket module the logic looks differently and the string is hard coded depending on the url:

https://github.com/atlassian-api/atlassian-python-api/blob/f63efa747bfc91b8f70e295f875b2edc43ca438f/atlassian/bitbucket/__init__.py#L19-L20

How is the general idea here? I could probably write a PR but would like to first understand how this should be implemented best. Maybe one of the maintainers of this package can help?

sonr09 commented 3 years ago

@dotcs thank you for comment.

I don't know cases that would be use api_root. I've just noted that api_root not used in confluence module and I've saw that confluence REST API has something which called context.

If somebody find cases for using api_root (especially in Confluence module), PR will have place.

Spacetown commented 3 years ago

I was also wondering about the construct in bitbucket. I think this is a difference between private cloud instances which use the rest/api and the atlassian instance which use another server name.