Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bb4e981
Merge remote-tracking branch 'upstream/master'
Sep 26, 2019
3cc00fd
Merge remote-tracking branch 'upstream/master'
Sep 26, 2019
12b19b5
A new Tempo method
Oct 3, 2019
8193283
Tempo: add team member
Oct 3, 2019
8ee5f04
Merge branch 'master' of https://github.com/gonchik/atlassian-python-api
Oct 3, 2019
16beefa
Bugfix
Oct 4, 2019
086c53d
Merge remote-tracking branch 'upstream/master'
Oct 4, 2019
911fac0
Merge conflicts
Oct 4, 2019
fd0cf22
Set workload method
Oct 23, 2019
f190a27
Bump version
Oct 23, 2019
0add3ae
Sync with upstream
Oct 27, 2019
c530690
Merge remote-tracking branch 'upstream/master'
Oct 28, 2019
359c1ee
Organize the imports
Oct 28, 2019
0e4e922
Polish
Oct 28, 2019
1fbfcc9
Bump version
Nov 13, 2019
91bf302
Add LFS info fetcher
Nov 13, 2019
141ff2a
Merge conflict
Nov 13, 2019
fa1a454
Git fix conflict
Nov 19, 2019
047486c
Merge remote-tracking branch 'upstream/master'
Nov 22, 2019
0aacfc1
Typo
Nov 23, 2019
05eea34
Merge branch 'master' of https://github.com/gonchik/atlassian-python-api
Nov 23, 2019
ce26890
Consolidate the Jira8 module into main
Nov 23, 2019
61b8fba
Add reindex methods
Nov 23, 2019
cf3e80e
Project related methods
Nov 23, 2019
a950ffb
Add update setup.py
Nov 23, 2019
952ca9e
Rename variables and polish to be in PEP-8
Nov 23, 2019
7f523cb
Polish
Nov 23, 2019
f83adac
Add Jira issue regex matcher
Nov 23, 2019
9f1ef7c
Add static method
Nov 23, 2019
96b0894
Add static method
Nov 23, 2019
2dbdffd
[Jira] fix upload attachment methods
Nov 24, 2019
df1f8b0
Hotfix for jira8 class
Nov 25, 2019
b386821
Hotfix for jira8 class
Nov 25, 2019
cd3a649
Merge branch 'master' into master
gonchik Nov 25, 2019
2ec6c9f
fix conflict
Nov 29, 2019
1eda694
Merge remote-tracking branch 'upstream/master'
Dec 1, 2019
9452aaa
Add the cookie file supports
Dec 22, 2019
2bfd724
Add methods for Confluence docs
Dec 22, 2019
6a3cee2
Polish comment
Jan 8, 2020
0f779da
Merge remote-tracking branch 'upstream/master'
Jan 8, 2020
497da1c
Add priority scheme configs
Jan 10, 2020
95f9c30
Merge remote-tracking branch 'upstream/master'
Jan 17, 2020
319e6aa
Bitbucket: example for clean branches
Jan 20, 2020
13457b2
Merge remote-tracking branch 'upstream/master'
Jan 22, 2020
9623792
Merge remote-tracking branch 'upstream/master'
Jan 27, 2020
1bceaca
[Confluence] Evaluate the move page method
Jan 27, 2020
a3946d8
Add docs
Jan 27, 2020
c015aef
Add docs
Jan 27, 2020
eb41607
[JIRA] Add method disable through REST api instead of crawling way
Jan 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions atlassian/bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,17 @@ def delete_tag(self, project, repository, tag_name):
return self.delete(url)

def get_diff(self, project, repository, path, hash_oldest, hash_newest):
"""
Gets a diff of the changes available in the {@code from} commit but not in the {@code to} commit.
If either the {@code from} or {@code to} commit are not specified,
they will be replaced by the default branch of their containing repository.
:param project:
:param repository:
:param path:
:param hash_oldest: the source commit (can be a partial/full commit ID or qualified/unqualified ref name)
:param hash_newest: the target commit (can be a partial/full commit ID or qualified/unqualified ref name)
:return:
"""
if not self.cloud:
url = 'rest/api/1.0/projects/{project}/repos/{repository}/compare/diff/{path}'.format(project=project,
repository=repository,
Expand Down
42 changes: 31 additions & 11 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,23 @@ def create_page(self, space, title, body, parent_id=None, type='page',
data['ancestors'] = [{'type': type, 'id': parent_id}]
return self.post(url, data=data)

def move_page(self, space_key, page_id, target_title, position="append"):
"""
Move page method
:param space_key:
:param page_id:
:param target_title:
:param position: topLevel or append
:return:
"""
url = "/pages/movepage.action"
params = {"spaceKey": space_key, "pageId": page_id}
if target_title:
params["targetTitle"] = target_title
if position:
params["position"] = position
return self.get(url, params=params, headers=self.no_check_headers)

def get_all_spaces(self, start=0, limit=500, expand=None):
"""
Get all spaces with provided limit
Expand Down Expand Up @@ -714,12 +731,12 @@ def is_page_content_is_already_updated(self, page_id, body, title=None):
"""
if self.advanced_mode:
confluence_content = (((self.get_page_by_id(page_id, expand='body.storage').json() or {})
.get('body') or {})
.get('storage') or {})
.get('body') or {})
.get('storage') or {})
else:
confluence_content = (((self.get_page_by_id(page_id, expand='body.storage') or {})
.get('body') or {})
.get('storage') or {})
.get('body') or {})
.get('storage') or {})

