google-cloud-build-v1 1.5.0

Google Cloud Client Libraries for Rust - Cloud Build API
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the Cloud Build API.
///
/// # Example
/// ```
/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
/// # use google_cloud_build_v1::client::CloudBuild;
/// let client = CloudBuild::builder().build().await?;
/// // use `client` to make requests to the Cloud Build API.
/// # Ok(()) }
/// ```
///
/// # Service Description
///
/// Creates and manages builds on Google Cloud Platform.
///
/// The main concept used by this API is a `Build`, which describes the location
/// of the source to build, how to build the source, and where to store the
/// built artifacts, if any.
///
/// A user can list previously-requested builds or get builds by their ID to
/// determine the status of the build.
///
/// # Configuration
///
/// To configure `CloudBuild` use the `with_*` methods in the type returned
/// by [builder()][CloudBuild::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://cloudbuild.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::cloud_build::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::cloud_build::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `CloudBuild` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `CloudBuild` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct CloudBuild {
    inner: std::sync::Arc<dyn super::stub::dynamic::CloudBuild>,
}

impl CloudBuild {
    /// Returns a builder for [CloudBuild].
    ///
    /// ```
    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
    /// # use google_cloud_build_v1::client::CloudBuild;
    /// let client = CloudBuild::builder().build().await?;
    /// # Ok(()) }
    /// ```
    pub fn builder() -> super::builder::cloud_build::ClientBuilder {
        crate::new_client_builder(super::builder::cloud_build::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::CloudBuild + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CloudBuild>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::CloudBuild> {
        super::transport::CloudBuild::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> crate::ClientBuilderResult<impl super::stub::CloudBuild> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::CloudBuild::new)
    }

    /// Starts a build with the specified configuration.
    ///
    /// This method returns a long-running `Operation`, which includes the build
    /// ID. Pass the build ID to `GetBuild` to determine the build status (such as
    /// `SUCCESS` or `FAILURE`).
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_build(&self) -> super::builder::cloud_build::CreateBuild {
        super::builder::cloud_build::CreateBuild::new(self.inner.clone())
    }

    /// Returns information about a previously requested build.
    ///
    /// The `Build` that is returned includes its status (such as `SUCCESS`,
    /// `FAILURE`, or `WORKING`), and timing information.
    pub fn get_build(&self) -> super::builder::cloud_build::GetBuild {
        super::builder::cloud_build::GetBuild::new(self.inner.clone())
    }

    /// Lists previously requested builds.
    ///
    /// Previously requested builds may still be in-progress, or may have finished
    /// successfully or unsuccessfully.
    pub fn list_builds(&self) -> super::builder::cloud_build::ListBuilds {
        super::builder::cloud_build::ListBuilds::new(self.inner.clone())
    }

    /// Cancels a build in progress.
    pub fn cancel_build(&self) -> super::builder::cloud_build::CancelBuild {
        super::builder::cloud_build::CancelBuild::new(self.inner.clone())
    }

    /// Creates a new build based on the specified build.
    ///
    /// This method creates a new build using the original build request, which may
    /// or may not result in an identical build.
    ///
    /// For triggered builds:
    ///
    /// * Triggered builds resolve to a precise revision; therefore a retry of a
    ///   triggered build will result in a build that uses the same revision.
    ///
    /// For non-triggered builds that specify `RepoSource`:
    ///
    /// * If the original build built from the tip of a branch, the retried build
    ///   will build from the tip of that branch, which may not be the same revision
    ///   as the original build.
    /// * If the original build specified a commit sha or revision ID, the retried
    ///   build will use the identical source.
    ///
    /// For builds that specify `StorageSource`:
    ///
    /// * If the original build pulled source from Cloud Storage without
    ///   specifying the generation of the object, the new build will use the current
    ///   object, which may be different from the original build source.
    /// * If the original build pulled source from Cloud Storage and specified the
    ///   generation of the object, the new build will attempt to use the same
    ///   object, which may or may not be available depending on the bucket's
    ///   lifecycle management settings.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn retry_build(&self) -> super::builder::cloud_build::RetryBuild {
        super::builder::cloud_build::RetryBuild::new(self.inner.clone())
    }

