Skip to content

Commit b475aab

Browse files
committed
Jira: update insight related methods
1 parent 5a891c7 commit b475aab

File tree

3 files changed

+75
-6
lines changed

3 files changed

+75
-6
lines changed

README.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ Atlassian Python API wrapper
55

66
What is it?
77
___________
8-
This package is used to provide a **simple** python interface for interacting with Atlassian products
9-
(Server, Data Center and Cloud) and apps from ecosystem (Portfolio, XRay).
10-
It is based on the official public Rest API documentation and private methods (+ xml+rpc, raw http request).
8+
The **atlassian-python-api** library provides a **simple** and convenient way to interact with Atlassian products
9+
(such as Jira Service management, Jira Software, Confluence, Bitbucket and apps Insight, X-Ray) using Python.
10+
It is based on the official REST APIs of these products, as well as additional private methods and protocols
11+
(such as xml+rpc and raw HTTP requests).
12+
This library can be used to automate tasks, integrate with other tools and systems,
13+
and build custom applications that interact with Atlassian products.
14+
It supports a wide range of Atlassian products, including Jira, Confluence, Bitbucket, and others,
15+
and is compatible with both Atlassian Server and Cloud instances.
16+
17+
Overall, the **atlassian-python-api** is a useful tool for Python developers who want to work with Atlassian products.
18+
It is well-documented and actively maintained, and provides a convenient way to access the full range of
19+
functionality offered by the Atlassian REST APIs.
20+
1121

1222
Documentation
1323
_____________

atlassian/insight.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ def __get_workspace_id(self):
5151
0
5252
]["workspaceId"]
5353

54+
def _get_insight_workspace_ids(self):
55+
"""
56+
Returns all Insight workspace Ids.
57+
:return: List
58+
"""
59+
result = self.get(
60+
"rest/servicedeskapi/insight/workspace",
61+
headers=self.experimental_headers,
62+
)
63+
return [i["workspaceId"] for i in result["values"]]
64+
65+
def _get_insight_workspace_id(self):
66+
"""
67+
Returns the first Insight workspace ID.
68+
:return: str
69+
"""
70+
return next(iter(self._get_insight_workspace_ids()))
71+
5472
# Attachments
5573
def get_attachments_of_objects(self, object_id):
5674
"""
@@ -600,3 +618,27 @@ def get_progress_of_import(self, import_id):
600618
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-put
601619
# TODO: Delete config statustype {id}:
602620
# https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-delete
621+
622+
# Update Issue with Insight Field
623+
def update_issue_insight_field(self, key, field_id, insight_keys, add=False):
624+
"""
625+
Set the value of an Insight field.
626+
Args:
627+
key (str): Jira issue key, eg. SFT-446
628+
field_id (str): The internal Jira name of the Insight field, eg. customfield_10200
629+
insight_keys (list): List of Insight objects to associate with the field. Limited
630+
to 20 objects. If the field only takes a single object pass a single value list.
631+
add (bool, optional): Add to the existing field rather than setting the field value.
632+
Defaults to False.
633+
Returns:
634+
[type]: The insight object updated.
635+
"""
636+
base_url = self.resource_url("issue")
637+
action = "add" if add else "set"
638+
data = {
639+
"update": {
640+
field_id: [{action: [{"key": i} for i in insight_keys]}],
641+
}
642+
}
643+
data = {"fields": {field_id: [{"key": i} for i in insight_keys]}}
644+
return self.put("{base_url}/{key}".format(base_url=base_url, key=key), data=data)

atlassian/jira.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,10 +1872,27 @@ def user_get_websudo(self):
18721872

18731873
def invalidate_websudo(self):
18741874
"""
1875-
This method invalidates the any current WebSudo session.
1875+
This method invalidates any current WebSudo session.
18761876
"""
18771877
return self.delete("rest/auth/1/websudo")
18781878

1879+
def users_get_all(
1880+
self,
1881+
start=0,
1882+
limit=50,
1883+
):
1884+
"""
1885+
:param start:
1886+
:param limit:
1887+
:return:
1888+
"""
1889+
url = self.resource_url("users/search")
1890+
params = {
1891+
"startAt": start,
1892+
"maxResults": limit,
1893+
}
1894+
return self.get(url, params=params)
1895+
18791896
def user_find_by_user_string(
18801897
self,
18811898
username=None,
@@ -1909,8 +1926,8 @@ def user_find_by_user_string(
19091926
"""
19101927
url = self.resource_url("user/search")
19111928
params = {
1912-
"includeActive": include_active_users,
1913-
"includeInactive": include_inactive_users,
1929+
"includeActive": str(include_active_users).lower(),
1930+
"includeInactive": str(include_inactive_users).lower(),
19141931
"startAt": start,
19151932
"maxResults": limit,
19161933
}

0 commit comments

Comments
 (0)