Requests wrapper for Azure DevOps
Project description
Azure requests
Just a wrapper around Python requests module for communicating with Azure DevOps.
DRY (don't repeat yourself) features
- Authentication
- Replace organization, project, and team in URL, so URLs can be copy-pasted from the documentation
- Handle rate limit
- Handle ADO temporary server errors
- Set appropriate Content-Type headers
- Parse JSON automatically
- Raise exception for wrong HTTPS statuses
Rationale
Azure DevOps has an excellent HTTPS API with an excellent documentation. It is easy to understand and easy to use. For smaller scripts and projects it is easier to use them as is. Every existing API implementations have many documentation issues.
Example
from azure_requests import AzureRequests
azure_requests = AzureRequests(
pat="<YOUR PAT>",
organization="<YOUR ORGANIZATION>",
)
WORK_ITEM_ID = 12345
work_item_fields = azure_requests.call(
# Copy-pasted from https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-7.0&tabs=HTTP
"PATCH https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=7.0",
# custom URL parameters
params={
"id": WORK_ITEM_ID,
},
# JSON data
data=[
{
"op": "test",
"path": "/id",
"value": WORK_ITEM_ID,
}
],
# syntactic sugar for azure_requests.call(...)[result_key]
result_key="fields"
)
print(work_item_fields)
For a more detailed example see example.py
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
azure_requests-24.3.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file azure_requests-24.3.tar.gz
.
File metadata
- Download URL: azure_requests-24.3.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7c8a87ed8917f423816aaf22e0e1790c4c7c0cc2d8325702e047e98ea683c1 |
|
MD5 | 723a0a4ab2975bd5efbb50253f77d937 |
|
BLAKE2b-256 | 454d7c99a902b79e32d88e4b8ff4e946dbd84ce246c2590008c5a752f3e96055 |
File details
Details for the file azure_requests-24.3-py3-none-any.whl
.
File metadata
- Download URL: azure_requests-24.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fed947b5e7e95e1e73967b76b114e5ed02ed0d9ea067bdcdee7cd697abf76a4 |
|
MD5 | c297b4e74025d91ddd6d438aaf39776d |
|
BLAKE2b-256 | 45643ce36f9b18210959cf1440a1f1ce480d2dba21da8b01c1241e6f404d147a |