google_cloud_cloudcontrolspartner_v1/
client.rs

1// Copyright 2025 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 Cloud Controls Partner API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
25/// let client = CloudControlsPartnerCore::builder().build().await?;
26/// // use `client` to make requests to the Cloud Controls Partner API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Service describing handlers for resources
33///
34/// # Configuration
35///
36/// To configure `CloudControlsPartnerCore` use the `with_*` methods in the type returned
37/// by [builder()][CloudControlsPartnerCore::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://cloudcontrolspartner.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::cloud_controls_partner_core::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::cloud_controls_partner_core::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/// `CloudControlsPartnerCore` holds a connection pool internally, it is advised to
57/// create one and the reuse it.  You do not need to wrap `CloudControlsPartnerCore` 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 CloudControlsPartnerCore {
62    inner: std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerCore>,
63}
64
65impl CloudControlsPartnerCore {
66    /// Returns a builder for [CloudControlsPartnerCore].
67    ///
68    /// ```
69    /// # tokio_test::block_on(async {
70    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerCore;
71    /// let client = CloudControlsPartnerCore::builder().build().await?;
72    /// # gax::client_builder::Result::<()>::Ok(()) });
73    /// ```
74    pub fn builder() -> super::builder::cloud_controls_partner_core::ClientBuilder {
75        gax::client_builder::internal::new_builder(
76            super::builder::cloud_controls_partner_core::client::Factory,
77        )
78    }
79
80    /// Creates a new client from the provided stub.
81    ///
82    /// The most common case for calling this function is in tests mocking the
83    /// client's behavior.
84    pub fn from_stub<T>(stub: T) -> Self
85    where
86        T: super::stub::CloudControlsPartnerCore + 'static,
87    {
88        Self {
89            inner: std::sync::Arc::new(stub),
90        }
91    }
92
93    pub(crate) async fn new(
94        config: gaxi::options::ClientConfig,
95    ) -> gax::client_builder::Result<Self> {
96        let inner = Self::build_inner(config).await?;
97        Ok(Self { inner })
98    }
99
100    async fn build_inner(
101        conf: gaxi::options::ClientConfig,
102    ) -> gax::client_builder::Result<
103        std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerCore>,
104    > {
105        if gaxi::options::tracing_enabled(&conf) {
106            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
107        }
108        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
109    }
110
111    async fn build_transport(
112        conf: gaxi::options::ClientConfig,
113    ) -> gax::client_builder::Result<impl super::stub::CloudControlsPartnerCore> {
114        super::transport::CloudControlsPartnerCore::new(conf).await
115    }
116
117    async fn build_with_tracing(
118        conf: gaxi::options::ClientConfig,
119    ) -> gax::client_builder::Result<impl super::stub::CloudControlsPartnerCore> {
120        Self::build_transport(conf)
121            .await
122            .map(super::tracing::CloudControlsPartnerCore::new)
123    }
124
125    /// Gets details of a single workload
126    pub fn get_workload(&self) -> super::builder::cloud_controls_partner_core::GetWorkload {
127        super::builder::cloud_controls_partner_core::GetWorkload::new(self.inner.clone())
128    }
129
130    /// Lists customer workloads for a given customer org id
131    pub fn list_workloads(&self) -> super::builder::cloud_controls_partner_core::ListWorkloads {
132        super::builder::cloud_controls_partner_core::ListWorkloads::new(self.inner.clone())
133    }
134
135    /// Gets details of a single customer
136    pub fn get_customer(&self) -> super::builder::cloud_controls_partner_core::GetCustomer {
137        super::builder::cloud_controls_partner_core::GetCustomer::new(self.inner.clone())
138    }
139
140    /// Lists customers of a partner identified by its Google Cloud organization ID
141    pub fn list_customers(&self) -> super::builder::cloud_controls_partner_core::ListCustomers {
142        super::builder::cloud_controls_partner_core::ListCustomers::new(self.inner.clone())
143    }
144
145    /// Gets the EKM connections associated with a workload
146    pub fn get_ekm_connections(
147        &self,
148    ) -> super::builder::cloud_controls_partner_core::GetEkmConnections {
149        super::builder::cloud_controls_partner_core::GetEkmConnections::new(self.inner.clone())
150    }
151
152    /// Gets the partner permissions granted for a workload
153    pub fn get_partner_permissions(
154        &self,
155    ) -> super::builder::cloud_controls_partner_core::GetPartnerPermissions {
156        super::builder::cloud_controls_partner_core::GetPartnerPermissions::new(self.inner.clone())
157    }
158
159    /// Deprecated: Only returns access approval requests directly associated with
160    /// an assured workload folder.
161    #[deprecated]
162    pub fn list_access_approval_requests(
163        &self,
164    ) -> super::builder::cloud_controls_partner_core::ListAccessApprovalRequests {
165        super::builder::cloud_controls_partner_core::ListAccessApprovalRequests::new(
166            self.inner.clone(),
167        )
168    }
169
170    /// Get details of a Partner.
171    pub fn get_partner(&self) -> super::builder::cloud_controls_partner_core::GetPartner {
172        super::builder::cloud_controls_partner_core::GetPartner::new(self.inner.clone())
173    }
174
175    /// Creates a new customer.
176    pub fn create_customer(&self) -> super::builder::cloud_controls_partner_core::CreateCustomer {
177        super::builder::cloud_controls_partner_core::CreateCustomer::new(self.inner.clone())
178    }
179
180    /// Update details of a single customer
181    pub fn update_customer(&self) -> super::builder::cloud_controls_partner_core::UpdateCustomer {
182        super::builder::cloud_controls_partner_core::UpdateCustomer::new(self.inner.clone())
183    }
184
185    /// Delete details of a single customer
186    pub fn delete_customer(&self) -> super::builder::cloud_controls_partner_core::DeleteCustomer {
187        super::builder::cloud_controls_partner_core::DeleteCustomer::new(self.inner.clone())
188    }
189}
190
191/// Implements a client for the Cloud Controls Partner API.
192///
193/// # Example
194/// ```
195/// # tokio_test::block_on(async {
196/// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
197/// let client = CloudControlsPartnerMonitoring::builder().build().await?;
198/// // use `client` to make requests to the Cloud Controls Partner API.
199/// # gax::client_builder::Result::<()>::Ok(()) });
200/// ```
201///
202/// # Service Description
203///
204/// Service describing handlers for resources
205///
206/// # Configuration
207///
208/// To configure `CloudControlsPartnerMonitoring` use the `with_*` methods in the type returned
209/// by [builder()][CloudControlsPartnerMonitoring::builder]. The default configuration should
210/// work for most applications. Common configuration changes include
211///
212/// * [with_endpoint()]: by default this client uses the global default endpoint
213///   (`https://cloudcontrolspartner.googleapis.com`). Applications using regional
214///   endpoints or running in restricted networks (e.g. a network configured
215//    with [Private Google Access with VPC Service Controls]) may want to
216///   override this default.
217/// * [with_credentials()]: by default this client uses
218///   [Application Default Credentials]. Applications using custom
219///   authentication may need to override this default.
220///
221/// [with_endpoint()]: super::builder::cloud_controls_partner_monitoring::ClientBuilder::with_endpoint
222/// [with_credentials()]: super::builder::cloud_controls_partner_monitoring::ClientBuilder::credentials
223/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
224/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
225///
226/// # Pooling and Cloning
227///
228/// `CloudControlsPartnerMonitoring` holds a connection pool internally, it is advised to
229/// create one and the reuse it.  You do not need to wrap `CloudControlsPartnerMonitoring` in
230/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
231/// already uses an `Arc` internally.
232#[derive(Clone, Debug)]
233pub struct CloudControlsPartnerMonitoring {
234    inner: std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerMonitoring>,
235}
236
237impl CloudControlsPartnerMonitoring {
238    /// Returns a builder for [CloudControlsPartnerMonitoring].
239    ///
240    /// ```
241    /// # tokio_test::block_on(async {
242    /// # use google_cloud_cloudcontrolspartner_v1::client::CloudControlsPartnerMonitoring;
243    /// let client = CloudControlsPartnerMonitoring::builder().build().await?;
244    /// # gax::client_builder::Result::<()>::Ok(()) });
245    /// ```
246    pub fn builder() -> super::builder::cloud_controls_partner_monitoring::ClientBuilder {
247        gax::client_builder::internal::new_builder(
248            super::builder::cloud_controls_partner_monitoring::client::Factory,
249        )
250    }
251
252    /// Creates a new client from the provided stub.
253    ///
254    /// The most common case for calling this function is in tests mocking the
255    /// client's behavior.
256    pub fn from_stub<T>(stub: T) -> Self
257    where
258        T: super::stub::CloudControlsPartnerMonitoring + 'static,
259    {
260        Self {
261            inner: std::sync::Arc::new(stub),
262        }
263    }
264
265    pub(crate) async fn new(
266        config: gaxi::options::ClientConfig,
267    ) -> gax::client_builder::Result<Self> {
268        let inner = Self::build_inner(config).await?;
269        Ok(Self { inner })
270    }
271
272    async fn build_inner(
273        conf: gaxi::options::ClientConfig,
274    ) -> gax::client_builder::Result<
275        std::sync::Arc<dyn super::stub::dynamic::CloudControlsPartnerMonitoring>,
276    > {
277        if gaxi::options::tracing_enabled(&conf) {
278            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
279        }
280        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
281    }
282
283    async fn build_transport(
284        conf: gaxi::options::ClientConfig,
285    ) -> gax::client_builder::Result<impl super::stub::CloudControlsPartnerMonitoring> {
286        super::transport::CloudControlsPartnerMonitoring::new(conf).await
287    }
288
289    async fn build_with_tracing(
290        conf: gaxi::options::ClientConfig,
291    ) -> gax::client_builder::Result<impl super::stub::CloudControlsPartnerMonitoring> {
292        Self::build_transport(conf)
293            .await
294            .map(super::tracing::CloudControlsPartnerMonitoring::new)
295    }
296
297    /// Lists Violations for a workload
298    /// Callers may also choose to read across multiple Customers or for a single
299    /// customer as per
300    /// [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash
301    /// character) as a wildcard character instead of {customer} & {workload}.
302    /// Format:
303    /// `organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}`
304    pub fn list_violations(
305        &self,
306    ) -> super::builder::cloud_controls_partner_monitoring::ListViolations {
307        super::builder::cloud_controls_partner_monitoring::ListViolations::new(self.inner.clone())
308    }
309
310    /// Gets details of a single Violation.
311    pub fn get_violation(&self) -> super::builder::cloud_controls_partner_monitoring::GetViolation {
312        super::builder::cloud_controls_partner_monitoring::GetViolation::new(self.inner.clone())
313    }
314}