Skip to main content

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