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