diff --git a/README.rst b/README.rst index 9c5ce860e..1614e20f7 100644 --- a/README.rst +++ b/README.rst @@ -5,9 +5,19 @@ Atlassian Python API wrapper What is it? ___________ -This package is used to provide a **simple** python interface for interacting with Atlassian products -(Server, Data Center and Cloud) and apps from ecosystem (Portfolio, XRay). -It is based on the official public Rest API documentation and private methods (+ xml+rpc, raw http request). +The **atlassian-python-api** library provides a **simple** and convenient way to interact with Atlassian products +(such as Jira Service management, Jira Software, Confluence, Bitbucket and apps Insight, X-Ray) using Python. +It is based on the official REST APIs of these products, as well as additional private methods and protocols +(such as xml+rpc and raw HTTP requests). +This library can be used to automate tasks, integrate with other tools and systems, +and build custom applications that interact with Atlassian products. +It supports a wide range of Atlassian products, including Jira, Confluence, Bitbucket, and others, +and is compatible with both Atlassian Server and Cloud instances. + +Overall, the **atlassian-python-api** is a useful tool for Python developers who want to work with Atlassian products. +It is well-documented and actively maintained, and provides a convenient way to access the full range of +functionality offered by the Atlassian REST APIs. + Documentation _____________ diff --git a/atlassian/insight.py b/atlassian/insight.py index 06018fa76..7a37e2f31 100644 --- a/atlassian/insight.py +++ b/atlassian/insight.py @@ -51,6 +51,24 @@ def __get_workspace_id(self): 0 ]["workspaceId"] + def _get_insight_workspace_ids(self): + """ + Returns all Insight workspace Ids. + :return: List + """ + result = self.get( + "rest/servicedeskapi/insight/workspace", + headers=self.experimental_headers, + ) + return [i["workspaceId"] for i in result["values"]] + + def _get_insight_workspace_id(self): + """ + Returns the first Insight workspace ID. + :return: str + """ + return next(iter(self._get_insight_workspace_ids())) + # Attachments def get_attachments_of_objects(self, object_id): """ @@ -600,3 +618,27 @@ def get_progress_of_import(self, import_id): # https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-put # TODO: Delete config statustype {id}: # https://developer.atlassian.com/cloud/insight/rest/api-group-config/#api-config-statustype-id-delete + + # Update Issue with Insight Field + def update_issue_insight_field(self, key, field_id, insight_keys, add=False): + """ + Set the value of an Insight field. + Args: + key (str): Jira issue key, eg. SFT-446 + field_id (str): The internal Jira name of the Insight field, eg. customfield_10200 + insight_keys (list): List of Insight objects to associate with the field. Limited + to 20 objects. If the field only takes a single object pass a single value list. + add (bool, optional): Add to the existing field rather than setting the field value. + Defaults to False. + Returns: + [type]: The insight object updated. + """ + base_url = self.resource_url("issue") + action = "add" if add else "set" + data = { + "update": { + field_id: [{action: [{"key": i} for i in insight_keys]}], + } + } + data = {"fields": {field_id: [{"key": i} for i in insight_keys]}} + return self.put("{base_url}/{key}".format(base_url=base_url, key=key), data=data) diff --git a/atlassian/jira.py b/atlassian/jira.py index d8b86fe14..3f7bfaf69 100644 --- a/atlassian/jira.py +++ b/atlassian/jira.py @@ -1872,10 +1872,27 @@ def user_get_websudo(self): def invalidate_websudo(self): """ - This method invalidates the any current WebSudo session. + This method invalidates any current WebSudo session. """ return self.delete("rest/auth/1/websudo") + def users_get_all( + self, + start=0, + limit=50, + ): + """ + :param start: + :param limit: + :return: + """ + url = self.resource_url("users/search") + params = { + "startAt": start, + "maxResults": limit, + } + return self.get(url, params=params) + def user_find_by_user_string( self, username=None, @@ -1909,8 +1926,8 @@ def user_find_by_user_string( """ url = self.resource_url("user/search") params = { - "includeActive": include_active_users, - "includeInactive": include_inactive_users, + "includeActive": str(include_active_users).lower(), + "includeInactive": str(include_inactive_users).lower(), "startAt": start, "maxResults": limit, }