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/// # tokio_test::block_on(async {
24/// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
25/// let client = ManagedIdentitiesService::builder().build().await?;
26/// // use `client` to make requests to the Managed Service for Microsoft Active Directory API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// API Overview
33///
34/// The `managedidentites.googleapis.com` service implements the Google Cloud
35/// Managed Identites API for identity services
36/// (e.g. Microsoft Active Directory).
37///
38/// The Managed Identities service provides methods to manage
39/// (create/read/update/delete) domains, reset managed identities admin password,
40/// add/remove domain controllers in GCP regions and add/remove VPC peering.
41///
42/// Data Model
43///
44/// The Managed Identities service exposes the following resources:
45///
46/// * Locations as global, named as follows:
47///   `projects/{project_id}/locations/global`.
48///
49/// * Domains, named as follows:
50///   `/projects/{project_id}/locations/global/domain/{domain_name}`.
51///
52///
53/// The `{domain_name}` refers to fully qualified domain name in the customer
54/// project e.g. mydomain.myorganization.com, with the following restrictions:
55///
56/// * Must contain only lowercase letters, numbers, periods and hyphens.
57/// * Must start with a letter.
58/// * Must contain between 2-64 characters.
59/// * Must end with a number or a letter.
60/// * Must not start with period.
61/// * First segement length (mydomain form example above) shouldn't exceed
62///   15 chars.
63/// * The last segment cannot be fully numeric.
64/// * Must be unique within the customer project.
65///
66/// # Configuration
67///
68/// To configure `ManagedIdentitiesService` use the `with_*` methods in the type returned
69/// by [builder()][ManagedIdentitiesService::builder]. The default configuration should
70/// work for most applications. Common configuration changes include
71///
72/// * [with_endpoint()]: by default this client uses the global default endpoint
73///   (`https://managedidentities.googleapis.com`). Applications using regional
74///   endpoints or running in restricted networks (e.g. a network configured
75//    with [Private Google Access with VPC Service Controls]) may want to
76///   override this default.
77/// * [with_credentials()]: by default this client uses
78///   [Application Default Credentials]. Applications using custom
79///   authentication may need to override this default.
80///
81/// [with_endpoint()]: super::builder::managed_identities_service::ClientBuilder::with_endpoint
82/// [with_credentials()]: super::builder::managed_identities_service::ClientBuilder::credentials
83/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
84/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
85///
86/// # Pooling and Cloning
87///
88/// `ManagedIdentitiesService` holds a connection pool internally, it is advised to
89/// create one and the reuse it.  You do not need to wrap `ManagedIdentitiesService` in
90/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
91/// already uses an `Arc` internally.
92#[derive(Clone, Debug)]
93pub struct ManagedIdentitiesService {
94    inner: std::sync::Arc<dyn super::stub::dynamic::ManagedIdentitiesService>,
95}
96
97impl ManagedIdentitiesService {
98    /// Returns a builder for [ManagedIdentitiesService].
99    ///
100    /// ```
101    /// # tokio_test::block_on(async {
102    /// # use google_cloud_managedidentities_v1::client::ManagedIdentitiesService;
103    /// let client = ManagedIdentitiesService::builder().build().await?;
104    /// # gax::client_builder::Result::<()>::Ok(()) });
105    /// ```
106    pub fn builder() -> super::builder::managed_identities_service::ClientBuilder {
107        gax::client_builder::internal::new_builder(
108            super::builder::managed_identities_service::client::Factory,
109        )
110    }
111
112    /// Creates a new client from the provided stub.
113    ///
114    /// The most common case for calling this function is in tests mocking the
115    /// client's behavior.
116    pub fn from_stub<T>(stub: T) -> Self
117    where
118        T: super::stub::ManagedIdentitiesService + 'static,
119    {
120        Self {
121            inner: std::sync::Arc::new(stub),
122        }
123    }
124
125    pub(crate) async fn new(
126        config: gaxi::options::ClientConfig,
127    ) -> gax::client_builder::Result<Self> {
128        let inner = Self::build_inner(config).await?;
129        Ok(Self { inner })
130    }
131
132    async fn build_inner(
133        conf: gaxi::options::ClientConfig,
134    ) -> gax::client_builder::Result<
135        std::sync::Arc<dyn super::stub::dynamic::ManagedIdentitiesService>,
136    > {
137        if gaxi::options::tracing_enabled(&conf) {
138            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
139        }
140        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
141    }
142
143    async fn build_transport(
144        conf: gaxi::options::ClientConfig,
145    ) -> gax::client_builder::Result<impl super::stub::ManagedIdentitiesService> {
146        super::transport::ManagedIdentitiesService::new(conf).await
147    }
148
149    async fn build_with_tracing(
150        conf: gaxi::options::ClientConfig,
151    ) -> gax::client_builder::Result<impl super::stub::ManagedIdentitiesService> {
152        Self::build_transport(conf)
153            .await
154            .map(super::tracing::ManagedIdentitiesService::new)
155    }
156
157    /// Creates a Microsoft AD domain.
158    ///
159    /// # Long running operations
160    ///
161    /// This method is used to start, and/or poll a [long-running Operation].
162    /// The [Working with long-running operations] chapter in the [user guide]
163    /// covers these operations in detail.
164    ///
165    /// [long-running operation]: https://google.aip.dev/151
166    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
167    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
168    pub fn create_microsoft_ad_domain(
169        &self,
170    ) -> super::builder::managed_identities_service::CreateMicrosoftAdDomain {
171        super::builder::managed_identities_service::CreateMicrosoftAdDomain::new(self.inner.clone())
172    }
173
174    /// Resets a domain's administrator password.
175    pub fn reset_admin_password(
176        &self,
177    ) -> super::builder::managed_identities_service::ResetAdminPassword {
178        super::builder::managed_identities_service::ResetAdminPassword::new(self.inner.clone())
179    }
180
181    /// Lists domains in a project.
182    pub fn list_domains(&self) -> super::builder::managed_identities_service::ListDomains {
183        super::builder::managed_identities_service::ListDomains::new(self.inner.clone())
184    }
185
186    /// Gets information about a domain.
187    pub fn get_domain(&self) -> super::builder::managed_identities_service::GetDomain {
188        super::builder::managed_identities_service::GetDomain::new(self.inner.clone())
189    }
190
191    /// Updates the metadata and configuration of a domain.
192    ///
193    /// # Long running operations
194    ///
195    /// This method is used to start, and/or poll a [long-running Operation].
196    /// The [Working with long-running operations] chapter in the [user guide]
197    /// covers these operations in detail.
198    ///
199    /// [long-running operation]: https://google.aip.dev/151
200    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
201    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
202    pub fn update_domain(&self) -> super::builder::managed_identities_service::UpdateDomain {
203        super::builder::managed_identities_service::UpdateDomain::new(self.inner.clone())
204    }
205
206    /// Deletes a domain.
207    ///
208    /// # Long running operations
209    ///
210    /// This method is used to start, and/or poll a [long-running Operation].
211    /// The [Working with long-running operations] chapter in the [user guide]
212    /// covers these operations in detail.
213    ///
214    /// [long-running operation]: https://google.aip.dev/151
215    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
216    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
217    pub fn delete_domain(&self) -> super::builder::managed_identities_service::DeleteDomain {
218        super::builder::managed_identities_service::DeleteDomain::new(self.inner.clone())
219    }
220
221    /// Adds an AD trust to a domain.
222    ///
223    /// # Long running operations
224    ///
225    /// This method is used to start, and/or poll a [long-running Operation].
226    /// The [Working with long-running operations] chapter in the [user guide]
227    /// covers these operations in detail.
228    ///
229    /// [long-running operation]: https://google.aip.dev/151
230    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
231    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
232    pub fn attach_trust(&self) -> super::builder::managed_identities_service::AttachTrust {
233        super::builder::managed_identities_service::AttachTrust::new(self.inner.clone())
234    }
235
236    /// Updates the DNS conditional forwarder.
237    ///
238    /// # Long running operations
239    ///
240    /// This method is used to start, and/or poll a [long-running Operation].
241    /// The [Working with long-running operations] chapter in the [user guide]
242    /// covers these operations in detail.
243    ///
244    /// [long-running operation]: https://google.aip.dev/151
245    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
246    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
247    pub fn reconfigure_trust(
248        &self,
249    ) -> super::builder::managed_identities_service::ReconfigureTrust {
250        super::builder::managed_identities_service::ReconfigureTrust::new(self.inner.clone())
251    }
252
253    /// Removes an AD trust.
254    ///
255    /// # Long running operations
256    ///
257    /// This method is used to start, and/or poll a [long-running Operation].
258    /// The [Working with long-running operations] chapter in the [user guide]
259    /// covers these operations in detail.
260    ///
261    /// [long-running operation]: https://google.aip.dev/151
262    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
263    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
264    pub fn detach_trust(&self) -> super::builder::managed_identities_service::DetachTrust {
265        super::builder::managed_identities_service::DetachTrust::new(self.inner.clone())
266    }
267
268    /// Validates a trust state, that the target domain is reachable, and that the
269    /// target domain is able to accept incoming trust requests.
270    ///
271    /// # Long running operations
272    ///
273    /// This method is used to start, and/or poll a [long-running Operation].
274    /// The [Working with long-running operations] chapter in the [user guide]
275    /// covers these operations in detail.
276    ///
277    /// [long-running operation]: https://google.aip.dev/151
278    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
279    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
280    pub fn validate_trust(&self) -> super::builder::managed_identities_service::ValidateTrust {
281        super::builder::managed_identities_service::ValidateTrust::new(self.inner.clone())
282    }
283
284    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
285    ///
286    /// [google.longrunning.Operations]: longrunning::client::Operations
287    pub fn list_operations(&self) -> super::builder::managed_identities_service::ListOperations {
288        super::builder::managed_identities_service::ListOperations::new(self.inner.clone())
289    }
290
291    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
292    ///
293    /// [google.longrunning.Operations]: longrunning::client::Operations
294    pub fn get_operation(&self) -> super::builder::managed_identities_service::GetOperation {
295        super::builder::managed_identities_service::GetOperation::new(self.inner.clone())
296    }
297
298    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
299    ///
300    /// [google.longrunning.Operations]: longrunning::client::Operations
301    pub fn delete_operation(&self) -> super::builder::managed_identities_service::DeleteOperation {
302        super::builder::managed_identities_service::DeleteOperation::new(self.inner.clone())
303    }
304
305    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
306    ///
307    /// [google.longrunning.Operations]: longrunning::client::Operations
308    pub fn cancel_operation(&self) -> super::builder::managed_identities_service::CancelOperation {
309        super::builder::managed_identities_service::CancelOperation::new(self.inner.clone())
310    }
311}