Skip to main content

google_cloud_auditmanager_v1/
client.rs

1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Audit Manager API.
20///
21/// # Example
22/// ```
23/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24/// # use google_cloud_auditmanager_v1::client::AuditManager;
25/// let client = AuditManager::builder().build().await?;
26/// // use `client` to make requests to the Audit Manager API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// Service describing handlers for resources
33///
34/// # Configuration
35///
36/// To configure `AuditManager` use the `with_*` methods in the type returned
37/// by [builder()][AuditManager::builder]. The default configuration should
38/// work for most applications. Common configuration changes include
39///
40/// * [with_endpoint()]: by default this client uses the global default endpoint
41///   (`https://auditmanager.googleapis.com`). Applications using regional
42///   endpoints or running in restricted networks (e.g. a network configured
43//    with [Private Google Access with VPC Service Controls]) may want to
44///   override this default.
45/// * [with_credentials()]: by default this client uses
46///   [Application Default Credentials]. Applications using custom
47///   authentication may need to override this default.
48///
49/// [with_endpoint()]: super::builder::audit_manager::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::audit_manager::ClientBuilder::credentials
51/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
52/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
53///
54/// # Pooling and Cloning
55///
56/// `AuditManager` holds a connection pool internally, it is advised to
57/// create one and the reuse it.  You do not need to wrap `AuditManager` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[derive(Clone, Debug)]
61pub struct AuditManager {
62    inner: std::sync::Arc<dyn super::stub::dynamic::AuditManager>,
63}
64
65impl AuditManager {
66    /// Returns a builder for [AuditManager].
67    ///
68    /// ```
69    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
70    /// # use google_cloud_auditmanager_v1::client::AuditManager;
71    /// let client = AuditManager::builder().build().await?;
72    /// # Ok(()) }
73    /// ```
74    pub fn builder() -> super::builder::audit_manager::ClientBuilder {
75        crate::new_client_builder(super::builder::audit_manager::client::Factory)
76    }
77
78    /// Creates a new client from the provided stub.
79    ///
80    /// The most common case for calling this function is in tests mocking the
81    /// client's behavior.
82    pub fn from_stub<T>(stub: T) -> Self
83    where
84        T: super::stub::AuditManager + 'static,
85    {
86        Self {
87            inner: std::sync::Arc::new(stub),
88        }
89    }
90
91    pub(crate) async fn new(
92        config: gaxi::options::ClientConfig,
93    ) -> crate::ClientBuilderResult<Self> {
94        let inner = Self::build_inner(config).await?;
95        Ok(Self { inner })
96    }
97
98    async fn build_inner(
99        conf: gaxi::options::ClientConfig,
100    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AuditManager>> {
101        if gaxi::options::tracing_enabled(&conf) {
102            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
103        }
104        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
105    }
106
107    async fn build_transport(
108        conf: gaxi::options::ClientConfig,
109    ) -> crate::ClientBuilderResult<impl super::stub::AuditManager> {
110        super::transport::AuditManager::new(conf).await
111    }
112
113    async fn build_with_tracing(
114        conf: gaxi::options::ClientConfig,
115    ) -> crate::ClientBuilderResult<impl super::stub::AuditManager> {
116        Self::build_transport(conf)
117            .await
118            .map(super::tracing::AuditManager::new)
119    }
120
121    /// Enrolls the customer resource(folder/project/organization) to the audit
122    /// manager service by creating the audit managers Service Agent in customers
123    /// workload and granting required permissions to the Service Agent. Please
124    /// note that if enrollment request is made on the already enrolled workload
125    /// then enrollment is executed overriding the existing set of destinations.
126    pub fn enroll_resource(&self) -> super::builder::audit_manager::EnrollResource {
127        super::builder::audit_manager::EnrollResource::new(self.inner.clone())
128    }
129
130    /// Generates a demo report highlighting different responsibilities
131    /// (Google/Customer/ shared) required to be fulfilled for the customer's
132    /// workload to be compliant with the given standard.
133    pub fn generate_audit_scope_report(
134        &self,
135    ) -> super::builder::audit_manager::GenerateAuditScopeReport {
136        super::builder::audit_manager::GenerateAuditScopeReport::new(self.inner.clone())
137    }
138
139    /// Register the Audit Report generation requests and returns the OperationId
140    /// using which the customer can track the report generation progress.
141    ///
142    /// # Long running operations
143    ///
144    /// This method is used to start, and/or poll a [long-running Operation].
145    /// The [Working with long-running operations] chapter in the [user guide]
146    /// covers these operations in detail.
147    ///
148    /// [long-running operation]: https://google.aip.dev/151
149    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
150    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
151    pub fn generate_audit_report(&self) -> super::builder::audit_manager::GenerateAuditReport {
152        super::builder::audit_manager::GenerateAuditReport::new(self.inner.clone())
153    }
154
155    /// Lists audit reports in the selected parent scope
156    pub fn list_audit_reports(&self) -> super::builder::audit_manager::ListAuditReports {
157        super::builder::audit_manager::ListAuditReports::new(self.inner.clone())
158    }
159
160    /// Get the overall audit report
161    pub fn get_audit_report(&self) -> super::builder::audit_manager::GetAuditReport {
162        super::builder::audit_manager::GetAuditReport::new(self.inner.clone())
163    }
164
165    /// Get a resource along with its enrollment status.
166    pub fn get_resource_enrollment_status(
167        &self,
168    ) -> super::builder::audit_manager::GetResourceEnrollmentStatus {
169        super::builder::audit_manager::GetResourceEnrollmentStatus::new(self.inner.clone())
170    }
171
172    /// Fetches all resources under the parent along with their enrollment.
173    pub fn list_resource_enrollment_statuses(
174        &self,
175    ) -> super::builder::audit_manager::ListResourceEnrollmentStatuses {
176        super::builder::audit_manager::ListResourceEnrollmentStatuses::new(self.inner.clone())
177    }
178
179    /// Gets controls needed to be implemented to be compliant to a standard.
180    pub fn list_controls(&self) -> super::builder::audit_manager::ListControls {
181        super::builder::audit_manager::ListControls::new(self.inner.clone())
182    }
183
184    /// Lists information about the supported locations for this service.
185    /// This method can be called in two ways:
186    ///
187    /// * **List all public locations:** Use the path `GET /v1/locations`.
188    /// * **List project-visible locations:** Use the path
189    ///   `GET /v1/projects/{project_id}/locations`. This may include public
190    ///   locations as well as private or other locations specifically visible
191    ///   to the project.
192    pub fn list_locations(&self) -> super::builder::audit_manager::ListLocations {
193        super::builder::audit_manager::ListLocations::new(self.inner.clone())
194    }
195
196    /// Gets information about a location.
197    pub fn get_location(&self) -> super::builder::audit_manager::GetLocation {
198        super::builder::audit_manager::GetLocation::new(self.inner.clone())
199    }
200
201    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
202    ///
203    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
204    pub fn list_operations(&self) -> super::builder::audit_manager::ListOperations {
205        super::builder::audit_manager::ListOperations::new(self.inner.clone())
206    }
207
208    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
209    ///
210    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
211    pub fn get_operation(&self) -> super::builder::audit_manager::GetOperation {
212        super::builder::audit_manager::GetOperation::new(self.inner.clone())
213    }
214
215    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
216    ///
217    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
218    pub fn delete_operation(&self) -> super::builder::audit_manager::DeleteOperation {
219        super::builder::audit_manager::DeleteOperation::new(self.inner.clone())
220    }
221
222    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
223    ///
224    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
225    pub fn cancel_operation(&self) -> super::builder::audit_manager::CancelOperation {
226        super::builder::audit_manager::CancelOperation::new(self.inner.clone())
227    }
228}