|
24 | 24 |
|
25 | 25 |
|
26 | 26 | class VstsApiPath:
|
| 27 | + """ |
| 28 | + Endpoints used by the Azure Devops (Formerly 'Visual Studios Team Services') integration client. |
| 29 | + Last Updated: 06/2023 |
| 30 | + """ |
| 31 | + |
| 32 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get |
27 | 33 | commit = "{instance}_apis/git/repositories/{repo_id}/commits/{commit_id}"
|
| 34 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits |
28 | 35 | commits = "{instance}_apis/git/repositories/{repo_id}/commits"
|
| 36 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits-batch |
29 | 37 | commits_batch = "{instance}_apis/git/repositories/{repo_id}/commitsBatch"
|
| 38 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-changes |
30 | 39 | commits_changes = "{instance}_apis/git/repositories/{repo_id}/commits/{commit_id}/changes"
|
| 40 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/get |
31 | 41 | project = "{instance}_apis/projects/{project_id}"
|
| 42 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list |
32 | 43 | projects = "{instance}_apis/projects"
|
| 44 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/get-repository |
33 | 45 | repository = "{instance}{project}_apis/git/repositories/{repo_id}"
|
| 46 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list |
34 | 47 | repositories = "{instance}{project}_apis/git/repositories"
|
| 48 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/get |
| 49 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/delete |
| 50 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/replace-subscription |
35 | 51 | subscription = "{instance}_apis/hooks/subscriptions/{subscription_id}"
|
| 52 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/hooks/subscriptions/create |
36 | 53 | subscriptions = "{instance}_apis/hooks/subscriptions"
|
| 54 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/get-work-item |
| 55 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update |
37 | 56 | work_items = "{instance}_apis/wit/workitems/{id}"
|
| 57 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/create |
38 | 58 | work_items_create = "{instance}{project}/_apis/wit/workitems/${type}"
|
39 |
| - # TODO(lb): Fix this url so that the base url is given by vsts rather than built by us |
| 59 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/search/work-item-search-results/fetch-work-item-search-results |
40 | 60 | work_item_search = (
|
| 61 | + # TODO(lb): Fix this url so that the base url is given by vsts rather than built by us |
41 | 62 | "https://{account_name}.almsearch.visualstudio.com/_apis/search/workitemsearchresults"
|
42 | 63 | )
|
| 64 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-item-type-states/list |
43 | 65 | work_item_states = "{instance}{project}/_apis/wit/workitemtypes/{type}/states"
|
44 |
| - # TODO(lb): Fix this url so that the base url is given by vsts rather than built by us |
45 |
| - users = "https://{account_name}.vssps.visualstudio.com/_apis/graph/users" |
| 66 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/get |
| 67 | + users = ( |
| 68 | + # TODO(lb): Fix this url so that the base url is given by vsts rather than built by us |
| 69 | + "https://{account_name}.vssps.visualstudio.com/_apis/graph/users" |
| 70 | + ) |
| 71 | + # https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-item-type-categories/list |
46 | 72 | work_item_categories = "{instance}{project}/_apis/wit/workitemtypecategories"
|
47 | 73 |
|
48 | 74 |
|
@@ -166,15 +192,23 @@ def get_work_item(self, instance: str, id: str) -> Response:
|
166 | 192 | return self.get(VstsApiPath.work_items.format(instance=instance, id=id))
|
167 | 193 |
|
168 | 194 | def get_work_item_states(self, instance: str, project: str) -> Response:
|
169 |
| - return self.get( |
170 |
| - VstsApiPath.work_item_states.format( |
171 |
| - instance=instance, |
172 |
| - project=project, |
173 |
| - # TODO(lb): might want to make this custom like jira at some point |
174 |
| - type="Bug", |
175 |
| - ), |
176 |
| - api_preview=True, |
177 |
| - ) |
| 195 | + # XXX: Until we add the option to enter the 'WorkItemType' for syncing status changes from |
| 196 | + # Sentry to Azure DevOps, we need will attempt to use the sequence below. There are certain |
| 197 | + # ADO configurations which don't have 'Bug' or 'Issue', hence iterating until we find a match. |
| 198 | + check_sequence = ["Bug", "Issue", "Task"] |
| 199 | + response = None |
| 200 | + for check_type in check_sequence: |
| 201 | + response = self.get( |
| 202 | + VstsApiPath.work_item_states.format( |
| 203 | + instance=instance, |
| 204 | + project=project, |
| 205 | + type=check_type, |
| 206 | + ), |
| 207 | + api_preview=True, |
| 208 | + ) |
| 209 | + if response.get("count", 0) > 0: |
| 210 | + break |
| 211 | + return response |
178 | 212 |
|
179 | 213 | def get_work_item_categories(self, instance: str, project: str) -> Response:
|
180 | 214 | return self.get(VstsApiPath.work_item_categories.format(instance=instance, project=project))
|
|
0 commit comments