azure-devops 0.1.0

Idiomatic Rust client for Azure DevOps REST APIs
Documentation
use crate::auth::Credentials;
use crate::builds::BuildsClient;
use crate::http::HttpClient;
use crate::pipelines::PipelinesClient;
use crate::projects::ProjectsClient;
use crate::pull_requests::PullRequestsClient;
use crate::repositories::RepositoriesClient;
use crate::work_items::WorkItemsClient;
use url::Url;

/// The main entry point for interacting with Azure DevOps.
///
/// Create an instance using [`AzureDevOps::builder()`] or
/// [`AzureDevOpsBuilder`](crate::AzureDevOpsBuilder).
///
/// # Example
///
/// ```no_run
/// use azure_devops::AzureDevOps;
///
/// let client = AzureDevOps::builder()
///     .organization("my-company")
///     .pat("my-token")
///     .build()
///     .unwrap();
/// ```
#[derive(Debug, Clone)]
pub struct AzureDevOps {
    pub(crate) http: HttpClient,
}

impl AzureDevOps {
    #[doc(hidden)]
    pub fn new(
        inner: reqwest::Client,
        base_url: Url,
        credentials: Credentials,
        api_version: String,
    ) -> Self {
        let http = HttpClient::new(inner, base_url, credentials, api_version);
        Self { http }
    }

    /// Create a new [`AzureDevOpsBuilder`].
    pub fn builder() -> crate::AzureDevOpsBuilder {
        crate::AzureDevOpsBuilder::new()
    }

    /// Access the Projects API.
    ///
    /// Returns a client that provides methods for listing, getting,
    /// creating, and updating Azure DevOps projects.
    pub fn projects(&self) -> ProjectsClient<'_> {
        ProjectsClient::new(&self.http)
    }

    /// Access the Work Items API.
    ///
    /// Returns a client that provides methods for creating, reading,
    /// updating, deleting, and querying work items.
    pub fn work_items(&self) -> WorkItemsClient<'_> {
        WorkItemsClient::new(&self.http)
    }

    /// Access the Git Repositories API.
    ///
    /// Returns a client that provides methods for creating, reading,
    /// updating, and deleting Git repositories, as well as managing
    /// refs, commits, branches, items, pushes, and statuses.
    pub fn repositories(&self) -> RepositoriesClient<'_> {
        RepositoriesClient::new(&self.http)
    }

    /// Access the Pull Requests API.
    ///
    /// Returns a client that provides methods for creating, reading,
    /// updating pull requests, as well as managing comments, threads,
    /// reviewers, commits, and work item references.
    pub fn pull_requests(&self) -> PullRequestsClient<'_> {
        PullRequestsClient::new(&self.http)
    }

    /// Access the Build API.
    ///
    /// Returns a client that provides methods for listing, getting,
    /// and queueing classic builds, as well as managing build
    /// definitions, artifacts, logs, timelines, tags, and changes.
    pub fn builds(&self) -> BuildsClient<'_> {
        BuildsClient::new(&self.http)
    }

    /// Access the Pipelines (YAML) API.
    ///
    /// Returns a client that provides methods for listing, getting,
    /// creating, and running YAML pipelines, as well as accessing
    /// pipeline runs, logs, and artifacts.
    pub fn pipelines(&self) -> PipelinesClient<'_> {
        PipelinesClient::new(&self.http)
    }
}