google_cloud_resourcemanager_v3/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 Resource Manager API.
20///
21/// # Example
22/// ```
23/// # tokio_test::block_on(async {
24/// # use google_cloud_resourcemanager_v3::client::Folders;
25/// let client = Folders::builder().build().await?;
26/// // use `client` to make requests to the Cloud Resource Manager API.
27/// # gax::client_builder::Result::<()>::Ok(()) });
28/// ```
29///
30/// # Service Description
31///
32/// Manages Cloud Platform folder resources.
33/// Folders can be used to organize the resources under an
34/// organization and to control the policies applied to groups of resources.
35///
36/// # Configuration
37///
38/// To configure `Folders` use the `with_*` methods in the type returned
39/// by [builder()][Folders::builder]. The default configuration should
40/// work for most applications. Common configuration changes include
41///
42/// * [with_endpoint()]: by default this client uses the global default endpoint
43/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
44/// endpoints or running in restricted networks (e.g. a network configured
45// with [Private Google Access with VPC Service Controls]) may want to
46/// override this default.
47/// * [with_credentials()]: by default this client uses
48/// [Application Default Credentials]. Applications using custom
49/// authentication may need to override this default.
50///
51/// [with_endpoint()]: super::builder::folders::ClientBuilder::with_endpoint
52/// [with_credentials()]: super::builder::folders::ClientBuilder::credentials
53/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
54/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
55///
56/// # Pooling and Cloning
57///
58/// `Folders` holds a connection pool internally, it is advised to
59/// create one and the reuse it. You do not need to wrap `Folders` in
60/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
61/// already uses an `Arc` internally.
62#[derive(Clone, Debug)]
63pub struct Folders {
64 inner: std::sync::Arc<dyn super::stub::dynamic::Folders>,
65}
66
67impl Folders {
68 /// Returns a builder for [Folders].
69 ///
70 /// ```
71 /// # tokio_test::block_on(async {
72 /// # use google_cloud_resourcemanager_v3::client::Folders;
73 /// let client = Folders::builder().build().await?;
74 /// # gax::client_builder::Result::<()>::Ok(()) });
75 /// ```
76 pub fn builder() -> super::builder::folders::ClientBuilder {
77 gax::client_builder::internal::new_builder(super::builder::folders::client::Factory)
78 }
79
80 /// Creates a new client from the provided stub.
81 ///
82 /// The most common case for calling this function is in tests mocking the
83 /// client's behavior.
84 pub fn from_stub<T>(stub: T) -> Self
85 where
86 T: super::stub::Folders + 'static,
87 {
88 Self {
89 inner: std::sync::Arc::new(stub),
90 }
91 }
92
93 pub(crate) async fn new(
94 config: gaxi::options::ClientConfig,
95 ) -> gax::client_builder::Result<Self> {
96 let inner = Self::build_inner(config).await?;
97 Ok(Self { inner })
98 }
99
100 async fn build_inner(
101 conf: gaxi::options::ClientConfig,
102 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Folders>> {
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 ) -> gax::client_builder::Result<impl super::stub::Folders> {
112 super::transport::Folders::new(conf).await
113 }
114
115 async fn build_with_tracing(
116 conf: gaxi::options::ClientConfig,
117 ) -> gax::client_builder::Result<impl super::stub::Folders> {
118 Self::build_transport(conf)
119 .await
120 .map(super::tracing::Folders::new)
121 }
122
123 /// Retrieves a folder identified by the supplied resource name.
124 /// Valid folder resource names have the format `folders/{folder_id}`
125 /// (for example, `folders/1234`).
126 /// The caller must have `resourcemanager.folders.get` permission on the
127 /// identified folder.
128 pub fn get_folder(&self) -> super::builder::folders::GetFolder {
129 super::builder::folders::GetFolder::new(self.inner.clone())
130 }
131
132 /// Lists the folders that are direct descendants of supplied parent resource.
133 /// `list()` provides a strongly consistent view of the folders underneath
134 /// the specified parent resource.
135 /// `list()` returns folders sorted based upon the (ascending) lexical ordering
136 /// of their display_name.
137 /// The caller must have `resourcemanager.folders.list` permission on the
138 /// identified parent.
139 pub fn list_folders(&self) -> super::builder::folders::ListFolders {
140 super::builder::folders::ListFolders::new(self.inner.clone())
141 }
142
143 /// Search for folders that match specific filter criteria.
144 /// `search()` provides an eventually consistent view of the folders a user has
145 /// access to which meet the specified filter criteria.
146 ///
147 /// This will only return folders on which the caller has the
148 /// permission `resourcemanager.folders.get`.
149 pub fn search_folders(&self) -> super::builder::folders::SearchFolders {
150 super::builder::folders::SearchFolders::new(self.inner.clone())
151 }
152
153 /// Creates a folder in the resource hierarchy.
154 /// Returns an `Operation` which can be used to track the progress of the
155 /// folder creation workflow.
156 /// Upon success, the `Operation.response` field will be populated with the
157 /// created Folder.
158 ///
159 /// In order to succeed, the addition of this new folder must not violate
160 /// the folder naming, height, or fanout constraints.
161 ///
162 /// + The folder's `display_name` must be distinct from all other folders that
163 /// share its parent.
164 /// + The addition of the folder must not cause the active folder hierarchy
165 /// to exceed a height of 10. Note, the full active + deleted folder hierarchy
166 /// is allowed to reach a height of 20; this provides additional headroom when
167 /// moving folders that contain deleted folders.
168 /// + The addition of the folder must not cause the total number of folders
169 /// under its parent to exceed 300.
170 ///
171 /// If the operation fails due to a folder constraint violation, some errors
172 /// may be returned by the `CreateFolder` request, with status code
173 /// `FAILED_PRECONDITION` and an error description. Other folder constraint
174 /// violations will be communicated in the `Operation`, with the specific
175 /// `PreconditionFailure` returned in the details list in the `Operation.error`
176 /// field.
177 ///
178 /// The caller must have `resourcemanager.folders.create` permission on the
179 /// identified parent.
180 ///
181 /// # Long running operations
182 ///
183 /// This method is used to start, and/or poll a [long-running Operation].
184 /// The [Working with long-running operations] chapter in the [user guide]
185 /// covers these operations in detail.
186 ///
187 /// [long-running operation]: https://google.aip.dev/151
188 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
189 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
190 pub fn create_folder(&self) -> super::builder::folders::CreateFolder {
191 super::builder::folders::CreateFolder::new(self.inner.clone())
192 }
193
194 /// Updates a folder, changing its `display_name`.
195 /// Changes to the folder `display_name` will be rejected if they violate
196 /// either the `display_name` formatting rules or the naming constraints
197 /// described in the
198 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
199 /// documentation.
200 ///
201 /// The folder's `display_name` must start and end with a letter or digit,
202 /// may contain letters, digits, spaces, hyphens and underscores and can be
203 /// between 3 and 30 characters. This is captured by the regular expression:
204 /// `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`.
205 /// The caller must have `resourcemanager.folders.update` permission on the
206 /// identified folder.
207 ///
208 /// If the update fails due to the unique name constraint then a
209 /// `PreconditionFailure` explaining this violation will be returned
210 /// in the Status.details field.
211 ///
212 /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
213 ///
214 /// # Long running operations
215 ///
216 /// This method is used to start, and/or poll a [long-running Operation].
217 /// The [Working with long-running operations] chapter in the [user guide]
218 /// covers these operations in detail.
219 ///
220 /// [long-running operation]: https://google.aip.dev/151
221 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
222 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
223 pub fn update_folder(&self) -> super::builder::folders::UpdateFolder {
224 super::builder::folders::UpdateFolder::new(self.inner.clone())
225 }
226
227 /// Moves a folder under a new resource parent.
228 /// Returns an `Operation` which can be used to track the progress of the
229 /// folder move workflow.
230 /// Upon success, the `Operation.response` field will be populated with the
231 /// moved folder.
232 /// Upon failure, a `FolderOperationError` categorizing the failure cause will
233 /// be returned - if the failure occurs synchronously then the
234 /// `FolderOperationError` will be returned in the `Status.details` field.
235 /// If it occurs asynchronously, then the FolderOperation will be returned
236 /// in the `Operation.error` field.
237 /// In addition, the `Operation.metadata` field will be populated with a
238 /// `FolderOperation` message as an aid to stateless clients.
239 /// Folder moves will be rejected if they violate either the naming, height,
240 /// or fanout constraints described in the
241 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
242 /// documentation. The caller must have `resourcemanager.folders.move`
243 /// permission on the folder's current and proposed new parent.
244 ///
245 /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
246 ///
247 /// # Long running operations
248 ///
249 /// This method is used to start, and/or poll a [long-running Operation].
250 /// The [Working with long-running operations] chapter in the [user guide]
251 /// covers these operations in detail.
252 ///
253 /// [long-running operation]: https://google.aip.dev/151
254 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
255 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
256 pub fn move_folder(&self) -> super::builder::folders::MoveFolder {
257 super::builder::folders::MoveFolder::new(self.inner.clone())
258 }
259
260 /// Requests deletion of a folder. The folder is moved into the
261 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
262 /// state immediately, and is deleted approximately 30 days later. This method
263 /// may only be called on an empty folder, where a folder is empty if it
264 /// doesn't contain any folders or projects in the
265 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If
266 /// called on a folder in
267 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
268 /// state the operation will result in a no-op success.
269 /// The caller must have `resourcemanager.folders.delete` permission on the
270 /// identified folder.
271 ///
272 /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
273 /// [google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]: crate::model::folder::State::DeleteRequested
274 ///
275 /// # Long running operations
276 ///
277 /// This method is used to start, and/or poll a [long-running Operation].
278 /// The [Working with long-running operations] chapter in the [user guide]
279 /// covers these operations in detail.
280 ///
281 /// [long-running operation]: https://google.aip.dev/151
282 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
283 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
284 pub fn delete_folder(&self) -> super::builder::folders::DeleteFolder {
285 super::builder::folders::DeleteFolder::new(self.inner.clone())
286 }
287
288 /// Cancels the deletion request for a folder. This method may be called on a
289 /// folder in any state. If the folder is in the
290 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the
291 /// result will be a no-op success. In order to succeed, the folder's parent
292 /// must be in the
293 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In
294 /// addition, reintroducing the folder into the tree must not violate folder
295 /// naming, height, and fanout constraints described in the
296 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
297 /// documentation. The caller must have `resourcemanager.folders.undelete`
298 /// permission on the identified folder.
299 ///
300 /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
301 /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
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 pub fn undelete_folder(&self) -> super::builder::folders::UndeleteFolder {
313 super::builder::folders::UndeleteFolder::new(self.inner.clone())
314 }
315
316 /// Gets the access control policy for a folder. The returned policy may be
317 /// empty if no such policy or resource exists. The `resource` field should
318 /// be the folder's resource name, for example: "folders/1234".
319 /// The caller must have `resourcemanager.folders.getIamPolicy` permission
320 /// on the identified folder.
321 pub fn get_iam_policy(&self) -> super::builder::folders::GetIamPolicy {
322 super::builder::folders::GetIamPolicy::new(self.inner.clone())
323 }
324
325 /// Sets the access control policy on a folder, replacing any existing policy.
326 /// The `resource` field should be the folder's resource name, for example:
327 /// "folders/1234".
328 /// The caller must have `resourcemanager.folders.setIamPolicy` permission
329 /// on the identified folder.
330 pub fn set_iam_policy(&self) -> super::builder::folders::SetIamPolicy {
331 super::builder::folders::SetIamPolicy::new(self.inner.clone())
332 }
333
334 /// Returns permissions that a caller has on the specified folder.
335 /// The `resource` field should be the folder's resource name,
336 /// for example: "folders/1234".
337 ///
338 /// There are no permissions required for making this API call.
339 pub fn test_iam_permissions(&self) -> super::builder::folders::TestIamPermissions {
340 super::builder::folders::TestIamPermissions::new(self.inner.clone())
341 }
342
343 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
344 ///
345 /// [google.longrunning.Operations]: longrunning::client::Operations
346 pub fn get_operation(&self) -> super::builder::folders::GetOperation {
347 super::builder::folders::GetOperation::new(self.inner.clone())
348 }
349}
350
351/// Implements a client for the Cloud Resource Manager API.
352///
353/// # Example
354/// ```
355/// # tokio_test::block_on(async {
356/// # use google_cloud_resourcemanager_v3::client::Organizations;
357/// let client = Organizations::builder().build().await?;
358/// // use `client` to make requests to the Cloud Resource Manager API.
359/// # gax::client_builder::Result::<()>::Ok(()) });
360/// ```
361///
362/// # Service Description
363///
364/// Allows users to manage their organization resources.
365///
366/// # Configuration
367///
368/// To configure `Organizations` use the `with_*` methods in the type returned
369/// by [builder()][Organizations::builder]. The default configuration should
370/// work for most applications. Common configuration changes include
371///
372/// * [with_endpoint()]: by default this client uses the global default endpoint
373/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
374/// endpoints or running in restricted networks (e.g. a network configured
375// with [Private Google Access with VPC Service Controls]) may want to
376/// override this default.
377/// * [with_credentials()]: by default this client uses
378/// [Application Default Credentials]. Applications using custom
379/// authentication may need to override this default.
380///
381/// [with_endpoint()]: super::builder::organizations::ClientBuilder::with_endpoint
382/// [with_credentials()]: super::builder::organizations::ClientBuilder::credentials
383/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
384/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
385///
386/// # Pooling and Cloning
387///
388/// `Organizations` holds a connection pool internally, it is advised to
389/// create one and the reuse it. You do not need to wrap `Organizations` in
390/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
391/// already uses an `Arc` internally.
392#[derive(Clone, Debug)]
393pub struct Organizations {
394 inner: std::sync::Arc<dyn super::stub::dynamic::Organizations>,
395}
396
397impl Organizations {
398 /// Returns a builder for [Organizations].
399 ///
400 /// ```
401 /// # tokio_test::block_on(async {
402 /// # use google_cloud_resourcemanager_v3::client::Organizations;
403 /// let client = Organizations::builder().build().await?;
404 /// # gax::client_builder::Result::<()>::Ok(()) });
405 /// ```
406 pub fn builder() -> super::builder::organizations::ClientBuilder {
407 gax::client_builder::internal::new_builder(super::builder::organizations::client::Factory)
408 }
409
410 /// Creates a new client from the provided stub.
411 ///
412 /// The most common case for calling this function is in tests mocking the
413 /// client's behavior.
414 pub fn from_stub<T>(stub: T) -> Self
415 where
416 T: super::stub::Organizations + 'static,
417 {
418 Self {
419 inner: std::sync::Arc::new(stub),
420 }
421 }
422
423 pub(crate) async fn new(
424 config: gaxi::options::ClientConfig,
425 ) -> gax::client_builder::Result<Self> {
426 let inner = Self::build_inner(config).await?;
427 Ok(Self { inner })
428 }
429
430 async fn build_inner(
431 conf: gaxi::options::ClientConfig,
432 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Organizations>> {
433 if gaxi::options::tracing_enabled(&conf) {
434 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
435 }
436 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
437 }
438
439 async fn build_transport(
440 conf: gaxi::options::ClientConfig,
441 ) -> gax::client_builder::Result<impl super::stub::Organizations> {
442 super::transport::Organizations::new(conf).await
443 }
444
445 async fn build_with_tracing(
446 conf: gaxi::options::ClientConfig,
447 ) -> gax::client_builder::Result<impl super::stub::Organizations> {
448 Self::build_transport(conf)
449 .await
450 .map(super::tracing::Organizations::new)
451 }
452
453 /// Fetches an organization resource identified by the specified resource name.
454 pub fn get_organization(&self) -> super::builder::organizations::GetOrganization {
455 super::builder::organizations::GetOrganization::new(self.inner.clone())
456 }
457
458 /// Searches organization resources that are visible to the user and satisfy
459 /// the specified filter. This method returns organizations in an unspecified
460 /// order. New organizations do not necessarily appear at the end of the
461 /// results, and may take a small amount of time to appear.
462 ///
463 /// Search will only return organizations on which the user has the permission
464 /// `resourcemanager.organizations.get`
465 pub fn search_organizations(&self) -> super::builder::organizations::SearchOrganizations {
466 super::builder::organizations::SearchOrganizations::new(self.inner.clone())
467 }
468
469 /// Gets the access control policy for an organization resource. The policy may
470 /// be empty if no such policy or resource exists. The `resource` field should
471 /// be the organization's resource name, for example: "organizations/123".
472 ///
473 /// Authorization requires the IAM permission
474 /// `resourcemanager.organizations.getIamPolicy` on the specified organization.
475 pub fn get_iam_policy(&self) -> super::builder::organizations::GetIamPolicy {
476 super::builder::organizations::GetIamPolicy::new(self.inner.clone())
477 }
478
479 /// Sets the access control policy on an organization resource. Replaces any
480 /// existing policy. The `resource` field should be the organization's resource
481 /// name, for example: "organizations/123".
482 ///
483 /// Authorization requires the IAM permission
484 /// `resourcemanager.organizations.setIamPolicy` on the specified organization.
485 pub fn set_iam_policy(&self) -> super::builder::organizations::SetIamPolicy {
486 super::builder::organizations::SetIamPolicy::new(self.inner.clone())
487 }
488
489 /// Returns the permissions that a caller has on the specified organization.
490 /// The `resource` field should be the organization's resource name,
491 /// for example: "organizations/123".
492 ///
493 /// There are no permissions required for making this API call.
494 pub fn test_iam_permissions(&self) -> super::builder::organizations::TestIamPermissions {
495 super::builder::organizations::TestIamPermissions::new(self.inner.clone())
496 }
497
498 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
499 ///
500 /// [google.longrunning.Operations]: longrunning::client::Operations
501 pub fn get_operation(&self) -> super::builder::organizations::GetOperation {
502 super::builder::organizations::GetOperation::new(self.inner.clone())
503 }
504}
505
506/// Implements a client for the Cloud Resource Manager API.
507///
508/// # Example
509/// ```
510/// # tokio_test::block_on(async {
511/// # use google_cloud_resourcemanager_v3::client::Projects;
512/// let client = Projects::builder().build().await?;
513/// // use `client` to make requests to the Cloud Resource Manager API.
514/// # gax::client_builder::Result::<()>::Ok(()) });
515/// ```
516///
517/// # Service Description
518///
519/// Manages Google Cloud Projects.
520///
521/// # Configuration
522///
523/// To configure `Projects` use the `with_*` methods in the type returned
524/// by [builder()][Projects::builder]. The default configuration should
525/// work for most applications. Common configuration changes include
526///
527/// * [with_endpoint()]: by default this client uses the global default endpoint
528/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
529/// endpoints or running in restricted networks (e.g. a network configured
530// with [Private Google Access with VPC Service Controls]) may want to
531/// override this default.
532/// * [with_credentials()]: by default this client uses
533/// [Application Default Credentials]. Applications using custom
534/// authentication may need to override this default.
535///
536/// [with_endpoint()]: super::builder::projects::ClientBuilder::with_endpoint
537/// [with_credentials()]: super::builder::projects::ClientBuilder::credentials
538/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
539/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
540///
541/// # Pooling and Cloning
542///
543/// `Projects` holds a connection pool internally, it is advised to
544/// create one and the reuse it. You do not need to wrap `Projects` in
545/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
546/// already uses an `Arc` internally.
547#[derive(Clone, Debug)]
548pub struct Projects {
549 inner: std::sync::Arc<dyn super::stub::dynamic::Projects>,
550}
551
552impl Projects {
553 /// Returns a builder for [Projects].
554 ///
555 /// ```
556 /// # tokio_test::block_on(async {
557 /// # use google_cloud_resourcemanager_v3::client::Projects;
558 /// let client = Projects::builder().build().await?;
559 /// # gax::client_builder::Result::<()>::Ok(()) });
560 /// ```
561 pub fn builder() -> super::builder::projects::ClientBuilder {
562 gax::client_builder::internal::new_builder(super::builder::projects::client::Factory)
563 }
564
565 /// Creates a new client from the provided stub.
566 ///
567 /// The most common case for calling this function is in tests mocking the
568 /// client's behavior.
569 pub fn from_stub<T>(stub: T) -> Self
570 where
571 T: super::stub::Projects + 'static,
572 {
573 Self {
574 inner: std::sync::Arc::new(stub),
575 }
576 }
577
578 pub(crate) async fn new(
579 config: gaxi::options::ClientConfig,
580 ) -> gax::client_builder::Result<Self> {
581 let inner = Self::build_inner(config).await?;
582 Ok(Self { inner })
583 }
584
585 async fn build_inner(
586 conf: gaxi::options::ClientConfig,
587 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Projects>> {
588 if gaxi::options::tracing_enabled(&conf) {
589 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
590 }
591 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
592 }
593
594 async fn build_transport(
595 conf: gaxi::options::ClientConfig,
596 ) -> gax::client_builder::Result<impl super::stub::Projects> {
597 super::transport::Projects::new(conf).await
598 }
599
600 async fn build_with_tracing(
601 conf: gaxi::options::ClientConfig,
602 ) -> gax::client_builder::Result<impl super::stub::Projects> {
603 Self::build_transport(conf)
604 .await
605 .map(super::tracing::Projects::new)
606 }
607
608 /// Retrieves the project identified by the specified `name` (for example,
609 /// `projects/415104041262`).
610 ///
611 /// The caller must have `resourcemanager.projects.get` permission
612 /// for this project.
613 pub fn get_project(&self) -> super::builder::projects::GetProject {
614 super::builder::projects::GetProject::new(self.inner.clone())
615 }
616
617 /// Lists projects that are direct children of the specified folder or
618 /// organization resource. `list()` provides a strongly consistent view of the
619 /// projects underneath the specified parent resource. `list()` returns
620 /// projects sorted based upon the (ascending) lexical ordering of their
621 /// `display_name`. The caller must have `resourcemanager.projects.list`
622 /// permission on the identified parent.
623 pub fn list_projects(&self) -> super::builder::projects::ListProjects {
624 super::builder::projects::ListProjects::new(self.inner.clone())
625 }
626
627 /// Search for projects that the caller has both `resourcemanager.projects.get`
628 /// permission on, and also satisfy the specified query.
629 ///
630 /// This method returns projects in an unspecified order.
631 ///
632 /// This method is eventually consistent with project mutations; this means
633 /// that a newly created project may not appear in the results or recent
634 /// updates to an existing project may not be reflected in the results. To
635 /// retrieve the latest state of a project, use the
636 /// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.
637 ///
638 /// [google.cloud.resourcemanager.v3.Projects.GetProject]: crate::client::Projects::get_project
639 pub fn search_projects(&self) -> super::builder::projects::SearchProjects {
640 super::builder::projects::SearchProjects::new(self.inner.clone())
641 }
642
643 /// Request that a new project be created. The result is an `Operation` which
644 /// can be used to track the creation process. This process usually takes a few
645 /// seconds, but can sometimes take much longer. The tracking `Operation` is
646 /// automatically deleted after a few hours, so there is no need to call
647 /// `DeleteOperation`.
648 ///
649 /// # Long running operations
650 ///
651 /// This method is used to start, and/or poll a [long-running Operation].
652 /// The [Working with long-running operations] chapter in the [user guide]
653 /// covers these operations in detail.
654 ///
655 /// [long-running operation]: https://google.aip.dev/151
656 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
657 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
658 pub fn create_project(&self) -> super::builder::projects::CreateProject {
659 super::builder::projects::CreateProject::new(self.inner.clone())
660 }
661
662 /// Updates the `display_name` and labels of the project identified by the
663 /// specified `name` (for example, `projects/415104041262`). Deleting all
664 /// labels requires an update mask for labels field.
665 ///
666 /// The caller must have `resourcemanager.projects.update` permission for this
667 /// project.
668 ///
669 /// # Long running operations
670 ///
671 /// This method is used to start, and/or poll a [long-running Operation].
672 /// The [Working with long-running operations] chapter in the [user guide]
673 /// covers these operations in detail.
674 ///
675 /// [long-running operation]: https://google.aip.dev/151
676 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
677 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
678 pub fn update_project(&self) -> super::builder::projects::UpdateProject {
679 super::builder::projects::UpdateProject::new(self.inner.clone())
680 }
681
682 /// Move a project to another place in your resource hierarchy, under a new
683 /// resource parent.
684 ///
685 /// Returns an operation which can be used to track the process of the project
686 /// move workflow.
687 /// Upon success, the `Operation.response` field will be populated with the
688 /// moved project.
689 ///
690 /// The caller must have `resourcemanager.projects.move` permission on the
691 /// project, on the project's current and proposed new parent.
692 ///
693 /// If project has no current parent, or it currently does not have an
694 /// associated organization resource, you will also need the
695 /// `resourcemanager.projects.setIamPolicy` permission in the project.
696 ///
697 /// # Long running operations
698 ///
699 /// This method is used to start, and/or poll a [long-running Operation].
700 /// The [Working with long-running operations] chapter in the [user guide]
701 /// covers these operations in detail.
702 ///
703 /// [long-running operation]: https://google.aip.dev/151
704 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
705 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
706 pub fn move_project(&self) -> super::builder::projects::MoveProject {
707 super::builder::projects::MoveProject::new(self.inner.clone())
708 }
709
710 /// Marks the project identified by the specified
711 /// `name` (for example, `projects/415104041262`) for deletion.
712 ///
713 /// This method will only affect the project if it has a lifecycle state of
714 /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE].
715 ///
716 /// This method changes the Project's lifecycle state from
717 /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]
718 /// to
719 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED].
720 /// The deletion starts at an unspecified time,
721 /// at which point the Project is no longer accessible.
722 ///
723 /// Until the deletion completes, you can check the lifecycle state
724 /// checked by retrieving the project with [GetProject]
725 /// [google.cloud.resourcemanager.v3.Projects.GetProject],
726 /// and the project remains visible to [ListProjects]
727 /// [google.cloud.resourcemanager.v3.Projects.ListProjects].
728 /// However, you cannot update the project.
729 ///
730 /// After the deletion completes, the project is not retrievable by
731 /// the [GetProject]
732 /// [google.cloud.resourcemanager.v3.Projects.GetProject],
733 /// [ListProjects]
734 /// [google.cloud.resourcemanager.v3.Projects.ListProjects], and
735 /// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects]
736 /// methods.
737 ///
738 /// This method behaves idempotently, such that deleting a `DELETE_REQUESTED`
739 /// project will not cause an error, but also won't do anything.
740 ///
741 /// The caller must have `resourcemanager.projects.delete` permissions for this
742 /// project.
743 ///
744 /// [google.cloud.resourcemanager.v3.Project.State.ACTIVE]: crate::model::project::State::Active
745 /// [google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]: crate::model::project::State::DeleteRequested
746 /// [google.cloud.resourcemanager.v3.Projects.SearchProjects]: crate::client::Projects::search_projects
747 ///
748 /// # Long running operations
749 ///
750 /// This method is used to start, and/or poll a [long-running Operation].
751 /// The [Working with long-running operations] chapter in the [user guide]
752 /// covers these operations in detail.
753 ///
754 /// [long-running operation]: https://google.aip.dev/151
755 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
756 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
757 pub fn delete_project(&self) -> super::builder::projects::DeleteProject {
758 super::builder::projects::DeleteProject::new(self.inner.clone())
759 }
760
761 /// Restores the project identified by the specified
762 /// `name` (for example, `projects/415104041262`).
763 /// You can only use this method for a project that has a lifecycle state of
764 /// [DELETE_REQUESTED]
765 /// [Projects.State.DELETE_REQUESTED].
766 /// After deletion starts, the project cannot be restored.
767 ///
768 /// The caller must have `resourcemanager.projects.undelete` permission for
769 /// this project.
770 ///
771 /// # Long running operations
772 ///
773 /// This method is used to start, and/or poll a [long-running Operation].
774 /// The [Working with long-running operations] chapter in the [user guide]
775 /// covers these operations in detail.
776 ///
777 /// [long-running operation]: https://google.aip.dev/151
778 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
779 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
780 pub fn undelete_project(&self) -> super::builder::projects::UndeleteProject {
781 super::builder::projects::UndeleteProject::new(self.inner.clone())
782 }
783
784 /// Returns the IAM access control policy for the specified project, in the
785 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
786 /// Permission is denied if the policy or the resource do not exist.
787 pub fn get_iam_policy(&self) -> super::builder::projects::GetIamPolicy {
788 super::builder::projects::GetIamPolicy::new(self.inner.clone())
789 }
790
791 /// Sets the IAM access control policy for the specified project, in the
792 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
793 ///
794 /// CAUTION: This method will replace the existing policy, and cannot be used
795 /// to append additional IAM settings.
796 ///
797 /// Note: Removing service accounts from policies or changing their roles can
798 /// render services completely inoperable. It is important to understand how
799 /// the service account is being used before removing or updating its roles.
800 ///
801 /// The following constraints apply when using `setIamPolicy()`:
802 ///
803 /// + Project does not support `allUsers` and `allAuthenticatedUsers` as
804 /// `members` in a `Binding` of a `Policy`.
805 ///
806 /// + The owner role can be granted to a `user`, `serviceAccount`, or a group
807 /// that is part of an organization. For example,
808 /// group@myownpersonaldomain.com could be added as an owner to a project in
809 /// the myownpersonaldomain.com organization, but not the examplepetstore.com
810 /// organization.
811 ///
812 /// + Service accounts can be made owners of a project directly
813 /// without any restrictions. However, to be added as an owner, a user must be
814 /// invited using the Cloud Platform console and must accept the invitation.
815 ///
816 /// + A user cannot be granted the owner role using `setIamPolicy()`. The user
817 /// must be granted the owner role using the Cloud Platform Console and must
818 /// explicitly accept the invitation.
819 ///
820 /// + Invitations to grant the owner role cannot be sent using
821 /// `setIamPolicy()`;
822 /// they must be sent only using the Cloud Platform Console.
823 ///
824 /// + If the project is not part of an organization, there must be at least
825 /// one owner who has accepted the Terms of Service (ToS) agreement in the
826 /// policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner
827 /// from the policy will fail. This restriction also applies to legacy
828 /// projects that no longer have owners who have accepted the ToS. Edits to
829 /// IAM policies will be rejected until the lack of a ToS-accepting owner is
830 /// rectified. If the project is part of an organization, you can remove all
831 /// owners, potentially making the organization inaccessible.
832 ///
833 pub fn set_iam_policy(&self) -> super::builder::projects::SetIamPolicy {
834 super::builder::projects::SetIamPolicy::new(self.inner.clone())
835 }
836
837 /// Returns permissions that a caller has on the specified project, in the
838 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123..
839 pub fn test_iam_permissions(&self) -> super::builder::projects::TestIamPermissions {
840 super::builder::projects::TestIamPermissions::new(self.inner.clone())
841 }
842
843 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
844 ///
845 /// [google.longrunning.Operations]: longrunning::client::Operations
846 pub fn get_operation(&self) -> super::builder::projects::GetOperation {
847 super::builder::projects::GetOperation::new(self.inner.clone())
848 }
849}
850
851/// Implements a client for the Cloud Resource Manager API.
852///
853/// # Example
854/// ```
855/// # tokio_test::block_on(async {
856/// # use google_cloud_resourcemanager_v3::client::TagBindings;
857/// let client = TagBindings::builder().build().await?;
858/// // use `client` to make requests to the Cloud Resource Manager API.
859/// # gax::client_builder::Result::<()>::Ok(()) });
860/// ```
861///
862/// # Service Description
863///
864/// Allow users to create and manage TagBindings between TagValues and
865/// different Google Cloud resources throughout the GCP resource hierarchy.
866///
867/// # Configuration
868///
869/// To configure `TagBindings` use the `with_*` methods in the type returned
870/// by [builder()][TagBindings::builder]. The default configuration should
871/// work for most applications. Common configuration changes include
872///
873/// * [with_endpoint()]: by default this client uses the global default endpoint
874/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
875/// endpoints or running in restricted networks (e.g. a network configured
876// with [Private Google Access with VPC Service Controls]) may want to
877/// override this default.
878/// * [with_credentials()]: by default this client uses
879/// [Application Default Credentials]. Applications using custom
880/// authentication may need to override this default.
881///
882/// [with_endpoint()]: super::builder::tag_bindings::ClientBuilder::with_endpoint
883/// [with_credentials()]: super::builder::tag_bindings::ClientBuilder::credentials
884/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
885/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
886///
887/// # Pooling and Cloning
888///
889/// `TagBindings` holds a connection pool internally, it is advised to
890/// create one and the reuse it. You do not need to wrap `TagBindings` in
891/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
892/// already uses an `Arc` internally.
893#[derive(Clone, Debug)]
894pub struct TagBindings {
895 inner: std::sync::Arc<dyn super::stub::dynamic::TagBindings>,
896}
897
898impl TagBindings {
899 /// Returns a builder for [TagBindings].
900 ///
901 /// ```
902 /// # tokio_test::block_on(async {
903 /// # use google_cloud_resourcemanager_v3::client::TagBindings;
904 /// let client = TagBindings::builder().build().await?;
905 /// # gax::client_builder::Result::<()>::Ok(()) });
906 /// ```
907 pub fn builder() -> super::builder::tag_bindings::ClientBuilder {
908 gax::client_builder::internal::new_builder(super::builder::tag_bindings::client::Factory)
909 }
910
911 /// Creates a new client from the provided stub.
912 ///
913 /// The most common case for calling this function is in tests mocking the
914 /// client's behavior.
915 pub fn from_stub<T>(stub: T) -> Self
916 where
917 T: super::stub::TagBindings + 'static,
918 {
919 Self {
920 inner: std::sync::Arc::new(stub),
921 }
922 }
923
924 pub(crate) async fn new(
925 config: gaxi::options::ClientConfig,
926 ) -> gax::client_builder::Result<Self> {
927 let inner = Self::build_inner(config).await?;
928 Ok(Self { inner })
929 }
930
931 async fn build_inner(
932 conf: gaxi::options::ClientConfig,
933 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagBindings>> {
934 if gaxi::options::tracing_enabled(&conf) {
935 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
936 }
937 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
938 }
939
940 async fn build_transport(
941 conf: gaxi::options::ClientConfig,
942 ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
943 super::transport::TagBindings::new(conf).await
944 }
945
946 async fn build_with_tracing(
947 conf: gaxi::options::ClientConfig,
948 ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
949 Self::build_transport(conf)
950 .await
951 .map(super::tracing::TagBindings::new)
952 }
953
954 /// Lists the TagBindings for the given Google Cloud resource, as specified
955 /// with `parent`.
956 ///
957 /// NOTE: The `parent` field is expected to be a full resource name:
958 /// <https://cloud.google.com/apis/design/resource_names#full_resource_name>
959 pub fn list_tag_bindings(&self) -> super::builder::tag_bindings::ListTagBindings {
960 super::builder::tag_bindings::ListTagBindings::new(self.inner.clone())
961 }
962
963 /// Creates a TagBinding between a TagValue and a Google Cloud resource.
964 ///
965 /// # Long running operations
966 ///
967 /// This method is used to start, and/or poll a [long-running Operation].
968 /// The [Working with long-running operations] chapter in the [user guide]
969 /// covers these operations in detail.
970 ///
971 /// [long-running operation]: https://google.aip.dev/151
972 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
973 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
974 pub fn create_tag_binding(&self) -> super::builder::tag_bindings::CreateTagBinding {
975 super::builder::tag_bindings::CreateTagBinding::new(self.inner.clone())
976 }
977
978 /// Deletes a TagBinding.
979 ///
980 /// # Long running operations
981 ///
982 /// This method is used to start, and/or poll a [long-running Operation].
983 /// The [Working with long-running operations] chapter in the [user guide]
984 /// covers these operations in detail.
985 ///
986 /// [long-running operation]: https://google.aip.dev/151
987 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
988 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
989 pub fn delete_tag_binding(&self) -> super::builder::tag_bindings::DeleteTagBinding {
990 super::builder::tag_bindings::DeleteTagBinding::new(self.inner.clone())
991 }
992
993 /// Return a list of effective tags for the given Google Cloud resource, as
994 /// specified in `parent`.
995 pub fn list_effective_tags(&self) -> super::builder::tag_bindings::ListEffectiveTags {
996 super::builder::tag_bindings::ListEffectiveTags::new(self.inner.clone())
997 }
998
999 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1000 ///
1001 /// [google.longrunning.Operations]: longrunning::client::Operations
1002 pub fn get_operation(&self) -> super::builder::tag_bindings::GetOperation {
1003 super::builder::tag_bindings::GetOperation::new(self.inner.clone())
1004 }
1005}
1006
1007/// Implements a client for the Cloud Resource Manager API.
1008///
1009/// # Example
1010/// ```
1011/// # tokio_test::block_on(async {
1012/// # use google_cloud_resourcemanager_v3::client::TagHolds;
1013/// let client = TagHolds::builder().build().await?;
1014/// // use `client` to make requests to the Cloud Resource Manager API.
1015/// # gax::client_builder::Result::<()>::Ok(()) });
1016/// ```
1017///
1018/// # Service Description
1019///
1020/// Allow users to create and manage TagHolds for TagValues. TagHolds represent
1021/// the use of a Tag Value that is not captured by TagBindings but
1022/// should still block TagValue deletion (such as a reference in a policy
1023/// condition). This service provides isolated failure domains by cloud location
1024/// so that TagHolds can be managed in the same location as their usage.
1025///
1026/// # Configuration
1027///
1028/// To configure `TagHolds` use the `with_*` methods in the type returned
1029/// by [builder()][TagHolds::builder]. The default configuration should
1030/// work for most applications. Common configuration changes include
1031///
1032/// * [with_endpoint()]: by default this client uses the global default endpoint
1033/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1034/// endpoints or running in restricted networks (e.g. a network configured
1035// with [Private Google Access with VPC Service Controls]) may want to
1036/// override this default.
1037/// * [with_credentials()]: by default this client uses
1038/// [Application Default Credentials]. Applications using custom
1039/// authentication may need to override this default.
1040///
1041/// [with_endpoint()]: super::builder::tag_holds::ClientBuilder::with_endpoint
1042/// [with_credentials()]: super::builder::tag_holds::ClientBuilder::credentials
1043/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1044/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1045///
1046/// # Pooling and Cloning
1047///
1048/// `TagHolds` holds a connection pool internally, it is advised to
1049/// create one and the reuse it. You do not need to wrap `TagHolds` in
1050/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1051/// already uses an `Arc` internally.
1052#[derive(Clone, Debug)]
1053pub struct TagHolds {
1054 inner: std::sync::Arc<dyn super::stub::dynamic::TagHolds>,
1055}
1056
1057impl TagHolds {
1058 /// Returns a builder for [TagHolds].
1059 ///
1060 /// ```
1061 /// # tokio_test::block_on(async {
1062 /// # use google_cloud_resourcemanager_v3::client::TagHolds;
1063 /// let client = TagHolds::builder().build().await?;
1064 /// # gax::client_builder::Result::<()>::Ok(()) });
1065 /// ```
1066 pub fn builder() -> super::builder::tag_holds::ClientBuilder {
1067 gax::client_builder::internal::new_builder(super::builder::tag_holds::client::Factory)
1068 }
1069
1070 /// Creates a new client from the provided stub.
1071 ///
1072 /// The most common case for calling this function is in tests mocking the
1073 /// client's behavior.
1074 pub fn from_stub<T>(stub: T) -> Self
1075 where
1076 T: super::stub::TagHolds + 'static,
1077 {
1078 Self {
1079 inner: std::sync::Arc::new(stub),
1080 }
1081 }
1082
1083 pub(crate) async fn new(
1084 config: gaxi::options::ClientConfig,
1085 ) -> gax::client_builder::Result<Self> {
1086 let inner = Self::build_inner(config).await?;
1087 Ok(Self { inner })
1088 }
1089
1090 async fn build_inner(
1091 conf: gaxi::options::ClientConfig,
1092 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagHolds>> {
1093 if gaxi::options::tracing_enabled(&conf) {
1094 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1095 }
1096 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1097 }
1098
1099 async fn build_transport(
1100 conf: gaxi::options::ClientConfig,
1101 ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
1102 super::transport::TagHolds::new(conf).await
1103 }
1104
1105 async fn build_with_tracing(
1106 conf: gaxi::options::ClientConfig,
1107 ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
1108 Self::build_transport(conf)
1109 .await
1110 .map(super::tracing::TagHolds::new)
1111 }
1112
1113 /// Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same
1114 /// resource and origin exists under the same TagValue.
1115 ///
1116 /// # Long running operations
1117 ///
1118 /// This method is used to start, and/or poll a [long-running Operation].
1119 /// The [Working with long-running operations] chapter in the [user guide]
1120 /// covers these operations in detail.
1121 ///
1122 /// [long-running operation]: https://google.aip.dev/151
1123 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1124 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1125 pub fn create_tag_hold(&self) -> super::builder::tag_holds::CreateTagHold {
1126 super::builder::tag_holds::CreateTagHold::new(self.inner.clone())
1127 }
1128
1129 /// Deletes a TagHold.
1130 ///
1131 /// # Long running operations
1132 ///
1133 /// This method is used to start, and/or poll a [long-running Operation].
1134 /// The [Working with long-running operations] chapter in the [user guide]
1135 /// covers these operations in detail.
1136 ///
1137 /// [long-running operation]: https://google.aip.dev/151
1138 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1139 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1140 pub fn delete_tag_hold(&self) -> super::builder::tag_holds::DeleteTagHold {
1141 super::builder::tag_holds::DeleteTagHold::new(self.inner.clone())
1142 }
1143
1144 /// Lists TagHolds under a TagValue.
1145 pub fn list_tag_holds(&self) -> super::builder::tag_holds::ListTagHolds {
1146 super::builder::tag_holds::ListTagHolds::new(self.inner.clone())
1147 }
1148
1149 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1150 ///
1151 /// [google.longrunning.Operations]: longrunning::client::Operations
1152 pub fn get_operation(&self) -> super::builder::tag_holds::GetOperation {
1153 super::builder::tag_holds::GetOperation::new(self.inner.clone())
1154 }
1155}
1156
1157/// Implements a client for the Cloud Resource Manager API.
1158///
1159/// # Example
1160/// ```
1161/// # tokio_test::block_on(async {
1162/// # use google_cloud_resourcemanager_v3::client::TagKeys;
1163/// let client = TagKeys::builder().build().await?;
1164/// // use `client` to make requests to the Cloud Resource Manager API.
1165/// # gax::client_builder::Result::<()>::Ok(()) });
1166/// ```
1167///
1168/// # Service Description
1169///
1170/// Allow users to create and manage tag keys.
1171///
1172/// # Configuration
1173///
1174/// To configure `TagKeys` use the `with_*` methods in the type returned
1175/// by [builder()][TagKeys::builder]. The default configuration should
1176/// work for most applications. Common configuration changes include
1177///
1178/// * [with_endpoint()]: by default this client uses the global default endpoint
1179/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1180/// endpoints or running in restricted networks (e.g. a network configured
1181// with [Private Google Access with VPC Service Controls]) may want to
1182/// override this default.
1183/// * [with_credentials()]: by default this client uses
1184/// [Application Default Credentials]. Applications using custom
1185/// authentication may need to override this default.
1186///
1187/// [with_endpoint()]: super::builder::tag_keys::ClientBuilder::with_endpoint
1188/// [with_credentials()]: super::builder::tag_keys::ClientBuilder::credentials
1189/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1190/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1191///
1192/// # Pooling and Cloning
1193///
1194/// `TagKeys` holds a connection pool internally, it is advised to
1195/// create one and the reuse it. You do not need to wrap `TagKeys` in
1196/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1197/// already uses an `Arc` internally.
1198#[derive(Clone, Debug)]
1199pub struct TagKeys {
1200 inner: std::sync::Arc<dyn super::stub::dynamic::TagKeys>,
1201}
1202
1203impl TagKeys {
1204 /// Returns a builder for [TagKeys].
1205 ///
1206 /// ```
1207 /// # tokio_test::block_on(async {
1208 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1209 /// let client = TagKeys::builder().build().await?;
1210 /// # gax::client_builder::Result::<()>::Ok(()) });
1211 /// ```
1212 pub fn builder() -> super::builder::tag_keys::ClientBuilder {
1213 gax::client_builder::internal::new_builder(super::builder::tag_keys::client::Factory)
1214 }
1215
1216 /// Creates a new client from the provided stub.
1217 ///
1218 /// The most common case for calling this function is in tests mocking the
1219 /// client's behavior.
1220 pub fn from_stub<T>(stub: T) -> Self
1221 where
1222 T: super::stub::TagKeys + 'static,
1223 {
1224 Self {
1225 inner: std::sync::Arc::new(stub),
1226 }
1227 }
1228
1229 pub(crate) async fn new(
1230 config: gaxi::options::ClientConfig,
1231 ) -> gax::client_builder::Result<Self> {
1232 let inner = Self::build_inner(config).await?;
1233 Ok(Self { inner })
1234 }
1235
1236 async fn build_inner(
1237 conf: gaxi::options::ClientConfig,
1238 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagKeys>> {
1239 if gaxi::options::tracing_enabled(&conf) {
1240 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1241 }
1242 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1243 }
1244
1245 async fn build_transport(
1246 conf: gaxi::options::ClientConfig,
1247 ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
1248 super::transport::TagKeys::new(conf).await
1249 }
1250
1251 async fn build_with_tracing(
1252 conf: gaxi::options::ClientConfig,
1253 ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
1254 Self::build_transport(conf)
1255 .await
1256 .map(super::tracing::TagKeys::new)
1257 }
1258
1259 /// Lists all TagKeys for a parent resource.
1260 pub fn list_tag_keys(&self) -> super::builder::tag_keys::ListTagKeys {
1261 super::builder::tag_keys::ListTagKeys::new(self.inner.clone())
1262 }
1263
1264 /// Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the
1265 /// key does not exist or the user does not have permission to view it.
1266 pub fn get_tag_key(&self) -> super::builder::tag_keys::GetTagKey {
1267 super::builder::tag_keys::GetTagKey::new(self.inner.clone())
1268 }
1269
1270 /// Retrieves a TagKey by its namespaced name.
1271 /// This method will return `PERMISSION_DENIED` if the key does not exist
1272 /// or the user does not have permission to view it.
1273 pub fn get_namespaced_tag_key(&self) -> super::builder::tag_keys::GetNamespacedTagKey {
1274 super::builder::tag_keys::GetNamespacedTagKey::new(self.inner.clone())
1275 }
1276
1277 /// Creates a new TagKey. If another request with the same parameters is
1278 /// sent while the original request is in process, the second request
1279 /// will receive an error. A maximum of 1000 TagKeys can exist under a parent
1280 /// at any given time.
1281 ///
1282 /// # Long running operations
1283 ///
1284 /// This method is used to start, and/or poll a [long-running Operation].
1285 /// The [Working with long-running operations] chapter in the [user guide]
1286 /// covers these operations in detail.
1287 ///
1288 /// [long-running operation]: https://google.aip.dev/151
1289 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1290 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1291 pub fn create_tag_key(&self) -> super::builder::tag_keys::CreateTagKey {
1292 super::builder::tag_keys::CreateTagKey::new(self.inner.clone())
1293 }
1294
1295 /// Updates the attributes of the TagKey resource.
1296 ///
1297 /// # Long running operations
1298 ///
1299 /// This method is used to start, and/or poll a [long-running Operation].
1300 /// The [Working with long-running operations] chapter in the [user guide]
1301 /// covers these operations in detail.
1302 ///
1303 /// [long-running operation]: https://google.aip.dev/151
1304 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1305 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1306 pub fn update_tag_key(&self) -> super::builder::tag_keys::UpdateTagKey {
1307 super::builder::tag_keys::UpdateTagKey::new(self.inner.clone())
1308 }
1309
1310 /// Deletes a TagKey. The TagKey cannot be deleted if it has any child
1311 /// TagValues.
1312 ///
1313 /// # Long running operations
1314 ///
1315 /// This method is used to start, and/or poll a [long-running Operation].
1316 /// The [Working with long-running operations] chapter in the [user guide]
1317 /// covers these operations in detail.
1318 ///
1319 /// [long-running operation]: https://google.aip.dev/151
1320 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1321 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1322 pub fn delete_tag_key(&self) -> super::builder::tag_keys::DeleteTagKey {
1323 super::builder::tag_keys::DeleteTagKey::new(self.inner.clone())
1324 }
1325
1326 /// Gets the access control policy for a TagKey. The returned policy may be
1327 /// empty if no such policy or resource exists. The `resource` field should
1328 /// be the TagKey's resource name. For example, "tagKeys/1234".
1329 /// The caller must have
1330 /// `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on
1331 /// the specified TagKey.
1332 pub fn get_iam_policy(&self) -> super::builder::tag_keys::GetIamPolicy {
1333 super::builder::tag_keys::GetIamPolicy::new(self.inner.clone())
1334 }
1335
1336 /// Sets the access control policy on a TagKey, replacing any existing
1337 /// policy. The `resource` field should be the TagKey's resource name.
1338 /// For example, "tagKeys/1234".
1339 /// The caller must have `resourcemanager.tagKeys.setIamPolicy` permission
1340 /// on the identified tagValue.
1341 pub fn set_iam_policy(&self) -> super::builder::tag_keys::SetIamPolicy {
1342 super::builder::tag_keys::SetIamPolicy::new(self.inner.clone())
1343 }
1344
1345 /// Returns permissions that a caller has on the specified TagKey.
1346 /// The `resource` field should be the TagKey's resource name.
1347 /// For example, "tagKeys/1234".
1348 ///
1349 /// There are no permissions required for making this API call.
1350 pub fn test_iam_permissions(&self) -> super::builder::tag_keys::TestIamPermissions {
1351 super::builder::tag_keys::TestIamPermissions::new(self.inner.clone())
1352 }
1353
1354 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1355 ///
1356 /// [google.longrunning.Operations]: longrunning::client::Operations
1357 pub fn get_operation(&self) -> super::builder::tag_keys::GetOperation {
1358 super::builder::tag_keys::GetOperation::new(self.inner.clone())
1359 }
1360}
1361
1362/// Implements a client for the Cloud Resource Manager API.
1363///
1364/// # Example
1365/// ```
1366/// # tokio_test::block_on(async {
1367/// # use google_cloud_resourcemanager_v3::client::TagValues;
1368/// let client = TagValues::builder().build().await?;
1369/// // use `client` to make requests to the Cloud Resource Manager API.
1370/// # gax::client_builder::Result::<()>::Ok(()) });
1371/// ```
1372///
1373/// # Service Description
1374///
1375/// Allow users to create and manage tag values.
1376///
1377/// # Configuration
1378///
1379/// To configure `TagValues` use the `with_*` methods in the type returned
1380/// by [builder()][TagValues::builder]. The default configuration should
1381/// work for most applications. Common configuration changes include
1382///
1383/// * [with_endpoint()]: by default this client uses the global default endpoint
1384/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1385/// endpoints or running in restricted networks (e.g. a network configured
1386// with [Private Google Access with VPC Service Controls]) may want to
1387/// override this default.
1388/// * [with_credentials()]: by default this client uses
1389/// [Application Default Credentials]. Applications using custom
1390/// authentication may need to override this default.
1391///
1392/// [with_endpoint()]: super::builder::tag_values::ClientBuilder::with_endpoint
1393/// [with_credentials()]: super::builder::tag_values::ClientBuilder::credentials
1394/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1395/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1396///
1397/// # Pooling and Cloning
1398///
1399/// `TagValues` holds a connection pool internally, it is advised to
1400/// create one and the reuse it. You do not need to wrap `TagValues` in
1401/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1402/// already uses an `Arc` internally.
1403#[derive(Clone, Debug)]
1404pub struct TagValues {
1405 inner: std::sync::Arc<dyn super::stub::dynamic::TagValues>,
1406}
1407
1408impl TagValues {
1409 /// Returns a builder for [TagValues].
1410 ///
1411 /// ```
1412 /// # tokio_test::block_on(async {
1413 /// # use google_cloud_resourcemanager_v3::client::TagValues;
1414 /// let client = TagValues::builder().build().await?;
1415 /// # gax::client_builder::Result::<()>::Ok(()) });
1416 /// ```
1417 pub fn builder() -> super::builder::tag_values::ClientBuilder {
1418 gax::client_builder::internal::new_builder(super::builder::tag_values::client::Factory)
1419 }
1420
1421 /// Creates a new client from the provided stub.
1422 ///
1423 /// The most common case for calling this function is in tests mocking the
1424 /// client's behavior.
1425 pub fn from_stub<T>(stub: T) -> Self
1426 where
1427 T: super::stub::TagValues + 'static,
1428 {
1429 Self {
1430 inner: std::sync::Arc::new(stub),
1431 }
1432 }
1433
1434 pub(crate) async fn new(
1435 config: gaxi::options::ClientConfig,
1436 ) -> gax::client_builder::Result<Self> {
1437 let inner = Self::build_inner(config).await?;
1438 Ok(Self { inner })
1439 }
1440
1441 async fn build_inner(
1442 conf: gaxi::options::ClientConfig,
1443 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagValues>> {
1444 if gaxi::options::tracing_enabled(&conf) {
1445 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1446 }
1447 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1448 }
1449
1450 async fn build_transport(
1451 conf: gaxi::options::ClientConfig,
1452 ) -> gax::client_builder::Result<impl super::stub::TagValues> {
1453 super::transport::TagValues::new(conf).await
1454 }
1455
1456 async fn build_with_tracing(
1457 conf: gaxi::options::ClientConfig,
1458 ) -> gax::client_builder::Result<impl super::stub::TagValues> {
1459 Self::build_transport(conf)
1460 .await
1461 .map(super::tracing::TagValues::new)
1462 }
1463
1464 /// Lists all TagValues for a specific TagKey.
1465 pub fn list_tag_values(&self) -> super::builder::tag_values::ListTagValues {
1466 super::builder::tag_values::ListTagValues::new(self.inner.clone())
1467 }
1468
1469 /// Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the
1470 /// value does not exist or the user does not have permission to view it.
1471 pub fn get_tag_value(&self) -> super::builder::tag_values::GetTagValue {
1472 super::builder::tag_values::GetTagValue::new(self.inner.clone())
1473 }
1474
1475 /// Retrieves a TagValue by its namespaced name.
1476 /// This method will return `PERMISSION_DENIED` if the value does not exist
1477 /// or the user does not have permission to view it.
1478 pub fn get_namespaced_tag_value(&self) -> super::builder::tag_values::GetNamespacedTagValue {
1479 super::builder::tag_values::GetNamespacedTagValue::new(self.inner.clone())
1480 }
1481
1482 /// Creates a TagValue as a child of the specified TagKey. If a another
1483 /// request with the same parameters is sent while the original request is in
1484 /// process the second request will receive an error. A maximum of 1000
1485 /// TagValues can exist under a TagKey at any given time.
1486 ///
1487 /// # Long running operations
1488 ///
1489 /// This method is used to start, and/or poll a [long-running Operation].
1490 /// The [Working with long-running operations] chapter in the [user guide]
1491 /// covers these operations in detail.
1492 ///
1493 /// [long-running operation]: https://google.aip.dev/151
1494 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1495 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1496 pub fn create_tag_value(&self) -> super::builder::tag_values::CreateTagValue {
1497 super::builder::tag_values::CreateTagValue::new(self.inner.clone())
1498 }
1499
1500 /// Updates the attributes of the TagValue resource.
1501 ///
1502 /// # Long running operations
1503 ///
1504 /// This method is used to start, and/or poll a [long-running Operation].
1505 /// The [Working with long-running operations] chapter in the [user guide]
1506 /// covers these operations in detail.
1507 ///
1508 /// [long-running operation]: https://google.aip.dev/151
1509 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1510 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1511 pub fn update_tag_value(&self) -> super::builder::tag_values::UpdateTagValue {
1512 super::builder::tag_values::UpdateTagValue::new(self.inner.clone())
1513 }
1514
1515 /// Deletes a TagValue. The TagValue cannot have any bindings when it is
1516 /// deleted.
1517 ///
1518 /// # Long running operations
1519 ///
1520 /// This method is used to start, and/or poll a [long-running Operation].
1521 /// The [Working with long-running operations] chapter in the [user guide]
1522 /// covers these operations in detail.
1523 ///
1524 /// [long-running operation]: https://google.aip.dev/151
1525 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1526 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1527 pub fn delete_tag_value(&self) -> super::builder::tag_values::DeleteTagValue {
1528 super::builder::tag_values::DeleteTagValue::new(self.inner.clone())
1529 }
1530
1531 /// Gets the access control policy for a TagValue. The returned policy may be
1532 /// empty if no such policy or resource exists. The `resource` field should
1533 /// be the TagValue's resource name. For example: `tagValues/1234`.
1534 /// The caller must have the
1535 /// `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on
1536 /// the identified TagValue to get the access control policy.
1537 pub fn get_iam_policy(&self) -> super::builder::tag_values::GetIamPolicy {
1538 super::builder::tag_values::GetIamPolicy::new(self.inner.clone())
1539 }
1540
1541 /// Sets the access control policy on a TagValue, replacing any existing
1542 /// policy. The `resource` field should be the TagValue's resource name.
1543 /// For example: `tagValues/1234`.
1544 /// The caller must have `resourcemanager.tagValues.setIamPolicy` permission
1545 /// on the identified tagValue.
1546 pub fn set_iam_policy(&self) -> super::builder::tag_values::SetIamPolicy {
1547 super::builder::tag_values::SetIamPolicy::new(self.inner.clone())
1548 }
1549
1550 /// Returns permissions that a caller has on the specified TagValue.
1551 /// The `resource` field should be the TagValue's resource name. For example:
1552 /// `tagValues/1234`.
1553 ///
1554 /// There are no permissions required for making this API call.
1555 pub fn test_iam_permissions(&self) -> super::builder::tag_values::TestIamPermissions {
1556 super::builder::tag_values::TestIamPermissions::new(self.inner.clone())
1557 }
1558
1559 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1560 ///
1561 /// [google.longrunning.Operations]: longrunning::client::Operations
1562 pub fn get_operation(&self) -> super::builder::tag_values::GetOperation {
1563 super::builder::tag_values::GetOperation::new(self.inner.clone())
1564 }
1565}