Skip to content

Commit aaff2a5

Browse files
Gonchik TsymzhitovGonchik Tsymzhitov
authored andcommitted
JIRA: Add a few new method work with Tempo
1 parent b4d4974 commit aaff2a5

File tree

2 files changed

+63
-8
lines changed

2 files changed

+63
-8
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.6
1+
1.10.0

atlassian/jira.py

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def user_disable(self, username):
8383
"""Override the disable method"""
8484
return self.user_deactivate(username)
8585

86-
def user_disable_throw_rest_endpoint(self, username, url='/rest/scriptrunner/latest/custom/disableUser',
86+
def user_disable_throw_rest_endpoint(self, username, url='rest/scriptrunner/latest/custom/disableUser',
8787
param='userName'):
8888
"""The disable method throw own rest enpoint"""
8989
url = "{}?{}={}".format(url, param, username)
@@ -136,9 +136,10 @@ def get_project_versions(self, key, expand=None):
136136
:param expand: the parameters to expand
137137
:return:
138138
"""
139+
params = {}
139140
if expand is not None:
140141
params["expand"] = expand
141-
return self.get('rest/api/2/project/{}/versions'.format(key))
142+
return self.get('rest/api/2/project/{}/versions'.format(key), params=params)
142143

143144
def get_project_versions_paginated(self, key, start=None, limit=None, order_by=None, expand=None):
144145
"""
@@ -363,7 +364,43 @@ def tempo_account_get_accounts(self, skip_archived=None, expand=None):
363364
url = 'rest/tempo-accounts/1/account'
364365
return self.get(url, params=params)
365366

366-
def tempo_account_get_all_customers(self, query=None, count_accounts=None):
367+
def tempo_account_add_account(self, data=None):
368+
"""
369+
Creates Account, adding new Account requires the Manage Accounts Permission.
370+
:param data: String then it will convert to json
371+
:return:
372+
"""
373+
url = 'rest/tempo-accounts/1/account/'
374+
if data is None:
375+
return """Please, provide data e.g.
376+
{name: "12312312321",
377+
key: "1231231232",
378+
lead: {name: "gonchik.tsymzhitov"},
379+
}
380+
detail info: http://developer.tempo.io/doc/accounts/api/rest/latest/#-700314780
381+
"""
382+
return self.post(url, data=data)
383+
384+
def tempo_account_delete_account_by_id(self, account_id):
385+
"""
386+
Delete an Account by id. Caller must have the Manage Account Permission for the Account.
387+
The Account can not be deleted if it has an AccountLinkBean.
388+
:param account_id: the id of the Account to be deleted.
389+
:return:
390+
"""
391+
url = 'rest/tempo-accounts/1/account/{id}/'.format(id=account_id)
392+
return self.delete(url)
393+
394+
def tempo_account_get_all_account_by_customer_id(self, customer_id):
395+
"""
396+
Get un-archived Accounts by customer. The Caller must have the Browse Account permission for the Account.
397+
:param customer_id: the Customer id.
398+
:return:
399+
"""
400+
url = 'rest/tempo-accounts/1/account/customer/{customerId}/'.format(customerId=customer_id)
401+
return self.get(url)
402+
403+
def tempo_account_get_customers(self, query=None, count_accounts=None):
367404
"""
368405
Gets all or some Attribute whose key or name contain a specific substring. Attributes can be a Category or Customer.
369406
:param query: OPTIONAL: query for search
@@ -378,6 +415,20 @@ def tempo_account_get_all_customers(self, query=None, count_accounts=None):
378415
url = 'rest/tempo-accounts/1/customer'
379416
return self.get(url, params=params)
380417

418+
def tempo_account_add_customer(self, data=None):
419+
"""
420+
Gets all or some Attribute whose key or name contain a specific substring. Attributes can be a Category or Customer.
421+
:param data:
422+
:return: if error will show in error log, like validation unsuccessful. If success will good.
423+
"""
424+
if data is None:
425+
return """Please, set the data as { isNew:boolean
426+
name:string
427+
key:string
428+
id:number } or you can put only name and key parameters"""
429+
url = 'rest/tempo-accounts/1/customer'
430+
return self.post(url, data=data)
431+
381432
def tempo_account_get_customer_by_id(self, customer_id=1):
382433
"""
383434
Get Account Attribute whose key or name contain a specific substring. Attribute can be a Category or Customer.
@@ -387,11 +438,11 @@ def tempo_account_get_customer_by_id(self, customer_id=1):
387438
url = 'rest/tempo-accounts/1/customer/{id}'.format(id=customer_id)
388439
return self.get(url)
389440

390-
def tempo_account_update_customer_by_id(self, customer_id=1, body=None):
441+
def tempo_account_update_customer_by_id(self, customer_id=1, data=None):
391442
"""
392443
Updates an Attribute. Caller must have Manage Account Permission. Attribute can be a Category or Customer.
393444
:param customer_id: id of Customer record
394-
:param body: format is
445+
:param data: format is
395446
{
396447
isNew:boolean
397448
name:string
@@ -400,9 +451,13 @@ def tempo_account_update_customer_by_id(self, customer_id=1, body=None):
400451
}
401452
:return: json with parameters name, key and id.
402453
"""
403-
454+
if data is None:
455+
return """Please, set the data as { isNew:boolean
456+
name:string
457+
key:string
458+
id:number }"""
404459
url = 'rest/tempo-accounts/1/customer/{id}'.format(id=customer_id)
405-
return self.put(url, data=body)
460+
return self.put(url, data=data)
406461

407462
def tempo_account_delete_customer_by_id(self, customer_id=1):
408463
"""

0 commit comments

Comments
 (0)