Azure DevOps Rust API
azure_devops_rust_api implements a Rust interface to the Azure DevOps REST API (version 7.1).
The crate is autogenerated from the Azure DevOps OpenAPI spec.
Getting started
- Add the crate to your
Cargo.toml, enabling the feature(s) you need:
[]
= { = "0.36.0", = ["git", "pipelines"] }
- Set environment variables:
-
Authenticate — see the Authentication section below.
-
Create a client and call the API — see the Usage section and examples.
Authentication
Two authentication methods are supported:
Azure CLI (recommended for development)
Run az login once, then:
use Credential;
use AzureCliCredential;
let cli_credential = new?;
let credential = from_token_credential;
Personal Access Token (PAT)
Create a PAT with the minimum required scopes and a short expiry, then:
use Credential;
let token = var.expect;
let credential = from_pat;
Note: Treat PATs like passwords — grant only the minimum required scopes and set a short expiry.
Usage
All modules follow the same pattern:
- Obtain a
Credential(see Authentication above). - Create a top-level client via
<module>::ClientBuilder::new(credential).build(). - Obtain a sub-client for the resource you want (e.g.
repositories_client()). - Call the operation method. Mandatory parameters are positional arguments; optional parameters
are set via builder methods. Finalize and send the request by
.awaiting the builder (the builder implementsIntoFuture).
Example
use Result;
use git;
use Credential;
use AzureCliCredential;
use env;
async
See examples/git_repo_list.rs for the full runnable version.
Available features
Each Azure DevOps API area is a separate, opt-in feature. Enable only the ones you need.
| Feature | Description |
|---|---|
git |
Repositories, pull requests, commits, branches |
build |
Build definitions and pipeline runs |
pipelines |
YAML pipelines |
release |
Release definitions and deployments |
wit |
Work items and queries |
test / test_plan / test_results |
Test management |
artifacts |
Azure Artifacts feeds and packages |
artifacts_download |
Higher-level Universal Package download client (see below) |
wiki |
Wikis and pages |
graph |
Users, groups, and memberships |
core |
Projects and teams |
distributed_task |
Agent pools, task groups, environments |
policy |
Branch policies |
security |
Security namespaces and ACLs |
search |
Code, work item, and wiki search |
tfvc |
Team Foundation Version Control |
profile |
User profiles |
audit |
Audit log |
hooks |
Service hooks |
status |
Service health |
work |
Boards, sprints, and backlogs |
See the [features] section of Cargo.toml for the complete list.
Artifact downloads
In addition to the auto-generated REST API wrappers, the crate includes a higher-level
artifacts_download module for downloading Universal Packages
from Azure Artifacts.
Unlike the other modules, artifacts_download is not a thin wrapper around a single REST
endpoint. It implements the full dedup-based download protocol: discovering service URLs,
fetching package metadata, resolving blob IDs, downloading and decompressing content chunks,
and reassembling them into files on disk.
Enable it with the artifacts_download feature:
[]
= { = "0.36.0", = ["artifacts_download"] }
See examples/download_artifact.rs for a full usage example.
Run the example:
Examples
The examples/ directory contains runnable examples for most API areas.
Run an example:
If you omit the required --features flag you will get a helpful error message listing what
is needed.
Minimum supported Rust version (MSRV)
This crate requires Rust 1.80.0 or later.
Issue reporting
Please raise bugs and feature requests via GitHub Issues.
If the issue is in the underlying OpenAPI spec (wrong types, missing fields, incorrect paths), it is better raised against vsts-rest-api-specs, as fixes there will automatically flow into this crate on the next regeneration.