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