Skip to main content

azure_devops/
client.rs

1use crate::auth::Credentials;
2use crate::builds::BuildsClient;
3use crate::http::HttpClient;
4use crate::pipelines::PipelinesClient;
5use crate::projects::ProjectsClient;
6use crate::pull_requests::PullRequestsClient;
7use crate::repositories::RepositoriesClient;
8use crate::work_items::WorkItemsClient;
9use url::Url;
10
11/// The main entry point for interacting with Azure DevOps.
12///
13/// Create an instance using [`AzureDevOps::builder()`] or
14/// [`AzureDevOpsBuilder`](crate::AzureDevOpsBuilder).
15///
16/// # Example
17///
18/// ```no_run
19/// use azure_devops::AzureDevOps;
20///
21/// let client = AzureDevOps::builder()
22///     .organization("my-company")
23///     .pat("my-token")
24///     .build()
25///     .unwrap();
26/// ```
27#[derive(Debug, Clone)]
28pub struct AzureDevOps {
29    pub(crate) http: HttpClient,
30}
31
32impl AzureDevOps {
33    #[doc(hidden)]
34    pub fn new(
35        inner: reqwest::Client,
36        base_url: Url,
37        credentials: Credentials,
38        api_version: String,
39    ) -> Self {
40        let http = HttpClient::new(inner, base_url, credentials, api_version);
41        Self { http }
42    }
43
44    /// Create a new [`AzureDevOpsBuilder`].
45    pub fn builder() -> crate::AzureDevOpsBuilder {
46        crate::AzureDevOpsBuilder::new()
47    }
48
49    /// Access the Projects API.
50    ///
51    /// Returns a client that provides methods for listing, getting,
52    /// creating, and updating Azure DevOps projects.
53    pub fn projects(&self) -> ProjectsClient<'_> {
54        ProjectsClient::new(&self.http)
55    }
56
57    /// Access the Work Items API.
58    ///
59    /// Returns a client that provides methods for creating, reading,
60    /// updating, deleting, and querying work items.
61    pub fn work_items(&self) -> WorkItemsClient<'_> {
62        WorkItemsClient::new(&self.http)
63    }
64
65    /// Access the Git Repositories API.
66    ///
67    /// Returns a client that provides methods for creating, reading,
68    /// updating, and deleting Git repositories, as well as managing
69    /// refs, commits, branches, items, pushes, and statuses.
70    pub fn repositories(&self) -> RepositoriesClient<'_> {
71        RepositoriesClient::new(&self.http)
72    }
73
74    /// Access the Pull Requests API.
75    ///
76    /// Returns a client that provides methods for creating, reading,
77    /// updating pull requests, as well as managing comments, threads,
78    /// reviewers, commits, and work item references.
79    pub fn pull_requests(&self) -> PullRequestsClient<'_> {
80        PullRequestsClient::new(&self.http)
81    }
82
83    /// Access the Build API.
84    ///
85    /// Returns a client that provides methods for listing, getting,
86    /// and queueing classic builds, as well as managing build
87    /// definitions, artifacts, logs, timelines, tags, and changes.
88    pub fn builds(&self) -> BuildsClient<'_> {
89        BuildsClient::new(&self.http)
90    }
91
92    /// Access the Pipelines (YAML) API.
93    ///
94    /// Returns a client that provides methods for listing, getting,
95    /// creating, and running YAML pipelines, as well as accessing
96    /// pipeline runs, logs, and artifacts.
97    pub fn pipelines(&self) -> PipelinesClient<'_> {
98        PipelinesClient::new(&self.http)
99    }
100}