Skip to content

Commit 587394b

Browse files
committed
Insght: adjsut methods variables
1 parent 697a05f commit 587394b

File tree

6 files changed

+133
-59
lines changed

6 files changed

+133
-59
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.29.1
1+
3.30.0

atlassian/bitbucket/cloud/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# coding=utf-8
22

3+
import logging
34
from ..base import BitbucketBase
45

56
from requests import HTTPError
67

8+
log = logging.getLogger(__name__)
9+
710

811
class BitbucketCloudBase(BitbucketBase):
912
def __init__(self, url, *args, **kwargs):
@@ -104,7 +107,8 @@ def raise_for_status(self, response):
104107
error_msg = e["message"]
105108
if e.get("detail"):
106109
error_msg += "\n" + e["detail"]
107-
except Exception:
110+
except Exception as e:
111+
log.error(e)
108112
response.raise_for_status()
109113
else:
110114
raise HTTPError(error_msg, response=response)

atlassian/confluence.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ def update_page(
15111511
:return:
15121512
"""
15131513
# update current page
1514-
params = {'status': 'current'}
1514+
params = {"status": "current"}
15151515
log.info('Updating {type} "{title}" with {parent_id}'.format(title=title, type=type, parent_id=parent_id))
15161516

15171517
if not always_update and body is not None and self.is_page_content_is_already_updated(page_id, body, title):
@@ -2785,7 +2785,8 @@ def raise_for_status(self, response):
27852785
try:
27862786
j = response.json()
27872787
error_msg = j["message"]
2788-
except Exception:
2788+
except Exception as e:
2789+
log.error(e)
27892790
response.raise_for_status()
27902791
else:
27912792
raise HTTPError(error_msg, response=response)

atlassian/insight.py

Lines changed: 107 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
class Insight(AtlassianRestAPI):
11-
1211
"""Insight for Jira API wrapper."""
1312

1413
# https://insight-javadoc.riada.io/insight-javadoc-8.6/insight-rest/
@@ -285,21 +284,21 @@ def get_object(self, object_id):
285284
url = self.url_joiner(self.api_root, "object/{id}".format(id=object_id))
286285
return self.get(url)
287286

288-
def update_object(self, object_id, object_type_id, attributes, has_avatar=False, avatar_UUID=""):
287+
def update_object(self, object_id, object_type_id, attributes, has_avatar=False, avatar_uuid=""):
289288
"""
290289
Update an existing object in Insight
291290
292291
:param object_id:
293292
:param object_type_id:
294293
:param attributes:
295294
:param has_avatar:
296-
:param avatar_UUID:
295+
:param avatar_uuid:
297296
:return:
298297
"""
299298
body = {
300299
"attributes": attributes,
301300
"objectTypeId": object_type_id,
302-
"avatarUUID": avatar_UUID,
301+
"avatarUUID": avatar_uuid,
303302
"hasAvatar": has_avatar,
304303
}
305304
url = self.url_joiner(self.api_root, "object/{id}".format(id=object_id))
@@ -337,7 +336,7 @@ def get_object_history(self, object_id, asc=False, abbreviate=True):
337336
params = {"asc": asc, "abbreviate": abbreviate}
338337
url = self.url_joiner(self.api_root, "object/{id}/history".format(id=object_id))
339338
return self.get(url, params=params)
340-
339+
341340
@deprecated(version="3.29.0", reason="Use get_object_reference_info()")
342341
def get_object_referenceinfo(self, object_id):
343342
"""Let's use the get_object_reference_info()"""
@@ -354,65 +353,71 @@ def get_object_reference_info(self, object_id):
354353
url = self.url_joiner(self.api_root, "object/{id}/referenceinfo".format(id=object_id))
355354
return self.get(url)
356355

357-
def create_object(self, objectTypeId, attributes, hasAvatar=False, avatarUUID=""):
356+
def create_object(self, object_type_id, attributes, has_avatar=False, avatar_uuid=""):
358357
"""
359358
Create a new object in Insight
360359
361-
:param objectTypeId:
360+
:param object_type_id:
362361
:param attributes:
363-
:param hasAvatar:
364-
:param avatarUUID:
362+
:param has_avatar:
363+
:param avatar_uuid:
365364
:return:
366365
:return:
367366
"""
368367
data = {
369368
"attributes": attributes,
370-
"objectTypeId": objectTypeId,
371-
"avatarUUID": avatarUUID,
372-
"hasAvatar": hasAvatar,
369+
"objectTypeId": object_type_id,
370+
"avatarUUID": avatar_uuid,
371+
"hasAvatar": has_avatar,
373372
}
374373
url = self.url_joiner(self.api_root, "object/create")
375374
return self.post(url, data=data)
376375

377376
def create_object_navlist_iql(
378377
self,
379378
iql,
380-
objectTypeId,
381-
resultsPerPage,
382-
orderByTypeAttrId,
383-
objectId,
384-
objectSchemaId,
385-
includeAttributes,
386-
attributesToDisplay,
379+
object_type_id,
380+
results_per_page,
381+
order_by_type_attr_id,
382+
object_id,
383+
object_schema_id,
384+
include_attributes,
385+
attributes_to_display,
387386
page=1,
388387
asc=0,
389388
):
390389
"""
391-
A filter object that is used to find a paginatad result set based on an object type and an IQL query
390+
A filter object that is used to find a paginated result set based on an object type and an IQL query
392391
393392
:param iql:
394-
:param objectTypeId:
393+
:param object_type_id:
395394
:param page:
396-
:param resultsPerPage:
397-
:param orderByTypeAttrId:
395+
:param results_per_page:
396+
:param order_by_type_attr_id:
398397
:param asc:
399-
:param objectId:
400-
:param objectSchemaId:
401-
:param includeAttributes:
402-
:param attributesToDisplay:
398+
:param object_id:
399+
:param object_schema_id:
400+
:param include_attributes:
401+
:param attributes_to_display:
403402
:return:
404403
"""
405-
data = {"objectTypeId": objectTypeId, "iql": iql, "resultsPerPage": resultsPerPage, "page": page, "asc": asc}
406-
if attributesToDisplay is not None:
407-
data["attributesToDisplay"] = attributesToDisplay
408-
if includeAttributes is not None:
409-
data["includeAttributes"] = includeAttributes
410-
if objectSchemaId is not None:
411-
data["objectSchemaId"] = objectSchemaId
412-
if orderByTypeAttrId is not None:
413-
data["orderByTypeAttrId"] = orderByTypeAttrId
414-
if objectId is not None:
415-
data["objectId"] = objectId
404+
data = {
405+
"objectTypeId": object_type_id,
406+
"iql": iql,
407+
"resultsPerPage": results_per_page,
408+
"page": page,
409+
"asc": asc,
410+
}
411+
if attributes_to_display is not None:
412+
data["attributesToDisplay"] = attributes_to_display
413+
if include_attributes is not None:
414+
data["includeAttributes"] = include_attributes
415+
if object_schema_id is not None:
416+
data["objectSchemaId"] = object_schema_id
417+
if order_by_type_attr_id is not None:
418+
data["orderByTypeAttrId"] = order_by_type_attr_id
419+
if object_id is not None:
420+
data["objectId"] = object_id
416421
url = self.url_joiner(self.api_root, "iql/objects")
417422
return self.post(url, data=data)
418423

@@ -494,7 +499,67 @@ def get_object_schema_object_types_flat(self, schema_id):
494499
"""
495500
raise NotImplementedError
496501

497-
# Objecttype
498-
# Objecttypeattribute
499-
# Progress
500-
# Config
502+
def get_object_type_attributes(
503+
self,
504+
type_id,
505+
only_value_editable=None,
506+
order_by_name=None,
507+
query=None,
508+
include_values_exist=None,
509+
exclude_parent_attributes=None,
510+
include_children=None,
511+
order_by_required=None,
512+
):
513+
"""
514+
Find all attributes for this object type
515+
https://developer.atlassian.com/cloud/insight/rest/api-group-objecttype/#api-objecttype-id-attributes-get
516+
Args:
517+
type_id (str): id of the object type
518+
only_value_editable (bool, optional): only return editable values, defaults to None (Use API default)
519+
order_by_name (bool, optional): values, defaults to None (Use API default)
520+
query (str, optional): Not documented in API, defaults to None (Use API default)
521+
include_values_exist (bool, optional): Include only where values exist, defaults to None (Use API default)
522+
exclude_parent_attributes (bool, optional): Exclude parent attributes, defaults to None (Use API default)
523+
include_children (bool, optional): include attributes from children, defaults to None (Use API default)
524+
order_by_required (bool, optional): Order by required fields, defaults to None (Use API default)
525+
"""
526+
527+
kwargs = locals().items()
528+
params = dict()
529+
params.update({k: v for k, v in kwargs if v is not None and k not in ["self", "type_id"]})
530+
531+
return self.get(
532+
"{0}objecttype/{1}/attributes".format(self.api_root, type_id),
533+
headers=self.experimental_headers,
534+
params=params,
535+
)
536+
537+
### Objecttype
538+
# TODO: Post objecttype {id} position:
539+
# https://developer.atlassian.com/cloud/insight/rest/api-group-objecttype/#api-objecttype-id-position-post
540+
# TODO: Post objecttype create:
541+
# https://developer.atlassian.com/cloud/insight/rest/api-group-objecttype/#api-objecttype-create-post
542+
543+
### Insight ObjectTypeAttribute API
544+
# TODO: Post objecttypeattribute {objectTypeId}:
545+
# https://developer.atlassian.com/cloud/insight/rest/api-group-objecttypeattribute/#api-objecttypeattribute-objecttypeid-post
546+
# TODO: Put objecttypeattribute {objectTypeId} {id}:
547+
# https://developer.atlassian.com/cloud/insight/rest/api-group-objecttypeattribute/#api-objecttypeattribute-objecttypeid-id-put
548+
# TODO: Delete objecttypeattribute {id}:
549+
# https://developer.atlassian.com/cloud/insight/rest/api-group-objecttypeattribute/#api-objecttypeattribute-id-delete
550+
551+
### Insight Progress API
552+
# TODO: Get progress category imports {id}:
553+
# https://developer.atlassian.com/cloud/insight/rest/api-group-progress/#api-progress-category-imports-id-get
554+
555+
### Insight Config API
556+
# TODO: Get config statustype:
557+
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-get
558+
# TODO: Post config statustype:
559+
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-post
560+
# TODO: Get config statustype {id}:
561+
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-get
562+
# TODO: Put config statustype {id}:
563+
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-put
564+
# TODO: Delete config statustype {id}:
565+
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-delete

atlassian/jira.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ def epic_issues(self, epic, fields="*all", expand=None):
902902
base_url = self.resource_url("epic", api_root="rest/agile", api_version="1.0")
903903
url = "{base_url}/{key}/issue?fields={fields}".format(base_url=base_url, key=epic, fields=fields)
904904
params = {}
905+
if expand:
906+
params["expand"] = expand
905907
return self.get(url, params=params)
906908

907909
def bulk_issue(self, issue_list, fields="*all"):
@@ -1048,7 +1050,8 @@ def bulk_update_issue_field(self, key_list, fields="*all"):
10481050
try:
10491051
for key in key_list:
10501052
self.put("{base_url}/{key}".format(base_url=base_url, key=key), data={"fields": fields})
1051-
except Exception:
1053+
except Exception as e:
1054+
log.error(e)
10521055
return False
10531056
return True
10541057

@@ -1183,7 +1186,7 @@ def issue_delete_watcher(self, issue_key, user):
11831186
def issue_get_watchers(self, issue_key):
11841187
"""
11851188
Get watchers for an issue
1186-
:param issue_key: Issue Id or Key
1189+
:param issue_key: Issue ID or Key
11871190
:return: List of watchers for issue
11881191
"""
11891192
base_url = self.resource_url("issue")
@@ -2938,27 +2941,27 @@ def get_all_workflows(self):
29382941
url = self.resource_url("workflow")
29392942
return self.get(url)
29402943

2941-
def get_workflows_paginated(self, startAt=None, maxResults=None, workflowName=None, expand=None):
2944+
def get_workflows_paginated(self, start_at=None, max_results=None, workflow_name=None, expand=None):
29422945
"""
29432946
Provide all workflows paginated (see https://developer.atlassian.com/cloud/jira/platform/rest/v2/\
29442947
api-group-workflows/#api-rest-api-2-workflow-search-get)
29452948
:param expand:
2946-
:param startAt: OPTIONAL The index of the first item to return in a page of results (page offset).
2947-
:param maxResults: OPTIONAL The maximum number of items to return per page.
2948-
:param workflowName: OPTIONAL The name of a workflow to return.
2949+
:param start_at: OPTIONAL The index of the first item to return in a page of results (page offset).
2950+
:param max_results: OPTIONAL The maximum number of items to return per page.
2951+
:param workflow_name: OPTIONAL The name of a workflow to return.
29492952
:param: expand: OPTIONAL Use expand to include additional information in the response. This parameter accepts a
29502953
comma-separated list. Expand options include: transitions, transitions.rules, statuses, statuses.properties
29512954
:return:
29522955
"""
29532956
url = self.resource_url("workflow/search")
29542957

29552958
params = {}
2956-
if startAt:
2957-
params["startAt"] = startAt
2958-
if maxResults:
2959-
params["maxResults"] = maxResults
2960-
if workflowName:
2961-
params["workflowName"] = workflowName
2959+
if start_at:
2960+
params["startAt"] = start_at
2961+
if max_results:
2962+
params["maxResults"] = max_results
2963+
if workflow_name:
2964+
params["workflowName"] = workflow_name
29622965
if expand:
29632966
params["expand"] = expand
29642967

atlassian/rest_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ def raise_for_status(self, response):
420420
error_msg = "\n".join(
421421
j.get("errorMessages", list()) + [k + ": " + v for k, v in j.get("errors", dict()).items()]
422422
)
423-
except Exception:
423+
except Exception as e:
424+
log.error(e)
424425
response.raise_for_status()
425426
else:
426427
raise HTTPError(error_msg, response=response)

0 commit comments

Comments
 (0)