Skip to main content

google_cloud_managedidentities_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::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Managed Service for Microsoft Active Directory API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28///    project_id: &str,
29///    location_id: &str,
30/// ) -> anyhow::Result<()> {
31///     let client = ManagedIdentitiesService::builder().build().await?;
32///     let mut list = client.list_domains()
33///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
34///         .by_item();
35///     while let Some(item) = list.next().await.transpose()? {
36///         println!("{:?}", item);
37///     }
38///     Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// API Overview
45///
46/// The `managedidentites.googleapis.com` service implements the Google Cloud
47/// Managed Identites API for identity services
48/// (e.g. Microsoft Active Directory).
49///
50/// The Managed Identities service provides methods to manage
51/// (create/read/update/delete) domains, reset managed identities admin password,
52/// add/remove domain controllers in GCP regions and add/remove VPC peering.
53///
54/// Data Model
55///
56/// The Managed Identities service exposes the following resources:
57///
58/// * Locations as global, named as follows:
59///   `projects/{project_id}/locations/global`.
60///
61/// * Domains, named as follows:
62///   `/projects/{project_id}/locations/global/domain/{domain_name}`.
63///
64///
65/// The `{domain_name}` refers to fully qualified domain name in the customer
66/// project e.g. mydomain.myorganization.com, with the following restrictions:
67///
68/// * Must contain only lowercase letters, numbers, periods and hyphens.
69/// * Must start with a letter.
70/// * Must contain between 2-64 characters.
71/// * Must end with a number or a letter.
72/// * Must not start with period.
73/// * First segement length (mydomain form example above) shouldn't exceed
74///   15 chars.
75/// * The last segment cannot be fully numeric.
76/// * Must be unique within the customer project.
77///
78/// # Configuration
79///
80/// To configure `ManagedIdentitiesService` use the `with_*` methods in the type returned
81/// by [builder()][ManagedIdentitiesService::builder]. The default configuration should
82/// work for most applications. Common configuration changes include
83///
84/// * [with_endpoint()]: by default this client uses the global default endpoint
85///   (`https://managedidentities.googleapis.com`). Applications using regional
86///   endpoints or running in restricted networks (e.g. a network configured
87///   with [Private Google Access with VPC Service Controls]) may want to
88///   override this default.
89/// * [with_credentials()]: by default this client uses
90///   [Application Default Credentials]. Applications using custom
91///   authentication may need to override this default.
92///
93/// [with_endpoint()]: super::builder::managed_identities_service::ClientBuilder::with_endpoint
94/// [with_credentials()]: super::builder::managed_identities_service::ClientBuilder::with_credentials
95/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
96/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
97///
98/// # Pooling and Cloning
99///
100/// `ManagedIdentitiesService` holds a connection pool internally, it is advised to
101/// create one and reuse it. You do not need to wrap `ManagedIdentitiesService` in
102/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
103/// already uses an `Arc` internally.
104#[derive(Clone, Debug)]
105pub struct ManagedIdentitiesService {
106    inner: std::sync::Arc<dyn super::stub::dynamic::ManagedIdentitiesService>,
107}
108
109impl ManagedIdentitiesService {
110    /// Returns a builder for [ManagedIdentitiesService].
111    ///
112    /// ```
113    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
114    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
115    /// let client = ManagedIdentitiesService::builder().build().await?;
116    /// # Ok(()) }
117    /// ```
118    pub fn builder() -> super::builder::managed_identities_service::ClientBuilder {
119        crate::new_client_builder(super::builder::managed_identities_service::client::Factory)
120    }
121
122    /// Creates a new client from the provided stub.
123    ///
124    /// The most common case for calling this function is in tests mocking the
125    /// client's behavior.
126    pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
127    where
128        T: super::stub::ManagedIdentitiesService + 'static,
129    {
130        Self { inner: stub.into() }
131    }
132
133    pub(crate) async fn new(
134        config: gaxi::options::ClientConfig,
135    ) -> crate::ClientBuilderResult<Self> {
136        let inner = Self::build_inner(config).await?;
137        Ok(Self { inner })
138    }
139
140    async fn build_inner(
141        conf: gaxi::options::ClientConfig,
142    ) -> crate::ClientBuilderResult<
143        std::sync::Arc<dyn super::stub::dynamic::ManagedIdentitiesService>,
144    > {
145        if gaxi::options::tracing_enabled(&conf) {
146            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
147        }
148        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
149    }
150
151    async fn build_transport(
152        conf: gaxi::options::ClientConfig,
153    ) -> crate::ClientBuilderResult<impl super::stub::ManagedIdentitiesService> {
154        super::transport::ManagedIdentitiesService::new(conf).await
155    }
156
157    async fn build_with_tracing(
158        conf: gaxi::options::ClientConfig,
159    ) -> crate::ClientBuilderResult<impl super::stub::ManagedIdentitiesService> {
160        Self::build_transport(conf)
161            .await
162            .map(super::tracing::ManagedIdentitiesService::new)
163    }
164
165    /// Creates a Microsoft AD domain.
166    ///
167    /// # Long running operations
168    ///
169    /// This method is used to start, and/or poll a [long-running Operation].
170    /// The [Working with long-running operations] chapter in the [user guide]
171    /// covers these operations in detail.
172    ///
173    /// [long-running operation]: https://google.aip.dev/151
174    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
175    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
176    ///
177    /// # Example
178    /// ```
179    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
180    /// use google_cloud_lro::Poller;
181    /// use google_cloud_managedidentities_v1::model::Domain;
182    /// use google_cloud_managedidentities_v1::Result;
183    /// async fn sample(
184    ///    client: &ManagedIdentitiesService, project_id: &str, location_id: &str
185    /// ) -> Result<()> {
186    ///     let response = client.create_microsoft_ad_domain()
187    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
188    ///         .set_domain(
189    ///             Domain::new()/* set fields */
190    ///         )
191    ///         .poller().until_done().await?;
192    ///     println!("response {:?}", response);
193    ///     Ok(())
194    /// }
195    /// ```
196    pub fn create_microsoft_ad_domain(
197        &self,
198    ) -> super::builder::managed_identities_service::CreateMicrosoftAdDomain {
199        super::builder::managed_identities_service::CreateMicrosoftAdDomain::new(self.inner.clone())
200    }
201
202    /// Resets a domain's administrator password.
203    ///
204    /// # Example
205    /// ```
206    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
207    /// use google_cloud_managedidentities_v1::Result;
208    /// async fn sample(
209    ///    client: &ManagedIdentitiesService
210    /// ) -> Result<()> {
211    ///     let response = client.reset_admin_password()
212    ///         /* set fields */
213    ///         .send().await?;
214    ///     println!("response {:?}", response);
215    ///     Ok(())
216    /// }
217    /// ```
218    pub fn reset_admin_password(
219        &self,
220    ) -> super::builder::managed_identities_service::ResetAdminPassword {
221        super::builder::managed_identities_service::ResetAdminPassword::new(self.inner.clone())
222    }
223
224    /// Lists domains in a project.
225    ///
226    /// # Example
227    /// ```
228    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
229    /// use google_cloud_gax::paginator::ItemPaginator as _;
230    /// use google_cloud_managedidentities_v1::Result;
231    /// async fn sample(
232    ///    client: &ManagedIdentitiesService, project_id: &str, location_id: &str
233    /// ) -> Result<()> {
234    ///     let mut list = client.list_domains()
235    ///         .set_parent(format!("projects/{project_id}/locations/{location_id}"))
236    ///         .by_item();
237    ///     while let Some(item) = list.next().await.transpose()? {
238    ///         println!("{:?}", item);
239    ///     }
240    ///     Ok(())
241    /// }
242    /// ```
243    pub fn list_domains(&self) -> super::builder::managed_identities_service::ListDomains {
244        super::builder::managed_identities_service::ListDomains::new(self.inner.clone())
245    }
246
247    /// Gets information about a domain.
248    ///
249    /// # Example
250    /// ```
251    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
252    /// use google_cloud_managedidentities_v1::Result;
253    /// async fn sample(
254    ///    client: &ManagedIdentitiesService, project_id: &str, location_id: &str, domain_id: &str
255    /// ) -> Result<()> {
256    ///     let response = client.get_domain()
257    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/domains/{domain_id}"))
258    ///         .send().await?;
259    ///     println!("response {:?}", response);
260    ///     Ok(())
261    /// }
262    /// ```
263    pub fn get_domain(&self) -> super::builder::managed_identities_service::GetDomain {
264        super::builder::managed_identities_service::GetDomain::new(self.inner.clone())
265    }
266
267    /// Updates the metadata and configuration of a domain.
268    ///
269    /// # Long running operations
270    ///
271    /// This method is used to start, and/or poll a [long-running Operation].
272    /// The [Working with long-running operations] chapter in the [user guide]
273    /// covers these operations in detail.
274    ///
275    /// [long-running operation]: https://google.aip.dev/151
276    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
277    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
278    ///
279    /// # Example
280    /// ```
281    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
282    /// use google_cloud_lro::Poller;
283    /// # extern crate wkt as google_cloud_wkt;
284    /// use google_cloud_wkt::FieldMask;
285    /// use google_cloud_managedidentities_v1::model::Domain;
286    /// use google_cloud_managedidentities_v1::Result;
287    /// async fn sample(
288    ///    client: &ManagedIdentitiesService, project_id: &str, location_id: &str, domain_id: &str
289    /// ) -> Result<()> {
290    ///     let response = client.update_domain()
291    ///         .set_domain(
292    ///             Domain::new().set_name(format!("projects/{project_id}/locations/{location_id}/domains/{domain_id}"))/* set fields */
293    ///         )
294    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
295    ///         .poller().until_done().await?;
296    ///     println!("response {:?}", response);
297    ///     Ok(())
298    /// }
299    /// ```
300    pub fn update_domain(&self) -> super::builder::managed_identities_service::UpdateDomain {
301        super::builder::managed_identities_service::UpdateDomain::new(self.inner.clone())
302    }
303
304    /// Deletes a domain.
305    ///
306    /// # Long running operations
307    ///
308    /// This method is used to start, and/or poll a [long-running Operation].
309    /// The [Working with long-running operations] chapter in the [user guide]
310    /// covers these operations in detail.
311    ///
312    /// [long-running operation]: https://google.aip.dev/151
313    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
314    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
315    ///
316    /// # Example
317    /// ```
318    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
319    /// use google_cloud_lro::Poller;
320    /// use google_cloud_managedidentities_v1::Result;
321    /// async fn sample(
322    ///    client: &ManagedIdentitiesService, project_id: &str, location_id: &str, domain_id: &str
323    /// ) -> Result<()> {
324    ///     client.delete_domain()
325    ///         .set_name(format!("projects/{project_id}/locations/{location_id}/domains/{domain_id}"))
326    ///         .poller().until_done().await?;
327    ///     Ok(())
328    /// }
329    /// ```
330    pub fn delete_domain(&self) -> super::builder::managed_identities_service::DeleteDomain {
331        super::builder::managed_identities_service::DeleteDomain::new(self.inner.clone())
332    }
333
334    /// Adds an AD trust to a domain.
335    ///
336    /// # Long running operations
337    ///
338    /// This method is used to start, and/or poll a [long-running Operation].
339    /// The [Working with long-running operations] chapter in the [user guide]
340    /// covers these operations in detail.
341    ///
342    /// [long-running operation]: https://google.aip.dev/151
343    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
344    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
345    ///
346    /// # Example
347    /// ```
348    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
349    /// use google_cloud_lro::Poller;
350    /// use google_cloud_managedidentities_v1::Result;
351    /// async fn sample(
352    ///    client: &ManagedIdentitiesService
353    /// ) -> Result<()> {
354    ///     let response = client.attach_trust()
355    ///         /* set fields */
356    ///         .poller().until_done().await?;
357    ///     println!("response {:?}", response);
358    ///     Ok(())
359    /// }
360    /// ```
361    pub fn attach_trust(&self) -> super::builder::managed_identities_service::AttachTrust {
362        super::builder::managed_identities_service::AttachTrust::new(self.inner.clone())
363    }
364
365    /// Updates the DNS conditional forwarder.
366    ///
367    /// # Long running operations
368    ///
369    /// This method is used to start, and/or poll a [long-running Operation].
370    /// The [Working with long-running operations] chapter in the [user guide]
371    /// covers these operations in detail.
372    ///
373    /// [long-running operation]: https://google.aip.dev/151
374    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
375    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
376    ///
377    /// # Example
378    /// ```
379    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
380    /// use google_cloud_lro::Poller;
381    /// use google_cloud_managedidentities_v1::Result;
382    /// async fn sample(
383    ///    client: &ManagedIdentitiesService
384    /// ) -> Result<()> {
385    ///     let response = client.reconfigure_trust()
386    ///         /* set fields */
387    ///         .poller().until_done().await?;
388    ///     println!("response {:?}", response);
389    ///     Ok(())
390    /// }
391    /// ```
392    pub fn reconfigure_trust(
393        &self,
394    ) -> super::builder::managed_identities_service::ReconfigureTrust {
395        super::builder::managed_identities_service::ReconfigureTrust::new(self.inner.clone())
396    }
397
398    /// Removes an AD trust.
399    ///
400    /// # Long running operations
401    ///
402    /// This method is used to start, and/or poll a [long-running Operation].
403    /// The [Working with long-running operations] chapter in the [user guide]
404    /// covers these operations in detail.
405    ///
406    /// [long-running operation]: https://google.aip.dev/151
407    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
408    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
409    ///
410    /// # Example
411    /// ```
412    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
413    /// use google_cloud_lro::Poller;
414    /// use google_cloud_managedidentities_v1::Result;
415    /// async fn sample(
416    ///    client: &ManagedIdentitiesService
417    /// ) -> Result<()> {
418    ///     let response = client.detach_trust()
419    ///         /* set fields */
420    ///         .poller().until_done().await?;
421    ///     println!("response {:?}", response);
422    ///     Ok(())
423    /// }
424    /// ```
425    pub fn detach_trust(&self) -> super::builder::managed_identities_service::DetachTrust {
426        super::builder::managed_identities_service::DetachTrust::new(self.inner.clone())
427    }
428
429    /// Validates a trust state, that the target domain is reachable, and that the
430    /// target domain is able to accept incoming trust requests.
431    ///
432    /// # Long running operations
433    ///
434    /// This method is used to start, and/or poll a [long-running Operation].
435    /// The [Working with long-running operations] chapter in the [user guide]
436    /// covers these operations in detail.
437    ///
438    /// [long-running operation]: https://google.aip.dev/151
439    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
440    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
441    ///
442    /// # Example
443    /// ```
444    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
445    /// use google_cloud_lro::Poller;
446    /// use google_cloud_managedidentities_v1::Result;
447    /// async fn sample(
448    ///    client: &ManagedIdentitiesService
449    /// ) -> Result<()> {
450    ///     let response = client.validate_trust()
451    ///         /* set fields */
452    ///         .poller().until_done().await?;
453    ///     println!("response {:?}", response);
454    ///     Ok(())
455    /// }
456    /// ```
457    pub fn validate_trust(&self) -> super::builder::managed_identities_service::ValidateTrust {
458        super::builder::managed_identities_service::ValidateTrust::new(self.inner.clone())
459    }
460
461    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
462    ///
463    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
464    ///
465    /// # Example
466    /// ```
467    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
468    /// use google_cloud_gax::paginator::ItemPaginator as _;
469    /// use google_cloud_managedidentities_v1::Result;
470    /// async fn sample(
471    ///    client: &ManagedIdentitiesService
472    /// ) -> Result<()> {
473    ///     let mut list = client.list_operations()
474    ///         /* set fields */
475    ///         .by_item();
476    ///     while let Some(item) = list.next().await.transpose()? {
477    ///         println!("{:?}", item);
478    ///     }
479    ///     Ok(())
480    /// }
481    /// ```
482    pub fn list_operations(&self) -> super::builder::managed_identities_service::ListOperations {
483        super::builder::managed_identities_service::ListOperations::new(self.inner.clone())
484    }
485
486    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
487    ///
488    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
489    ///
490    /// # Example
491    /// ```
492    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
493    /// use google_cloud_managedidentities_v1::Result;
494    /// async fn sample(
495    ///    client: &ManagedIdentitiesService
496    /// ) -> Result<()> {
497    ///     let response = client.get_operation()
498    ///         /* set fields */
499    ///         .send().await?;
500    ///     println!("response {:?}", response);
501    ///     Ok(())
502    /// }
503    /// ```
504    pub fn get_operation(&self) -> super::builder::managed_identities_service::GetOperation {
505        super::builder::managed_identities_service::GetOperation::new(self.inner.clone())
506    }
507
508    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
509    ///
510    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
511    ///
512    /// # Example
513    /// ```
514    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
515    /// use google_cloud_managedidentities_v1::Result;
516    /// async fn sample(
517    ///    client: &ManagedIdentitiesService
518    /// ) -> Result<()> {
519    ///     client.delete_operation()
520    ///         /* set fields */
521    ///         .send().await?;
522    ///     Ok(())
523    /// }
524    /// ```
525    pub fn delete_operation(&self) -> super::builder::managed_identities_service::DeleteOperation {
526        super::builder::managed_identities_service::DeleteOperation::new(self.inner.clone())
527    }
528
529    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
530    ///
531    /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
532    ///
533    /// # Example
534    /// ```
535    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
536    /// use google_cloud_managedidentities_v1::Result;
537    /// async fn sample(
538    ///    client: &ManagedIdentitiesService
539    /// ) -> Result<()> {
540    ///     client.cancel_operation()
541    ///         /* set fields */
542    ///         .send().await?;
543    ///     Ok(())
544    /// }
545    /// ```
546    pub fn cancel_operation(&self) -> super::builder::managed_identities_service::CancelOperation {
547        super::builder::managed_identities_service::CancelOperation::new(self.inner.clone())
548    }
549}