Crates.io | azure_devops_rust_api |
lib.rs | azure_devops_rust_api |
version | 0.24.0 |
source | src |
created_at | 2022-07-29 21:49:57.822487 |
updated_at | 2024-11-21 13:08:32.309829 |
description | Rust API library for Azure DevOps |
homepage | https://github.com/microsoft/azure-devops-rust-api |
repository | https://github.com/microsoft/azure-devops-rust-api |
max_upload_size | |
id | 635206 |
size | 11,139,043 |
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.
The crate contains 38 modules
The crate has many features/modules, but the general approach is similar for all:
azure_identity
crategit_client
), and then one for the submodule (e.g. repositories_client
).await
, which transforms
the builder into a Future (via the IntoFuture
trait) and awaits the response.Example usage (from examples/git_repo_list.rs):
// Get authentication credential either from a PAT ("ADO_TOKEN")
// or via the az cli.
let credential = utils::get_credential()
// Get ADO configuration via environment variables
let organization = env::var("ADO_ORGANIZATION")
.expect("Must define ADO_ORGANIZATION");
let project = env::var("ADO_PROJECT")
.expect("Must define ADO_PROJECT");
// Create a git client
let git_client = git::ClientBuilder::new(credential).build();
// Get all repositories in the specified organization/project
let repos = git_client
.repositories_client()
.list(organization, project)
.await?
.value;
// Output repo names
for repo in repos.iter() {
println!("{}", repo.name);
}
println!("{} repos found", repos.len());
Individual modules in the API are enabled via Rust features
.
See the features
section of Cargo.toml for the full list of features.
Example application Cargo.toml
dependency spec showing how to specify desired features:
[dependencies]
...
azure_devops_rust_api = { version = "0.23.0", features = ["git", "pipelines"] }
See examples directory.
Define environment variables:
export ADO_ORGANIZATION=<organization-name>
export ADO_PROJECT=<project-name>
To run the examples you need to provide authentication credentials either via:
az
CLI, where you just need to have authenticated by running az login
before running the examples.ADO_TOKEN
Note: A personal access token contains your security credentials for Azure DevOps. A PAT identifies you, your accessible organizations, and scopes of access. As such, they're as critical as passwords, so you should treat them the same way. When creating a PAT only grant it the minimum required scopes, and set the expiry time to be short.
Run the example via cargo run --example
. You will need to enable the features required
by the example. If you don't specify the necessary features you do get a helpful error
message.
Example:
cargo run --example git_repo_get --features="git" <repo-name>
If you find any issues then please raise them via Github.