    /// Approves or rejects a pending build.
    ///
    /// If approved, the returned long-running operation (LRO) will be analogous to
    /// the LRO returned from a CreateBuild call.
    ///
    /// If rejected, the returned LRO will be immediately done.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn approve_build(&self) -> super::builder::cloud_build::ApproveBuild {
        super::builder::cloud_build::ApproveBuild::new(self.inner.clone())
    }

    /// Creates a new `BuildTrigger`.
    pub fn create_build_trigger(&self) -> super::builder::cloud_build::CreateBuildTrigger {
        super::builder::cloud_build::CreateBuildTrigger::new(self.inner.clone())
    }

    /// Returns information about a `BuildTrigger`.
    pub fn get_build_trigger(&self) -> super::builder::cloud_build::GetBuildTrigger {
        super::builder::cloud_build::GetBuildTrigger::new(self.inner.clone())
    }

    /// Lists existing `BuildTrigger`s.
    pub fn list_build_triggers(&self) -> super::builder::cloud_build::ListBuildTriggers {
        super::builder::cloud_build::ListBuildTriggers::new(self.inner.clone())
    }

    /// Deletes a `BuildTrigger` by its project ID and trigger ID.
    pub fn delete_build_trigger(&self) -> super::builder::cloud_build::DeleteBuildTrigger {
        super::builder::cloud_build::DeleteBuildTrigger::new(self.inner.clone())
    }

    /// Updates a `BuildTrigger` by its project ID and trigger ID.
    pub fn update_build_trigger(&self) -> super::builder::cloud_build::UpdateBuildTrigger {
        super::builder::cloud_build::UpdateBuildTrigger::new(self.inner.clone())
    }

    /// Runs a `BuildTrigger` at a particular source revision.
    ///
    /// To run a regional or global trigger, use the POST request
    /// that includes the location endpoint in the path (ex.
    /// v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The
    /// POST request that does not include the location endpoint in the path can
    /// only be used when running global triggers.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn run_build_trigger(&self) -> super::builder::cloud_build::RunBuildTrigger {
        super::builder::cloud_build::RunBuildTrigger::new(self.inner.clone())
    }

    /// ReceiveTriggerWebhook [Experimental] is called when the API receives a
    /// webhook request targeted at a specific trigger.
    pub fn receive_trigger_webhook(&self) -> super::builder::cloud_build::ReceiveTriggerWebhook {
        super::builder::cloud_build::ReceiveTriggerWebhook::new(self.inner.clone())
    }

    /// Creates a `WorkerPool`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_worker_pool(&self) -> super::builder::cloud_build::CreateWorkerPool {
        super::builder::cloud_build::CreateWorkerPool::new(self.inner.clone())
    }

    /// Returns details of a `WorkerPool`.
    pub fn get_worker_pool(&self) -> super::builder::cloud_build::GetWorkerPool {
        super::builder::cloud_build::GetWorkerPool::new(self.inner.clone())
    }

    /// Deletes a `WorkerPool`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_worker_pool(&self) -> super::builder::cloud_build::DeleteWorkerPool {
        super::builder::cloud_build::DeleteWorkerPool::new(self.inner.clone())
    }

    /// Updates a `WorkerPool`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_worker_pool(&self) -> super::builder::cloud_build::UpdateWorkerPool {
        super::builder::cloud_build::UpdateWorkerPool::new(self.inner.clone())
    }

    /// Lists `WorkerPool`s.
    pub fn list_worker_pools(&self) -> super::builder::cloud_build::ListWorkerPools {
        super::builder::cloud_build::ListWorkerPools::new(self.inner.clone())
    }

    /// Returns the `DefaultServiceAccount` used by the project.
    pub fn get_default_service_account(
        &self,
    ) -> super::builder::cloud_build::GetDefaultServiceAccount {
        super::builder::cloud_build::GetDefaultServiceAccount::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::cloud_build::GetOperation {
        super::builder::cloud_build::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::cloud_build::CancelOperation {
        super::builder::cloud_build::CancelOperation::new(self.inner.clone())
    }
}