if title:
current_title = confluence_content.get('title', None)
Expand Down Expand Up @@ -793,8 +810,9 @@ def update_page(self, page_id, title, body, parent_id=None, type='page', represe

return self.put('rest/api/content/{0}'.format(page_id), data=data)

def _insert_to_existing_page(self, page_id, title, insert_body, parent_id=None, type='page', representation='storage',
minor_edit=False, top_of_page=False):
def _insert_to_existing_page(self, page_id, title, insert_body, parent_id=None, type='page',
representation='storage',
minor_edit=False, top_of_page=False):
"""
Insert body to a page if already exist
:param parent_id:
Expand Down Expand Up @@ -849,11 +867,12 @@ def append_page(self, page_id, title, append_body, parent_id=None, type='page',
"""
log.info('Updating {type} "{title}"'.format(title=title, type=type))

return self._insert_to_existing_page(page_id, title, append_body, parent_id=parent_id, type=type, representation=representation,
minor_edit=minor_edit, top_of_page=False)
return self._insert_to_existing_page(page_id, title, append_body, parent_id=parent_id, type=type,
representation=representation,
minor_edit=minor_edit, top_of_page=False)

def prepend_page(self, page_id, title, prepend_body, parent_id=None, type='page', representation='storage',
minor_edit=False):
minor_edit=False):
"""
Append body to page if already exist
:param parent_id:
Expand All @@ -868,8 +887,9 @@ def prepend_page(self, page_id, title, prepend_body, parent_id=None, type='page'
"""
log.info('Updating {type} "{title}"'.format(title=title, type=type))

return self._insert_to_existing_page(page_id, title, prepend_body, parent_id=parent_id, type=type, representation=representation,
minor_edit=minor_edit, top_of_page=True)
return self._insert_to_existing_page(page_id, title, prepend_body, parent_id=parent_id, type=type,
representation=representation,
minor_edit=minor_edit, top_of_page=True)

def update_or_create(self, parent_id, title, body, representation='storage', minor_edit=False):
"""
Expand Down
27 changes: 5 additions & 22 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,30 +231,13 @@ def user_update_or_create_property_through_rest_point(self, username, key, value

def user_deactivate(self, username):
"""
Disable user
Disable user. Works from 8.3.0 Release
https://docs.atlassian.com/software/jira/docs/api/REST/8.3.0/#api/2/user-updateUser
:param username:
:return:
"""
url = 'secure/admin/user/EditUser.jspa'
headers = self.form_token_headers
user = self.user(username)
data = {
'inline': 'true',
'decorator': 'dialog',
'username': user['name'],
'fullName': user['displayName'],
'email': user['emailAddress'],
'editName': user['name']
}
answer = self.get('secure/admin/WebSudoAuthenticate.jspa', self.form_token_headers)
atl_token = None
if answer:
atl_token = \
answer.split('<meta id="atlassian-token" name="atlassian-token" content="')[1].split('\n')[0].split(
'"')[0]
if atl_token:
data['atl_token'] = atl_token
return self.post(data=data, path=url, headers=headers)
data = {"active": "false", "name": username}
return self.user_update(username=username, data=data)

def user_disable(self, username):
"""Override the disable method"""
Expand Down Expand Up @@ -2080,7 +2063,7 @@ def tempo_4_timesheets_find_worklogs(self, **params):
:param maxResults: integer
:param offset: integer
"""

url = "rest/tempo-timesheets/4/worklogs/search"
return self.post(url, data=params)

Expand Down
2 changes: 1 addition & 1 deletion atlassian/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AtlassianRestAPI(object):
'X-ExperimentalApi': 'opt-in'}
form_token_headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Atlassian-Token': 'no-check'}

no_check_headers = {'X-Atlassian-Token': 'no-check'}
response = None

def __init__(self, url, username=None, password=None, timeout=60, api_root='rest/api', api_version='latest',
Expand Down
3 changes: 3 additions & 0 deletions docs/confluence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ Page actions
# Delete the page (content) property e.g. delete key of hash
confluence.delete_page_property(page_id, page_property)

# Move page
confluence.move_page(space_key, page_id, target_title, position="append")

# Get the page (content) property e.g. get key of hash
confluence.get_page_property(page_id, page_property_key)

Expand Down
2 changes: 1 addition & 1 deletion docs/jira.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Manage users
# Remove user
jira.user_remove(username)

# Deactivate user
# Deactivate user. Works from 8.3.0 release
jira.user_deactivate(username)

# Get web sudo cookies using normal http request
Expand Down