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/// # async fn sample() -> gax::client_builder::Result<()> {
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/// # 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 /// # async fn sample() -> gax::client_builder::Result<()> {
72 /// # use google_cloud_resourcemanager_v3::client::Folders;
73 /// let client = Folders::builder().build().await?;
74 /// # 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 ///
129 /// # Example
130 /// ```
131 /// # use google_cloud_resourcemanager_v3::client::Folders;
132 /// use google_cloud_resourcemanager_v3::Result;
133 /// async fn sample(
134 /// client: &Folders,
135 /// resource_name: &str
136 /// ) -> Result<()> {
137 /// let response = client
138 /// .get_folder()
139 /// .set_name(resource_name)
140 /// .send()
141 /// .await?;
142 /// println!("response {:?}", response);
143 /// Ok(())
144 /// }
145 /// ```
146 pub fn get_folder(&self) -> super::builder::folders::GetFolder {
147 super::builder::folders::GetFolder::new(self.inner.clone())
148 }
149
150 /// Lists the folders that are direct descendants of supplied parent resource.
151 /// `list()` provides a strongly consistent view of the folders underneath
152 /// the specified parent resource.
153 /// `list()` returns folders sorted based upon the (ascending) lexical ordering
154 /// of their display_name.
155 /// The caller must have `resourcemanager.folders.list` permission on the
156 /// identified parent.
157 pub fn list_folders(&self) -> super::builder::folders::ListFolders {
158 super::builder::folders::ListFolders::new(self.inner.clone())
159 }
160
161 /// Search for folders that match specific filter criteria.
162 /// `search()` provides an eventually consistent view of the folders a user has
163 /// access to which meet the specified filter criteria.
164 ///
165 /// This will only return folders on which the caller has the
166 /// permission `resourcemanager.folders.get`.
167 pub fn search_folders(&self) -> super::builder::folders::SearchFolders {
168 super::builder::folders::SearchFolders::new(self.inner.clone())
169 }
170
171 /// Creates a folder in the resource hierarchy.
172 /// Returns an `Operation` which can be used to track the progress of the
173 /// folder creation workflow.
174 /// Upon success, the `Operation.response` field will be populated with the
175 /// created Folder.
176 ///
177 /// In order to succeed, the addition of this new folder must not violate
178 /// the folder naming, height, or fanout constraints.
179 ///
180 /// + The folder's `display_name` must be distinct from all other folders that
181 /// share its parent.
182 /// + The addition of the folder must not cause the active folder hierarchy
183 /// to exceed a height of 10. Note, the full active + deleted folder hierarchy
184 /// is allowed to reach a height of 20; this provides additional headroom when
185 /// moving folders that contain deleted folders.
186 /// + The addition of the folder must not cause the total number of folders
187 /// under its parent to exceed 300.
188 ///
189 /// If the operation fails due to a folder constraint violation, some errors
190 /// may be returned by the `CreateFolder` request, with status code
191 /// `FAILED_PRECONDITION` and an error description. Other folder constraint
192 /// violations will be communicated in the `Operation`, with the specific
193 /// `PreconditionFailure` returned in the details list in the `Operation.error`
194 /// field.
195 ///
196 /// The caller must have `resourcemanager.folders.create` permission on the
197 /// identified parent.
198 ///
199 /// # Long running operations
200 ///
201 /// This method is used to start, and/or poll a [long-running Operation].
202 /// The [Working with long-running operations] chapter in the [user guide]
203 /// covers these operations in detail.
204 ///
205 /// [long-running operation]: https://google.aip.dev/151
206 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
207 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
208 ///
209 /// # Example
210 /// ```
211 /// # use google_cloud_resourcemanager_v3::client::Folders;
212 /// # use lro::Poller;
213 /// use google_cloud_resourcemanager_v3::Result;
214 /// async fn sample(
215 /// client: &Folders
216 /// ) -> Result<()> {
217 /// let response = client
218 /// .create_folder()
219 /// /* set fields */
220 /// .poller()
221 /// .until_done()
222 /// .await?;
223 /// println!("response {:?}", response);
224 /// Ok(())
225 /// }
226 /// ```
227 pub fn create_folder(&self) -> super::builder::folders::CreateFolder {
228 super::builder::folders::CreateFolder::new(self.inner.clone())
229 }
230
231 /// Updates a folder, changing its `display_name`.
232 /// Changes to the folder `display_name` will be rejected if they violate
233 /// either the `display_name` formatting rules or the naming constraints
234 /// described in the
235 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
236 /// documentation.
237 ///
238 /// The folder's `display_name` must start and end with a letter or digit,
239 /// may contain letters, digits, spaces, hyphens and underscores and can be
240 /// between 3 and 30 characters. This is captured by the regular expression:
241 /// `[\p{L}\p{N}][\p{L}\p{N}_- ]{1,28}[\p{L}\p{N}]`.
242 /// The caller must have `resourcemanager.folders.update` permission on the
243 /// identified folder.
244 ///
245 /// If the update fails due to the unique name constraint then a
246 /// `PreconditionFailure` explaining this violation will be returned
247 /// in the Status.details field.
248 ///
249 /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
250 ///
251 /// # Long running operations
252 ///
253 /// This method is used to start, and/or poll a [long-running Operation].
254 /// The [Working with long-running operations] chapter in the [user guide]
255 /// covers these operations in detail.
256 ///
257 /// [long-running operation]: https://google.aip.dev/151
258 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
259 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
260 ///
261 /// # Example
262 /// ```
263 /// # use google_cloud_resourcemanager_v3::client::Folders;
264 /// # use lro::Poller;
265 /// use google_cloud_resourcemanager_v3::Result;
266 /// async fn sample(
267 /// client: &Folders
268 /// ) -> Result<()> {
269 /// let response = client
270 /// .update_folder()
271 /// /* set fields */
272 /// .poller()
273 /// .until_done()
274 /// .await?;
275 /// println!("response {:?}", response);
276 /// Ok(())
277 /// }
278 /// ```
279 pub fn update_folder(&self) -> super::builder::folders::UpdateFolder {
280 super::builder::folders::UpdateFolder::new(self.inner.clone())
281 }
282
283 /// Moves a folder under a new resource parent.
284 /// Returns an `Operation` which can be used to track the progress of the
285 /// folder move workflow.
286 /// Upon success, the `Operation.response` field will be populated with the
287 /// moved folder.
288 /// Upon failure, a `FolderOperationError` categorizing the failure cause will
289 /// be returned - if the failure occurs synchronously then the
290 /// `FolderOperationError` will be returned in the `Status.details` field.
291 /// If it occurs asynchronously, then the FolderOperation will be returned
292 /// in the `Operation.error` field.
293 /// In addition, the `Operation.metadata` field will be populated with a
294 /// `FolderOperation` message as an aid to stateless clients.
295 /// Folder moves will be rejected if they violate either the naming, height,
296 /// or fanout constraints described in the
297 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
298 /// documentation. The caller must have `resourcemanager.folders.move`
299 /// permission on the folder's current and proposed new parent.
300 ///
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 ///
313 /// # Example
314 /// ```
315 /// # use google_cloud_resourcemanager_v3::client::Folders;
316 /// # use lro::Poller;
317 /// use google_cloud_resourcemanager_v3::Result;
318 /// async fn sample(
319 /// client: &Folders
320 /// ) -> Result<()> {
321 /// let response = client
322 /// .move_folder()
323 /// /* set fields */
324 /// .poller()
325 /// .until_done()
326 /// .await?;
327 /// println!("response {:?}", response);
328 /// Ok(())
329 /// }
330 /// ```
331 pub fn move_folder(&self) -> super::builder::folders::MoveFolder {
332 super::builder::folders::MoveFolder::new(self.inner.clone())
333 }
334
335 /// Requests deletion of a folder. The folder is moved into the
336 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
337 /// state immediately, and is deleted approximately 30 days later. This method
338 /// may only be called on an empty folder, where a folder is empty if it
339 /// doesn't contain any folders or projects in the
340 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. If
341 /// called on a folder in
342 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]
343 /// state the operation will result in a no-op success.
344 /// The caller must have `resourcemanager.folders.delete` permission on the
345 /// identified folder.
346 ///
347 /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
348 /// [google.cloud.resourcemanager.v3.Folder.State.DELETE_REQUESTED]: crate::model::folder::State::DeleteRequested
349 ///
350 /// # Long running operations
351 ///
352 /// This method is used to start, and/or poll a [long-running Operation].
353 /// The [Working with long-running operations] chapter in the [user guide]
354 /// covers these operations in detail.
355 ///
356 /// [long-running operation]: https://google.aip.dev/151
357 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
358 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
359 ///
360 /// # Example
361 /// ```
362 /// # use google_cloud_resourcemanager_v3::client::Folders;
363 /// # use lro::Poller;
364 /// use google_cloud_resourcemanager_v3::Result;
365 /// async fn sample(
366 /// client: &Folders,
367 /// resource_name: &str
368 /// ) -> Result<()> {
369 /// let response = client
370 /// .delete_folder()
371 /// .set_name(resource_name)
372 /// .poller()
373 /// .until_done()
374 /// .await?;
375 /// println!("response {:?}", response);
376 /// Ok(())
377 /// }
378 /// ```
379 pub fn delete_folder(&self) -> super::builder::folders::DeleteFolder {
380 super::builder::folders::DeleteFolder::new(self.inner.clone())
381 }
382
383 /// Cancels the deletion request for a folder. This method may be called on a
384 /// folder in any state. If the folder is in the
385 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state the
386 /// result will be a no-op success. In order to succeed, the folder's parent
387 /// must be in the
388 /// [ACTIVE][google.cloud.resourcemanager.v3.Folder.State.ACTIVE] state. In
389 /// addition, reintroducing the folder into the tree must not violate folder
390 /// naming, height, and fanout constraints described in the
391 /// [CreateFolder][google.cloud.resourcemanager.v3.Folders.CreateFolder]
392 /// documentation. The caller must have `resourcemanager.folders.undelete`
393 /// permission on the identified folder.
394 ///
395 /// [google.cloud.resourcemanager.v3.Folder.State.ACTIVE]: crate::model::folder::State::Active
396 /// [google.cloud.resourcemanager.v3.Folders.CreateFolder]: crate::client::Folders::create_folder
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_resourcemanager_v3::client::Folders;
411 /// # use lro::Poller;
412 /// use google_cloud_resourcemanager_v3::Result;
413 /// async fn sample(
414 /// client: &Folders,
415 /// resource_name: &str
416 /// ) -> Result<()> {
417 /// let response = client
418 /// .undelete_folder()
419 /// .set_name(resource_name)
420 /// .poller()
421 /// .until_done()
422 /// .await?;
423 /// println!("response {:?}", response);
424 /// Ok(())
425 /// }
426 /// ```
427 pub fn undelete_folder(&self) -> super::builder::folders::UndeleteFolder {
428 super::builder::folders::UndeleteFolder::new(self.inner.clone())
429 }
430
431 /// Gets the access control policy for a folder. The returned policy may be
432 /// empty if no such policy or resource exists. The `resource` field should
433 /// be the folder's resource name, for example: "folders/1234".
434 /// The caller must have `resourcemanager.folders.getIamPolicy` permission
435 /// on the identified folder.
436 ///
437 /// # Example
438 /// ```
439 /// # use google_cloud_resourcemanager_v3::client::Folders;
440 /// use google_cloud_resourcemanager_v3::Result;
441 /// async fn sample(
442 /// client: &Folders
443 /// ) -> Result<()> {
444 /// let response = client
445 /// .get_iam_policy()
446 /// /* set fields */
447 /// .send()
448 /// .await?;
449 /// println!("response {:?}", response);
450 /// Ok(())
451 /// }
452 /// ```
453 pub fn get_iam_policy(&self) -> super::builder::folders::GetIamPolicy {
454 super::builder::folders::GetIamPolicy::new(self.inner.clone())
455 }
456
457 /// Sets the access control policy on a folder, replacing any existing policy.
458 /// The `resource` field should be the folder's resource name, for example:
459 /// "folders/1234".
460 /// The caller must have `resourcemanager.folders.setIamPolicy` permission
461 /// on the identified folder.
462 ///
463 /// # Example
464 /// ```
465 /// # use google_cloud_resourcemanager_v3::client::Folders;
466 /// use google_cloud_resourcemanager_v3::Result;
467 /// async fn sample(
468 /// client: &Folders
469 /// ) -> Result<()> {
470 /// let response = client
471 /// .set_iam_policy()
472 /// /* set fields */
473 /// .send()
474 /// .await?;
475 /// println!("response {:?}", response);
476 /// Ok(())
477 /// }
478 /// ```
479 pub fn set_iam_policy(&self) -> super::builder::folders::SetIamPolicy {
480 super::builder::folders::SetIamPolicy::new(self.inner.clone())
481 }
482
483 /// Returns permissions that a caller has on the specified folder.
484 /// The `resource` field should be the folder's resource name,
485 /// for example: "folders/1234".
486 ///
487 /// There are no permissions required for making this API call.
488 ///
489 /// # Example
490 /// ```
491 /// # use google_cloud_resourcemanager_v3::client::Folders;
492 /// use google_cloud_resourcemanager_v3::Result;
493 /// async fn sample(
494 /// client: &Folders
495 /// ) -> Result<()> {
496 /// let response = client
497 /// .test_iam_permissions()
498 /// /* set fields */
499 /// .send()
500 /// .await?;
501 /// println!("response {:?}", response);
502 /// Ok(())
503 /// }
504 /// ```
505 pub fn test_iam_permissions(&self) -> super::builder::folders::TestIamPermissions {
506 super::builder::folders::TestIamPermissions::new(self.inner.clone())
507 }
508
509 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
510 ///
511 /// [google.longrunning.Operations]: longrunning::client::Operations
512 ///
513 /// # Example
514 /// ```
515 /// # use google_cloud_resourcemanager_v3::client::Folders;
516 /// use google_cloud_resourcemanager_v3::Result;
517 /// async fn sample(
518 /// client: &Folders
519 /// ) -> Result<()> {
520 /// let response = client
521 /// .get_operation()
522 /// /* set fields */
523 /// .send()
524 /// .await?;
525 /// println!("response {:?}", response);
526 /// Ok(())
527 /// }
528 /// ```
529 pub fn get_operation(&self) -> super::builder::folders::GetOperation {
530 super::builder::folders::GetOperation::new(self.inner.clone())
531 }
532}
533
534/// Implements a client for the Cloud Resource Manager API.
535///
536/// # Example
537/// ```
538/// # async fn sample() -> gax::client_builder::Result<()> {
539/// # use google_cloud_resourcemanager_v3::client::Organizations;
540/// let client = Organizations::builder().build().await?;
541/// // use `client` to make requests to the Cloud Resource Manager API.
542/// # Ok(()) }
543/// ```
544///
545/// # Service Description
546///
547/// Allows users to manage their organization resources.
548///
549/// # Configuration
550///
551/// To configure `Organizations` use the `with_*` methods in the type returned
552/// by [builder()][Organizations::builder]. The default configuration should
553/// work for most applications. Common configuration changes include
554///
555/// * [with_endpoint()]: by default this client uses the global default endpoint
556/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
557/// endpoints or running in restricted networks (e.g. a network configured
558// with [Private Google Access with VPC Service Controls]) may want to
559/// override this default.
560/// * [with_credentials()]: by default this client uses
561/// [Application Default Credentials]. Applications using custom
562/// authentication may need to override this default.
563///
564/// [with_endpoint()]: super::builder::organizations::ClientBuilder::with_endpoint
565/// [with_credentials()]: super::builder::organizations::ClientBuilder::credentials
566/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
567/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
568///
569/// # Pooling and Cloning
570///
571/// `Organizations` holds a connection pool internally, it is advised to
572/// create one and the reuse it. You do not need to wrap `Organizations` in
573/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
574/// already uses an `Arc` internally.
575#[derive(Clone, Debug)]
576pub struct Organizations {
577 inner: std::sync::Arc<dyn super::stub::dynamic::Organizations>,
578}
579
580impl Organizations {
581 /// Returns a builder for [Organizations].
582 ///
583 /// ```
584 /// # async fn sample() -> gax::client_builder::Result<()> {
585 /// # use google_cloud_resourcemanager_v3::client::Organizations;
586 /// let client = Organizations::builder().build().await?;
587 /// # Ok(()) }
588 /// ```
589 pub fn builder() -> super::builder::organizations::ClientBuilder {
590 gax::client_builder::internal::new_builder(super::builder::organizations::client::Factory)
591 }
592
593 /// Creates a new client from the provided stub.
594 ///
595 /// The most common case for calling this function is in tests mocking the
596 /// client's behavior.
597 pub fn from_stub<T>(stub: T) -> Self
598 where
599 T: super::stub::Organizations + 'static,
600 {
601 Self {
602 inner: std::sync::Arc::new(stub),
603 }
604 }
605
606 pub(crate) async fn new(
607 config: gaxi::options::ClientConfig,
608 ) -> gax::client_builder::Result<Self> {
609 let inner = Self::build_inner(config).await?;
610 Ok(Self { inner })
611 }
612
613 async fn build_inner(
614 conf: gaxi::options::ClientConfig,
615 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Organizations>> {
616 if gaxi::options::tracing_enabled(&conf) {
617 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
618 }
619 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
620 }
621
622 async fn build_transport(
623 conf: gaxi::options::ClientConfig,
624 ) -> gax::client_builder::Result<impl super::stub::Organizations> {
625 super::transport::Organizations::new(conf).await
626 }
627
628 async fn build_with_tracing(
629 conf: gaxi::options::ClientConfig,
630 ) -> gax::client_builder::Result<impl super::stub::Organizations> {
631 Self::build_transport(conf)
632 .await
633 .map(super::tracing::Organizations::new)
634 }
635
636 /// Fetches an organization resource identified by the specified resource name.
637 ///
638 /// # Example
639 /// ```
640 /// # use google_cloud_resourcemanager_v3::client::Organizations;
641 /// use google_cloud_resourcemanager_v3::Result;
642 /// async fn sample(
643 /// client: &Organizations,
644 /// resource_name: &str
645 /// ) -> Result<()> {
646 /// let response = client
647 /// .get_organization()
648 /// .set_name(resource_name)
649 /// .send()
650 /// .await?;
651 /// println!("response {:?}", response);
652 /// Ok(())
653 /// }
654 /// ```
655 pub fn get_organization(&self) -> super::builder::organizations::GetOrganization {
656 super::builder::organizations::GetOrganization::new(self.inner.clone())
657 }
658
659 /// Searches organization resources that are visible to the user and satisfy
660 /// the specified filter. This method returns organizations in an unspecified
661 /// order. New organizations do not necessarily appear at the end of the
662 /// results, and may take a small amount of time to appear.
663 ///
664 /// Search will only return organizations on which the user has the permission
665 /// `resourcemanager.organizations.get`
666 pub fn search_organizations(&self) -> super::builder::organizations::SearchOrganizations {
667 super::builder::organizations::SearchOrganizations::new(self.inner.clone())
668 }
669
670 /// Gets the access control policy for an organization resource. The policy may
671 /// be empty if no such policy or resource exists. The `resource` field should
672 /// be the organization's resource name, for example: "organizations/123".
673 ///
674 /// Authorization requires the IAM permission
675 /// `resourcemanager.organizations.getIamPolicy` on the specified organization.
676 ///
677 /// # Example
678 /// ```
679 /// # use google_cloud_resourcemanager_v3::client::Organizations;
680 /// use google_cloud_resourcemanager_v3::Result;
681 /// async fn sample(
682 /// client: &Organizations
683 /// ) -> Result<()> {
684 /// let response = client
685 /// .get_iam_policy()
686 /// /* set fields */
687 /// .send()
688 /// .await?;
689 /// println!("response {:?}", response);
690 /// Ok(())
691 /// }
692 /// ```
693 pub fn get_iam_policy(&self) -> super::builder::organizations::GetIamPolicy {
694 super::builder::organizations::GetIamPolicy::new(self.inner.clone())
695 }
696
697 /// Sets the access control policy on an organization resource. Replaces any
698 /// existing policy. The `resource` field should be the organization's resource
699 /// name, for example: "organizations/123".
700 ///
701 /// Authorization requires the IAM permission
702 /// `resourcemanager.organizations.setIamPolicy` on the specified organization.
703 ///
704 /// # Example
705 /// ```
706 /// # use google_cloud_resourcemanager_v3::client::Organizations;
707 /// use google_cloud_resourcemanager_v3::Result;
708 /// async fn sample(
709 /// client: &Organizations
710 /// ) -> Result<()> {
711 /// let response = client
712 /// .set_iam_policy()
713 /// /* set fields */
714 /// .send()
715 /// .await?;
716 /// println!("response {:?}", response);
717 /// Ok(())
718 /// }
719 /// ```
720 pub fn set_iam_policy(&self) -> super::builder::organizations::SetIamPolicy {
721 super::builder::organizations::SetIamPolicy::new(self.inner.clone())
722 }
723
724 /// Returns the permissions that a caller has on the specified organization.
725 /// The `resource` field should be the organization's resource name,
726 /// for example: "organizations/123".
727 ///
728 /// There are no permissions required for making this API call.
729 ///
730 /// # Example
731 /// ```
732 /// # use google_cloud_resourcemanager_v3::client::Organizations;
733 /// use google_cloud_resourcemanager_v3::Result;
734 /// async fn sample(
735 /// client: &Organizations
736 /// ) -> Result<()> {
737 /// let response = client
738 /// .test_iam_permissions()
739 /// /* set fields */
740 /// .send()
741 /// .await?;
742 /// println!("response {:?}", response);
743 /// Ok(())
744 /// }
745 /// ```
746 pub fn test_iam_permissions(&self) -> super::builder::organizations::TestIamPermissions {
747 super::builder::organizations::TestIamPermissions::new(self.inner.clone())
748 }
749
750 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
751 ///
752 /// [google.longrunning.Operations]: longrunning::client::Operations
753 ///
754 /// # Example
755 /// ```
756 /// # use google_cloud_resourcemanager_v3::client::Organizations;
757 /// use google_cloud_resourcemanager_v3::Result;
758 /// async fn sample(
759 /// client: &Organizations
760 /// ) -> Result<()> {
761 /// let response = client
762 /// .get_operation()
763 /// /* set fields */
764 /// .send()
765 /// .await?;
766 /// println!("response {:?}", response);
767 /// Ok(())
768 /// }
769 /// ```
770 pub fn get_operation(&self) -> super::builder::organizations::GetOperation {
771 super::builder::organizations::GetOperation::new(self.inner.clone())
772 }
773}
774
775/// Implements a client for the Cloud Resource Manager API.
776///
777/// # Example
778/// ```
779/// # async fn sample() -> gax::client_builder::Result<()> {
780/// # use google_cloud_resourcemanager_v3::client::Projects;
781/// let client = Projects::builder().build().await?;
782/// // use `client` to make requests to the Cloud Resource Manager API.
783/// # Ok(()) }
784/// ```
785///
786/// # Service Description
787///
788/// Manages Google Cloud Projects.
789///
790/// # Configuration
791///
792/// To configure `Projects` use the `with_*` methods in the type returned
793/// by [builder()][Projects::builder]. The default configuration should
794/// work for most applications. Common configuration changes include
795///
796/// * [with_endpoint()]: by default this client uses the global default endpoint
797/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
798/// endpoints or running in restricted networks (e.g. a network configured
799// with [Private Google Access with VPC Service Controls]) may want to
800/// override this default.
801/// * [with_credentials()]: by default this client uses
802/// [Application Default Credentials]. Applications using custom
803/// authentication may need to override this default.
804///
805/// [with_endpoint()]: super::builder::projects::ClientBuilder::with_endpoint
806/// [with_credentials()]: super::builder::projects::ClientBuilder::credentials
807/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
808/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
809///
810/// # Pooling and Cloning
811///
812/// `Projects` holds a connection pool internally, it is advised to
813/// create one and the reuse it. You do not need to wrap `Projects` in
814/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
815/// already uses an `Arc` internally.
816#[derive(Clone, Debug)]
817pub struct Projects {
818 inner: std::sync::Arc<dyn super::stub::dynamic::Projects>,
819}
820
821impl Projects {
822 /// Returns a builder for [Projects].
823 ///
824 /// ```
825 /// # async fn sample() -> gax::client_builder::Result<()> {
826 /// # use google_cloud_resourcemanager_v3::client::Projects;
827 /// let client = Projects::builder().build().await?;
828 /// # Ok(()) }
829 /// ```
830 pub fn builder() -> super::builder::projects::ClientBuilder {
831 gax::client_builder::internal::new_builder(super::builder::projects::client::Factory)
832 }
833
834 /// Creates a new client from the provided stub.
835 ///
836 /// The most common case for calling this function is in tests mocking the
837 /// client's behavior.
838 pub fn from_stub<T>(stub: T) -> Self
839 where
840 T: super::stub::Projects + 'static,
841 {
842 Self {
843 inner: std::sync::Arc::new(stub),
844 }
845 }
846
847 pub(crate) async fn new(
848 config: gaxi::options::ClientConfig,
849 ) -> gax::client_builder::Result<Self> {
850 let inner = Self::build_inner(config).await?;
851 Ok(Self { inner })
852 }
853
854 async fn build_inner(
855 conf: gaxi::options::ClientConfig,
856 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::Projects>> {
857 if gaxi::options::tracing_enabled(&conf) {
858 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
859 }
860 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
861 }
862
863 async fn build_transport(
864 conf: gaxi::options::ClientConfig,
865 ) -> gax::client_builder::Result<impl super::stub::Projects> {
866 super::transport::Projects::new(conf).await
867 }
868
869 async fn build_with_tracing(
870 conf: gaxi::options::ClientConfig,
871 ) -> gax::client_builder::Result<impl super::stub::Projects> {
872 Self::build_transport(conf)
873 .await
874 .map(super::tracing::Projects::new)
875 }
876
877 /// Retrieves the project identified by the specified `name` (for example,
878 /// `projects/415104041262`).
879 ///
880 /// The caller must have `resourcemanager.projects.get` permission
881 /// for this project.
882 ///
883 /// # Example
884 /// ```
885 /// # use google_cloud_resourcemanager_v3::client::Projects;
886 /// use google_cloud_resourcemanager_v3::Result;
887 /// async fn sample(
888 /// client: &Projects,
889 /// resource_name: &str
890 /// ) -> Result<()> {
891 /// let response = client
892 /// .get_project()
893 /// .set_name(resource_name)
894 /// .send()
895 /// .await?;
896 /// println!("response {:?}", response);
897 /// Ok(())
898 /// }
899 /// ```
900 pub fn get_project(&self) -> super::builder::projects::GetProject {
901 super::builder::projects::GetProject::new(self.inner.clone())
902 }
903
904 /// Lists projects that are direct children of the specified folder or
905 /// organization resource. `list()` provides a strongly consistent view of the
906 /// projects underneath the specified parent resource. `list()` returns
907 /// projects sorted based upon the (ascending) lexical ordering of their
908 /// `display_name`. The caller must have `resourcemanager.projects.list`
909 /// permission on the identified parent.
910 pub fn list_projects(&self) -> super::builder::projects::ListProjects {
911 super::builder::projects::ListProjects::new(self.inner.clone())
912 }
913
914 /// Search for projects that the caller has both `resourcemanager.projects.get`
915 /// permission on, and also satisfy the specified query.
916 ///
917 /// This method returns projects in an unspecified order.
918 ///
919 /// This method is eventually consistent with project mutations; this means
920 /// that a newly created project may not appear in the results or recent
921 /// updates to an existing project may not be reflected in the results. To
922 /// retrieve the latest state of a project, use the
923 /// [GetProject][google.cloud.resourcemanager.v3.Projects.GetProject] method.
924 ///
925 /// [google.cloud.resourcemanager.v3.Projects.GetProject]: crate::client::Projects::get_project
926 pub fn search_projects(&self) -> super::builder::projects::SearchProjects {
927 super::builder::projects::SearchProjects::new(self.inner.clone())
928 }
929
930 /// Request that a new project be created. The result is an `Operation` which
931 /// can be used to track the creation process. This process usually takes a few
932 /// seconds, but can sometimes take much longer. The tracking `Operation` is
933 /// automatically deleted after a few hours, so there is no need to call
934 /// `DeleteOperation`.
935 ///
936 /// # Long running operations
937 ///
938 /// This method is used to start, and/or poll a [long-running Operation].
939 /// The [Working with long-running operations] chapter in the [user guide]
940 /// covers these operations in detail.
941 ///
942 /// [long-running operation]: https://google.aip.dev/151
943 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
944 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
945 ///
946 /// # Example
947 /// ```
948 /// # use google_cloud_resourcemanager_v3::client::Projects;
949 /// # use lro::Poller;
950 /// use google_cloud_resourcemanager_v3::Result;
951 /// async fn sample(
952 /// client: &Projects
953 /// ) -> Result<()> {
954 /// let response = client
955 /// .create_project()
956 /// /* set fields */
957 /// .poller()
958 /// .until_done()
959 /// .await?;
960 /// println!("response {:?}", response);
961 /// Ok(())
962 /// }
963 /// ```
964 pub fn create_project(&self) -> super::builder::projects::CreateProject {
965 super::builder::projects::CreateProject::new(self.inner.clone())
966 }
967
968 /// Updates the `display_name` and labels of the project identified by the
969 /// specified `name` (for example, `projects/415104041262`). Deleting all
970 /// labels requires an update mask for labels field.
971 ///
972 /// The caller must have `resourcemanager.projects.update` permission for this
973 /// project.
974 ///
975 /// # Long running operations
976 ///
977 /// This method is used to start, and/or poll a [long-running Operation].
978 /// The [Working with long-running operations] chapter in the [user guide]
979 /// covers these operations in detail.
980 ///
981 /// [long-running operation]: https://google.aip.dev/151
982 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
983 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
984 ///
985 /// # Example
986 /// ```
987 /// # use google_cloud_resourcemanager_v3::client::Projects;
988 /// # use lro::Poller;
989 /// use google_cloud_resourcemanager_v3::Result;
990 /// async fn sample(
991 /// client: &Projects
992 /// ) -> Result<()> {
993 /// let response = client
994 /// .update_project()
995 /// /* set fields */
996 /// .poller()
997 /// .until_done()
998 /// .await?;
999 /// println!("response {:?}", response);
1000 /// Ok(())
1001 /// }
1002 /// ```
1003 pub fn update_project(&self) -> super::builder::projects::UpdateProject {
1004 super::builder::projects::UpdateProject::new(self.inner.clone())
1005 }
1006
1007 /// Move a project to another place in your resource hierarchy, under a new
1008 /// resource parent.
1009 ///
1010 /// Returns an operation which can be used to track the process of the project
1011 /// move workflow.
1012 /// Upon success, the `Operation.response` field will be populated with the
1013 /// moved project.
1014 ///
1015 /// The caller must have `resourcemanager.projects.move` permission on the
1016 /// project, on the project's current and proposed new parent.
1017 ///
1018 /// If project has no current parent, or it currently does not have an
1019 /// associated organization resource, you will also need the
1020 /// `resourcemanager.projects.setIamPolicy` permission in the project.
1021 ///
1022 /// # Long running operations
1023 ///
1024 /// This method is used to start, and/or poll a [long-running Operation].
1025 /// The [Working with long-running operations] chapter in the [user guide]
1026 /// covers these operations in detail.
1027 ///
1028 /// [long-running operation]: https://google.aip.dev/151
1029 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1030 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1031 ///
1032 /// # Example
1033 /// ```
1034 /// # use google_cloud_resourcemanager_v3::client::Projects;
1035 /// # use lro::Poller;
1036 /// use google_cloud_resourcemanager_v3::Result;
1037 /// async fn sample(
1038 /// client: &Projects
1039 /// ) -> Result<()> {
1040 /// let response = client
1041 /// .move_project()
1042 /// /* set fields */
1043 /// .poller()
1044 /// .until_done()
1045 /// .await?;
1046 /// println!("response {:?}", response);
1047 /// Ok(())
1048 /// }
1049 /// ```
1050 pub fn move_project(&self) -> super::builder::projects::MoveProject {
1051 super::builder::projects::MoveProject::new(self.inner.clone())
1052 }
1053
1054 /// Marks the project identified by the specified
1055 /// `name` (for example, `projects/415104041262`) for deletion.
1056 ///
1057 /// This method will only affect the project if it has a lifecycle state of
1058 /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE].
1059 ///
1060 /// This method changes the Project's lifecycle state from
1061 /// [ACTIVE][google.cloud.resourcemanager.v3.Project.State.ACTIVE]
1062 /// to
1063 /// [DELETE_REQUESTED][google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED].
1064 /// The deletion starts at an unspecified time,
1065 /// at which point the Project is no longer accessible.
1066 ///
1067 /// Until the deletion completes, you can check the lifecycle state
1068 /// checked by retrieving the project with [GetProject]
1069 /// [google.cloud.resourcemanager.v3.Projects.GetProject],
1070 /// and the project remains visible to [ListProjects]
1071 /// [google.cloud.resourcemanager.v3.Projects.ListProjects].
1072 /// However, you cannot update the project.
1073 ///
1074 /// After the deletion completes, the project is not retrievable by
1075 /// the [GetProject]
1076 /// [google.cloud.resourcemanager.v3.Projects.GetProject],
1077 /// [ListProjects]
1078 /// [google.cloud.resourcemanager.v3.Projects.ListProjects], and
1079 /// [SearchProjects][google.cloud.resourcemanager.v3.Projects.SearchProjects]
1080 /// methods.
1081 ///
1082 /// This method behaves idempotently, such that deleting a `DELETE_REQUESTED`
1083 /// project will not cause an error, but also won't do anything.
1084 ///
1085 /// The caller must have `resourcemanager.projects.delete` permissions for this
1086 /// project.
1087 ///
1088 /// [google.cloud.resourcemanager.v3.Project.State.ACTIVE]: crate::model::project::State::Active
1089 /// [google.cloud.resourcemanager.v3.Project.State.DELETE_REQUESTED]: crate::model::project::State::DeleteRequested
1090 /// [google.cloud.resourcemanager.v3.Projects.SearchProjects]: crate::client::Projects::search_projects
1091 ///
1092 /// # Long running operations
1093 ///
1094 /// This method is used to start, and/or poll a [long-running Operation].
1095 /// The [Working with long-running operations] chapter in the [user guide]
1096 /// covers these operations in detail.
1097 ///
1098 /// [long-running operation]: https://google.aip.dev/151
1099 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1100 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1101 ///
1102 /// # Example
1103 /// ```
1104 /// # use google_cloud_resourcemanager_v3::client::Projects;
1105 /// # use lro::Poller;
1106 /// use google_cloud_resourcemanager_v3::Result;
1107 /// async fn sample(
1108 /// client: &Projects,
1109 /// resource_name: &str
1110 /// ) -> Result<()> {
1111 /// let response = client
1112 /// .delete_project()
1113 /// .set_name(resource_name)
1114 /// .poller()
1115 /// .until_done()
1116 /// .await?;
1117 /// println!("response {:?}", response);
1118 /// Ok(())
1119 /// }
1120 /// ```
1121 pub fn delete_project(&self) -> super::builder::projects::DeleteProject {
1122 super::builder::projects::DeleteProject::new(self.inner.clone())
1123 }
1124
1125 /// Restores the project identified by the specified
1126 /// `name` (for example, `projects/415104041262`).
1127 /// You can only use this method for a project that has a lifecycle state of
1128 /// [DELETE_REQUESTED]
1129 /// [Projects.State.DELETE_REQUESTED].
1130 /// After deletion starts, the project cannot be restored.
1131 ///
1132 /// The caller must have `resourcemanager.projects.undelete` permission for
1133 /// this project.
1134 ///
1135 /// # Long running operations
1136 ///
1137 /// This method is used to start, and/or poll a [long-running Operation].
1138 /// The [Working with long-running operations] chapter in the [user guide]
1139 /// covers these operations in detail.
1140 ///
1141 /// [long-running operation]: https://google.aip.dev/151
1142 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1143 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1144 ///
1145 /// # Example
1146 /// ```
1147 /// # use google_cloud_resourcemanager_v3::client::Projects;
1148 /// # use lro::Poller;
1149 /// use google_cloud_resourcemanager_v3::Result;
1150 /// async fn sample(
1151 /// client: &Projects,
1152 /// resource_name: &str
1153 /// ) -> Result<()> {
1154 /// let response = client
1155 /// .undelete_project()
1156 /// .set_name(resource_name)
1157 /// .poller()
1158 /// .until_done()
1159 /// .await?;
1160 /// println!("response {:?}", response);
1161 /// Ok(())
1162 /// }
1163 /// ```
1164 pub fn undelete_project(&self) -> super::builder::projects::UndeleteProject {
1165 super::builder::projects::UndeleteProject::new(self.inner.clone())
1166 }
1167
1168 /// Returns the IAM access control policy for the specified project, in the
1169 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
1170 /// Permission is denied if the policy or the resource do not exist.
1171 ///
1172 /// # Example
1173 /// ```
1174 /// # use google_cloud_resourcemanager_v3::client::Projects;
1175 /// use google_cloud_resourcemanager_v3::Result;
1176 /// async fn sample(
1177 /// client: &Projects
1178 /// ) -> Result<()> {
1179 /// let response = client
1180 /// .get_iam_policy()
1181 /// /* set fields */
1182 /// .send()
1183 /// .await?;
1184 /// println!("response {:?}", response);
1185 /// Ok(())
1186 /// }
1187 /// ```
1188 pub fn get_iam_policy(&self) -> super::builder::projects::GetIamPolicy {
1189 super::builder::projects::GetIamPolicy::new(self.inner.clone())
1190 }
1191
1192 /// Sets the IAM access control policy for the specified project, in the
1193 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123.
1194 ///
1195 /// CAUTION: This method will replace the existing policy, and cannot be used
1196 /// to append additional IAM settings.
1197 ///
1198 /// Note: Removing service accounts from policies or changing their roles can
1199 /// render services completely inoperable. It is important to understand how
1200 /// the service account is being used before removing or updating its roles.
1201 ///
1202 /// The following constraints apply when using `setIamPolicy()`:
1203 ///
1204 /// + Project does not support `allUsers` and `allAuthenticatedUsers` as
1205 /// `members` in a `Binding` of a `Policy`.
1206 ///
1207 /// + The owner role can be granted to a `user`, `serviceAccount`, or a group
1208 /// that is part of an organization. For example,
1209 /// group@myownpersonaldomain.com could be added as an owner to a project in
1210 /// the myownpersonaldomain.com organization, but not the examplepetstore.com
1211 /// organization.
1212 ///
1213 /// + Service accounts can be made owners of a project directly
1214 /// without any restrictions. However, to be added as an owner, a user must be
1215 /// invited using the Cloud Platform console and must accept the invitation.
1216 ///
1217 /// + A user cannot be granted the owner role using `setIamPolicy()`. The user
1218 /// must be granted the owner role using the Cloud Platform Console and must
1219 /// explicitly accept the invitation.
1220 ///
1221 /// + Invitations to grant the owner role cannot be sent using
1222 /// `setIamPolicy()`;
1223 /// they must be sent only using the Cloud Platform Console.
1224 ///
1225 /// + If the project is not part of an organization, there must be at least
1226 /// one owner who has accepted the Terms of Service (ToS) agreement in the
1227 /// policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner
1228 /// from the policy will fail. This restriction also applies to legacy
1229 /// projects that no longer have owners who have accepted the ToS. Edits to
1230 /// IAM policies will be rejected until the lack of a ToS-accepting owner is
1231 /// rectified. If the project is part of an organization, you can remove all
1232 /// owners, potentially making the organization inaccessible.
1233 ///
1234 ///
1235 /// # Example
1236 /// ```
1237 /// # use google_cloud_resourcemanager_v3::client::Projects;
1238 /// use google_cloud_resourcemanager_v3::Result;
1239 /// async fn sample(
1240 /// client: &Projects
1241 /// ) -> Result<()> {
1242 /// let response = client
1243 /// .set_iam_policy()
1244 /// /* set fields */
1245 /// .send()
1246 /// .await?;
1247 /// println!("response {:?}", response);
1248 /// Ok(())
1249 /// }
1250 /// ```
1251 pub fn set_iam_policy(&self) -> super::builder::projects::SetIamPolicy {
1252 super::builder::projects::SetIamPolicy::new(self.inner.clone())
1253 }
1254
1255 /// Returns permissions that a caller has on the specified project, in the
1256 /// format `projects/{ProjectIdOrNumber}` e.g. projects/123..
1257 ///
1258 /// # Example
1259 /// ```
1260 /// # use google_cloud_resourcemanager_v3::client::Projects;
1261 /// use google_cloud_resourcemanager_v3::Result;
1262 /// async fn sample(
1263 /// client: &Projects
1264 /// ) -> Result<()> {
1265 /// let response = client
1266 /// .test_iam_permissions()
1267 /// /* set fields */
1268 /// .send()
1269 /// .await?;
1270 /// println!("response {:?}", response);
1271 /// Ok(())
1272 /// }
1273 /// ```
1274 pub fn test_iam_permissions(&self) -> super::builder::projects::TestIamPermissions {
1275 super::builder::projects::TestIamPermissions::new(self.inner.clone())
1276 }
1277
1278 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1279 ///
1280 /// [google.longrunning.Operations]: longrunning::client::Operations
1281 ///
1282 /// # Example
1283 /// ```
1284 /// # use google_cloud_resourcemanager_v3::client::Projects;
1285 /// use google_cloud_resourcemanager_v3::Result;
1286 /// async fn sample(
1287 /// client: &Projects
1288 /// ) -> Result<()> {
1289 /// let response = client
1290 /// .get_operation()
1291 /// /* set fields */
1292 /// .send()
1293 /// .await?;
1294 /// println!("response {:?}", response);
1295 /// Ok(())
1296 /// }
1297 /// ```
1298 pub fn get_operation(&self) -> super::builder::projects::GetOperation {
1299 super::builder::projects::GetOperation::new(self.inner.clone())
1300 }
1301}
1302
1303/// Implements a client for the Cloud Resource Manager API.
1304///
1305/// # Example
1306/// ```
1307/// # async fn sample() -> gax::client_builder::Result<()> {
1308/// # use google_cloud_resourcemanager_v3::client::TagBindings;
1309/// let client = TagBindings::builder().build().await?;
1310/// // use `client` to make requests to the Cloud Resource Manager API.
1311/// # Ok(()) }
1312/// ```
1313///
1314/// # Service Description
1315///
1316/// Allow users to create and manage TagBindings between TagValues and
1317/// different Google Cloud resources throughout the GCP resource hierarchy.
1318///
1319/// # Configuration
1320///
1321/// To configure `TagBindings` use the `with_*` methods in the type returned
1322/// by [builder()][TagBindings::builder]. The default configuration should
1323/// work for most applications. Common configuration changes include
1324///
1325/// * [with_endpoint()]: by default this client uses the global default endpoint
1326/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1327/// endpoints or running in restricted networks (e.g. a network configured
1328// with [Private Google Access with VPC Service Controls]) may want to
1329/// override this default.
1330/// * [with_credentials()]: by default this client uses
1331/// [Application Default Credentials]. Applications using custom
1332/// authentication may need to override this default.
1333///
1334/// [with_endpoint()]: super::builder::tag_bindings::ClientBuilder::with_endpoint
1335/// [with_credentials()]: super::builder::tag_bindings::ClientBuilder::credentials
1336/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1337/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1338///
1339/// # Pooling and Cloning
1340///
1341/// `TagBindings` holds a connection pool internally, it is advised to
1342/// create one and the reuse it. You do not need to wrap `TagBindings` in
1343/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1344/// already uses an `Arc` internally.
1345#[derive(Clone, Debug)]
1346pub struct TagBindings {
1347 inner: std::sync::Arc<dyn super::stub::dynamic::TagBindings>,
1348}
1349
1350impl TagBindings {
1351 /// Returns a builder for [TagBindings].
1352 ///
1353 /// ```
1354 /// # async fn sample() -> gax::client_builder::Result<()> {
1355 /// # use google_cloud_resourcemanager_v3::client::TagBindings;
1356 /// let client = TagBindings::builder().build().await?;
1357 /// # Ok(()) }
1358 /// ```
1359 pub fn builder() -> super::builder::tag_bindings::ClientBuilder {
1360 gax::client_builder::internal::new_builder(super::builder::tag_bindings::client::Factory)
1361 }
1362
1363 /// Creates a new client from the provided stub.
1364 ///
1365 /// The most common case for calling this function is in tests mocking the
1366 /// client's behavior.
1367 pub fn from_stub<T>(stub: T) -> Self
1368 where
1369 T: super::stub::TagBindings + 'static,
1370 {
1371 Self {
1372 inner: std::sync::Arc::new(stub),
1373 }
1374 }
1375
1376 pub(crate) async fn new(
1377 config: gaxi::options::ClientConfig,
1378 ) -> gax::client_builder::Result<Self> {
1379 let inner = Self::build_inner(config).await?;
1380 Ok(Self { inner })
1381 }
1382
1383 async fn build_inner(
1384 conf: gaxi::options::ClientConfig,
1385 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagBindings>> {
1386 if gaxi::options::tracing_enabled(&conf) {
1387 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1388 }
1389 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1390 }
1391
1392 async fn build_transport(
1393 conf: gaxi::options::ClientConfig,
1394 ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
1395 super::transport::TagBindings::new(conf).await
1396 }
1397
1398 async fn build_with_tracing(
1399 conf: gaxi::options::ClientConfig,
1400 ) -> gax::client_builder::Result<impl super::stub::TagBindings> {
1401 Self::build_transport(conf)
1402 .await
1403 .map(super::tracing::TagBindings::new)
1404 }
1405
1406 /// Lists the TagBindings for the given Google Cloud resource, as specified
1407 /// with `parent`.
1408 ///
1409 /// NOTE: The `parent` field is expected to be a full resource name:
1410 /// <https://cloud.google.com/apis/design/resource_names#full_resource_name>
1411 pub fn list_tag_bindings(&self) -> super::builder::tag_bindings::ListTagBindings {
1412 super::builder::tag_bindings::ListTagBindings::new(self.inner.clone())
1413 }
1414
1415 /// Creates a TagBinding between a TagValue and a Google Cloud resource.
1416 ///
1417 /// # Long running operations
1418 ///
1419 /// This method is used to start, and/or poll a [long-running Operation].
1420 /// The [Working with long-running operations] chapter in the [user guide]
1421 /// covers these operations in detail.
1422 ///
1423 /// [long-running operation]: https://google.aip.dev/151
1424 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1425 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1426 ///
1427 /// # Example
1428 /// ```
1429 /// # use google_cloud_resourcemanager_v3::client::TagBindings;
1430 /// # use lro::Poller;
1431 /// use google_cloud_resourcemanager_v3::Result;
1432 /// async fn sample(
1433 /// client: &TagBindings
1434 /// ) -> Result<()> {
1435 /// let response = client
1436 /// .create_tag_binding()
1437 /// /* set fields */
1438 /// .poller()
1439 /// .until_done()
1440 /// .await?;
1441 /// println!("response {:?}", response);
1442 /// Ok(())
1443 /// }
1444 /// ```
1445 pub fn create_tag_binding(&self) -> super::builder::tag_bindings::CreateTagBinding {
1446 super::builder::tag_bindings::CreateTagBinding::new(self.inner.clone())
1447 }
1448
1449 /// Deletes a TagBinding.
1450 ///
1451 /// # Long running operations
1452 ///
1453 /// This method is used to start, and/or poll a [long-running Operation].
1454 /// The [Working with long-running operations] chapter in the [user guide]
1455 /// covers these operations in detail.
1456 ///
1457 /// [long-running operation]: https://google.aip.dev/151
1458 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1459 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1460 ///
1461 /// # Example
1462 /// ```
1463 /// # use google_cloud_resourcemanager_v3::client::TagBindings;
1464 /// # use lro::Poller;
1465 /// use google_cloud_resourcemanager_v3::Result;
1466 /// async fn sample(
1467 /// client: &TagBindings,
1468 /// resource_name: &str
1469 /// ) -> Result<()> {
1470 /// client
1471 /// .delete_tag_binding()
1472 /// .set_name(resource_name)
1473 /// .poller()
1474 /// .until_done()
1475 /// .await?;
1476 /// Ok(())
1477 /// }
1478 /// ```
1479 pub fn delete_tag_binding(&self) -> super::builder::tag_bindings::DeleteTagBinding {
1480 super::builder::tag_bindings::DeleteTagBinding::new(self.inner.clone())
1481 }
1482
1483 /// Return a list of effective tags for the given Google Cloud resource, as
1484 /// specified in `parent`.
1485 pub fn list_effective_tags(&self) -> super::builder::tag_bindings::ListEffectiveTags {
1486 super::builder::tag_bindings::ListEffectiveTags::new(self.inner.clone())
1487 }
1488
1489 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1490 ///
1491 /// [google.longrunning.Operations]: longrunning::client::Operations
1492 ///
1493 /// # Example
1494 /// ```
1495 /// # use google_cloud_resourcemanager_v3::client::TagBindings;
1496 /// use google_cloud_resourcemanager_v3::Result;
1497 /// async fn sample(
1498 /// client: &TagBindings
1499 /// ) -> Result<()> {
1500 /// let response = client
1501 /// .get_operation()
1502 /// /* set fields */
1503 /// .send()
1504 /// .await?;
1505 /// println!("response {:?}", response);
1506 /// Ok(())
1507 /// }
1508 /// ```
1509 pub fn get_operation(&self) -> super::builder::tag_bindings::GetOperation {
1510 super::builder::tag_bindings::GetOperation::new(self.inner.clone())
1511 }
1512}
1513
1514/// Implements a client for the Cloud Resource Manager API.
1515///
1516/// # Example
1517/// ```
1518/// # async fn sample() -> gax::client_builder::Result<()> {
1519/// # use google_cloud_resourcemanager_v3::client::TagHolds;
1520/// let client = TagHolds::builder().build().await?;
1521/// // use `client` to make requests to the Cloud Resource Manager API.
1522/// # Ok(()) }
1523/// ```
1524///
1525/// # Service Description
1526///
1527/// Allow users to create and manage TagHolds for TagValues. TagHolds represent
1528/// the use of a Tag Value that is not captured by TagBindings but
1529/// should still block TagValue deletion (such as a reference in a policy
1530/// condition). This service provides isolated failure domains by cloud location
1531/// so that TagHolds can be managed in the same location as their usage.
1532///
1533/// # Configuration
1534///
1535/// To configure `TagHolds` use the `with_*` methods in the type returned
1536/// by [builder()][TagHolds::builder]. The default configuration should
1537/// work for most applications. Common configuration changes include
1538///
1539/// * [with_endpoint()]: by default this client uses the global default endpoint
1540/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1541/// endpoints or running in restricted networks (e.g. a network configured
1542// with [Private Google Access with VPC Service Controls]) may want to
1543/// override this default.
1544/// * [with_credentials()]: by default this client uses
1545/// [Application Default Credentials]. Applications using custom
1546/// authentication may need to override this default.
1547///
1548/// [with_endpoint()]: super::builder::tag_holds::ClientBuilder::with_endpoint
1549/// [with_credentials()]: super::builder::tag_holds::ClientBuilder::credentials
1550/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1551/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1552///
1553/// # Pooling and Cloning
1554///
1555/// `TagHolds` holds a connection pool internally, it is advised to
1556/// create one and the reuse it. You do not need to wrap `TagHolds` in
1557/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1558/// already uses an `Arc` internally.
1559#[derive(Clone, Debug)]
1560pub struct TagHolds {
1561 inner: std::sync::Arc<dyn super::stub::dynamic::TagHolds>,
1562}
1563
1564impl TagHolds {
1565 /// Returns a builder for [TagHolds].
1566 ///
1567 /// ```
1568 /// # async fn sample() -> gax::client_builder::Result<()> {
1569 /// # use google_cloud_resourcemanager_v3::client::TagHolds;
1570 /// let client = TagHolds::builder().build().await?;
1571 /// # Ok(()) }
1572 /// ```
1573 pub fn builder() -> super::builder::tag_holds::ClientBuilder {
1574 gax::client_builder::internal::new_builder(super::builder::tag_holds::client::Factory)
1575 }
1576
1577 /// Creates a new client from the provided stub.
1578 ///
1579 /// The most common case for calling this function is in tests mocking the
1580 /// client's behavior.
1581 pub fn from_stub<T>(stub: T) -> Self
1582 where
1583 T: super::stub::TagHolds + 'static,
1584 {
1585 Self {
1586 inner: std::sync::Arc::new(stub),
1587 }
1588 }
1589
1590 pub(crate) async fn new(
1591 config: gaxi::options::ClientConfig,
1592 ) -> gax::client_builder::Result<Self> {
1593 let inner = Self::build_inner(config).await?;
1594 Ok(Self { inner })
1595 }
1596
1597 async fn build_inner(
1598 conf: gaxi::options::ClientConfig,
1599 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagHolds>> {
1600 if gaxi::options::tracing_enabled(&conf) {
1601 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1602 }
1603 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1604 }
1605
1606 async fn build_transport(
1607 conf: gaxi::options::ClientConfig,
1608 ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
1609 super::transport::TagHolds::new(conf).await
1610 }
1611
1612 async fn build_with_tracing(
1613 conf: gaxi::options::ClientConfig,
1614 ) -> gax::client_builder::Result<impl super::stub::TagHolds> {
1615 Self::build_transport(conf)
1616 .await
1617 .map(super::tracing::TagHolds::new)
1618 }
1619
1620 /// Creates a TagHold. Returns ALREADY_EXISTS if a TagHold with the same
1621 /// resource and origin exists under the same TagValue.
1622 ///
1623 /// # Long running operations
1624 ///
1625 /// This method is used to start, and/or poll a [long-running Operation].
1626 /// The [Working with long-running operations] chapter in the [user guide]
1627 /// covers these operations in detail.
1628 ///
1629 /// [long-running operation]: https://google.aip.dev/151
1630 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1631 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1632 ///
1633 /// # Example
1634 /// ```
1635 /// # use google_cloud_resourcemanager_v3::client::TagHolds;
1636 /// # use lro::Poller;
1637 /// use google_cloud_resourcemanager_v3::Result;
1638 /// async fn sample(
1639 /// client: &TagHolds
1640 /// ) -> Result<()> {
1641 /// let response = client
1642 /// .create_tag_hold()
1643 /// /* set fields */
1644 /// .poller()
1645 /// .until_done()
1646 /// .await?;
1647 /// println!("response {:?}", response);
1648 /// Ok(())
1649 /// }
1650 /// ```
1651 pub fn create_tag_hold(&self) -> super::builder::tag_holds::CreateTagHold {
1652 super::builder::tag_holds::CreateTagHold::new(self.inner.clone())
1653 }
1654
1655 /// Deletes a TagHold.
1656 ///
1657 /// # Long running operations
1658 ///
1659 /// This method is used to start, and/or poll a [long-running Operation].
1660 /// The [Working with long-running operations] chapter in the [user guide]
1661 /// covers these operations in detail.
1662 ///
1663 /// [long-running operation]: https://google.aip.dev/151
1664 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1665 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1666 ///
1667 /// # Example
1668 /// ```
1669 /// # use google_cloud_resourcemanager_v3::client::TagHolds;
1670 /// # use lro::Poller;
1671 /// use google_cloud_resourcemanager_v3::Result;
1672 /// async fn sample(
1673 /// client: &TagHolds,
1674 /// resource_name: &str
1675 /// ) -> Result<()> {
1676 /// client
1677 /// .delete_tag_hold()
1678 /// .set_name(resource_name)
1679 /// .poller()
1680 /// .until_done()
1681 /// .await?;
1682 /// Ok(())
1683 /// }
1684 /// ```
1685 pub fn delete_tag_hold(&self) -> super::builder::tag_holds::DeleteTagHold {
1686 super::builder::tag_holds::DeleteTagHold::new(self.inner.clone())
1687 }
1688
1689 /// Lists TagHolds under a TagValue.
1690 pub fn list_tag_holds(&self) -> super::builder::tag_holds::ListTagHolds {
1691 super::builder::tag_holds::ListTagHolds::new(self.inner.clone())
1692 }
1693
1694 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1695 ///
1696 /// [google.longrunning.Operations]: longrunning::client::Operations
1697 ///
1698 /// # Example
1699 /// ```
1700 /// # use google_cloud_resourcemanager_v3::client::TagHolds;
1701 /// use google_cloud_resourcemanager_v3::Result;
1702 /// async fn sample(
1703 /// client: &TagHolds
1704 /// ) -> Result<()> {
1705 /// let response = client
1706 /// .get_operation()
1707 /// /* set fields */
1708 /// .send()
1709 /// .await?;
1710 /// println!("response {:?}", response);
1711 /// Ok(())
1712 /// }
1713 /// ```
1714 pub fn get_operation(&self) -> super::builder::tag_holds::GetOperation {
1715 super::builder::tag_holds::GetOperation::new(self.inner.clone())
1716 }
1717}
1718
1719/// Implements a client for the Cloud Resource Manager API.
1720///
1721/// # Example
1722/// ```
1723/// # async fn sample() -> gax::client_builder::Result<()> {
1724/// # use google_cloud_resourcemanager_v3::client::TagKeys;
1725/// let client = TagKeys::builder().build().await?;
1726/// // use `client` to make requests to the Cloud Resource Manager API.
1727/// # Ok(()) }
1728/// ```
1729///
1730/// # Service Description
1731///
1732/// Allow users to create and manage tag keys.
1733///
1734/// # Configuration
1735///
1736/// To configure `TagKeys` use the `with_*` methods in the type returned
1737/// by [builder()][TagKeys::builder]. The default configuration should
1738/// work for most applications. Common configuration changes include
1739///
1740/// * [with_endpoint()]: by default this client uses the global default endpoint
1741/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
1742/// endpoints or running in restricted networks (e.g. a network configured
1743// with [Private Google Access with VPC Service Controls]) may want to
1744/// override this default.
1745/// * [with_credentials()]: by default this client uses
1746/// [Application Default Credentials]. Applications using custom
1747/// authentication may need to override this default.
1748///
1749/// [with_endpoint()]: super::builder::tag_keys::ClientBuilder::with_endpoint
1750/// [with_credentials()]: super::builder::tag_keys::ClientBuilder::credentials
1751/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1752/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1753///
1754/// # Pooling and Cloning
1755///
1756/// `TagKeys` holds a connection pool internally, it is advised to
1757/// create one and the reuse it. You do not need to wrap `TagKeys` in
1758/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1759/// already uses an `Arc` internally.
1760#[derive(Clone, Debug)]
1761pub struct TagKeys {
1762 inner: std::sync::Arc<dyn super::stub::dynamic::TagKeys>,
1763}
1764
1765impl TagKeys {
1766 /// Returns a builder for [TagKeys].
1767 ///
1768 /// ```
1769 /// # async fn sample() -> gax::client_builder::Result<()> {
1770 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1771 /// let client = TagKeys::builder().build().await?;
1772 /// # Ok(()) }
1773 /// ```
1774 pub fn builder() -> super::builder::tag_keys::ClientBuilder {
1775 gax::client_builder::internal::new_builder(super::builder::tag_keys::client::Factory)
1776 }
1777
1778 /// Creates a new client from the provided stub.
1779 ///
1780 /// The most common case for calling this function is in tests mocking the
1781 /// client's behavior.
1782 pub fn from_stub<T>(stub: T) -> Self
1783 where
1784 T: super::stub::TagKeys + 'static,
1785 {
1786 Self {
1787 inner: std::sync::Arc::new(stub),
1788 }
1789 }
1790
1791 pub(crate) async fn new(
1792 config: gaxi::options::ClientConfig,
1793 ) -> gax::client_builder::Result<Self> {
1794 let inner = Self::build_inner(config).await?;
1795 Ok(Self { inner })
1796 }
1797
1798 async fn build_inner(
1799 conf: gaxi::options::ClientConfig,
1800 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagKeys>> {
1801 if gaxi::options::tracing_enabled(&conf) {
1802 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1803 }
1804 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1805 }
1806
1807 async fn build_transport(
1808 conf: gaxi::options::ClientConfig,
1809 ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
1810 super::transport::TagKeys::new(conf).await
1811 }
1812
1813 async fn build_with_tracing(
1814 conf: gaxi::options::ClientConfig,
1815 ) -> gax::client_builder::Result<impl super::stub::TagKeys> {
1816 Self::build_transport(conf)
1817 .await
1818 .map(super::tracing::TagKeys::new)
1819 }
1820
1821 /// Lists all TagKeys for a parent resource.
1822 pub fn list_tag_keys(&self) -> super::builder::tag_keys::ListTagKeys {
1823 super::builder::tag_keys::ListTagKeys::new(self.inner.clone())
1824 }
1825
1826 /// Retrieves a TagKey. This method will return `PERMISSION_DENIED` if the
1827 /// key does not exist or the user does not have permission to view it.
1828 ///
1829 /// # Example
1830 /// ```
1831 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1832 /// use google_cloud_resourcemanager_v3::Result;
1833 /// async fn sample(
1834 /// client: &TagKeys,
1835 /// resource_name: &str
1836 /// ) -> Result<()> {
1837 /// let response = client
1838 /// .get_tag_key()
1839 /// .set_name(resource_name)
1840 /// .send()
1841 /// .await?;
1842 /// println!("response {:?}", response);
1843 /// Ok(())
1844 /// }
1845 /// ```
1846 pub fn get_tag_key(&self) -> super::builder::tag_keys::GetTagKey {
1847 super::builder::tag_keys::GetTagKey::new(self.inner.clone())
1848 }
1849
1850 /// Retrieves a TagKey by its namespaced name.
1851 /// This method will return `PERMISSION_DENIED` if the key does not exist
1852 /// or the user does not have permission to view it.
1853 ///
1854 /// # Example
1855 /// ```
1856 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1857 /// use google_cloud_resourcemanager_v3::Result;
1858 /// async fn sample(
1859 /// client: &TagKeys,
1860 /// resource_name: &str
1861 /// ) -> Result<()> {
1862 /// let response = client
1863 /// .get_namespaced_tag_key()
1864 /// .set_name(resource_name)
1865 /// .send()
1866 /// .await?;
1867 /// println!("response {:?}", response);
1868 /// Ok(())
1869 /// }
1870 /// ```
1871 pub fn get_namespaced_tag_key(&self) -> super::builder::tag_keys::GetNamespacedTagKey {
1872 super::builder::tag_keys::GetNamespacedTagKey::new(self.inner.clone())
1873 }
1874
1875 /// Creates a new TagKey. If another request with the same parameters is
1876 /// sent while the original request is in process, the second request
1877 /// will receive an error. A maximum of 1000 TagKeys can exist under a parent
1878 /// at any given time.
1879 ///
1880 /// # Long running operations
1881 ///
1882 /// This method is used to start, and/or poll a [long-running Operation].
1883 /// The [Working with long-running operations] chapter in the [user guide]
1884 /// covers these operations in detail.
1885 ///
1886 /// [long-running operation]: https://google.aip.dev/151
1887 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1888 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1889 ///
1890 /// # Example
1891 /// ```
1892 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1893 /// # use lro::Poller;
1894 /// use google_cloud_resourcemanager_v3::Result;
1895 /// async fn sample(
1896 /// client: &TagKeys
1897 /// ) -> Result<()> {
1898 /// let response = client
1899 /// .create_tag_key()
1900 /// /* set fields */
1901 /// .poller()
1902 /// .until_done()
1903 /// .await?;
1904 /// println!("response {:?}", response);
1905 /// Ok(())
1906 /// }
1907 /// ```
1908 pub fn create_tag_key(&self) -> super::builder::tag_keys::CreateTagKey {
1909 super::builder::tag_keys::CreateTagKey::new(self.inner.clone())
1910 }
1911
1912 /// Updates the attributes of the TagKey resource.
1913 ///
1914 /// # Long running operations
1915 ///
1916 /// This method is used to start, and/or poll a [long-running Operation].
1917 /// The [Working with long-running operations] chapter in the [user guide]
1918 /// covers these operations in detail.
1919 ///
1920 /// [long-running operation]: https://google.aip.dev/151
1921 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1922 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1923 ///
1924 /// # Example
1925 /// ```
1926 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1927 /// # use lro::Poller;
1928 /// use google_cloud_resourcemanager_v3::Result;
1929 /// async fn sample(
1930 /// client: &TagKeys
1931 /// ) -> Result<()> {
1932 /// let response = client
1933 /// .update_tag_key()
1934 /// /* set fields */
1935 /// .poller()
1936 /// .until_done()
1937 /// .await?;
1938 /// println!("response {:?}", response);
1939 /// Ok(())
1940 /// }
1941 /// ```
1942 pub fn update_tag_key(&self) -> super::builder::tag_keys::UpdateTagKey {
1943 super::builder::tag_keys::UpdateTagKey::new(self.inner.clone())
1944 }
1945
1946 /// Deletes a TagKey. The TagKey cannot be deleted if it has any child
1947 /// TagValues.
1948 ///
1949 /// # Long running operations
1950 ///
1951 /// This method is used to start, and/or poll a [long-running Operation].
1952 /// The [Working with long-running operations] chapter in the [user guide]
1953 /// covers these operations in detail.
1954 ///
1955 /// [long-running operation]: https://google.aip.dev/151
1956 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1957 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1958 ///
1959 /// # Example
1960 /// ```
1961 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1962 /// # use lro::Poller;
1963 /// use google_cloud_resourcemanager_v3::Result;
1964 /// async fn sample(
1965 /// client: &TagKeys,
1966 /// resource_name: &str
1967 /// ) -> Result<()> {
1968 /// let response = client
1969 /// .delete_tag_key()
1970 /// .set_name(resource_name)
1971 /// .poller()
1972 /// .until_done()
1973 /// .await?;
1974 /// println!("response {:?}", response);
1975 /// Ok(())
1976 /// }
1977 /// ```
1978 pub fn delete_tag_key(&self) -> super::builder::tag_keys::DeleteTagKey {
1979 super::builder::tag_keys::DeleteTagKey::new(self.inner.clone())
1980 }
1981
1982 /// Gets the access control policy for a TagKey. The returned policy may be
1983 /// empty if no such policy or resource exists. The `resource` field should
1984 /// be the TagKey's resource name. For example, "tagKeys/1234".
1985 /// The caller must have
1986 /// `cloudresourcemanager.googleapis.com/tagKeys.getIamPolicy` permission on
1987 /// the specified TagKey.
1988 ///
1989 /// # Example
1990 /// ```
1991 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
1992 /// use google_cloud_resourcemanager_v3::Result;
1993 /// async fn sample(
1994 /// client: &TagKeys
1995 /// ) -> Result<()> {
1996 /// let response = client
1997 /// .get_iam_policy()
1998 /// /* set fields */
1999 /// .send()
2000 /// .await?;
2001 /// println!("response {:?}", response);
2002 /// Ok(())
2003 /// }
2004 /// ```
2005 pub fn get_iam_policy(&self) -> super::builder::tag_keys::GetIamPolicy {
2006 super::builder::tag_keys::GetIamPolicy::new(self.inner.clone())
2007 }
2008
2009 /// Sets the access control policy on a TagKey, replacing any existing
2010 /// policy. The `resource` field should be the TagKey's resource name.
2011 /// For example, "tagKeys/1234".
2012 /// The caller must have `resourcemanager.tagKeys.setIamPolicy` permission
2013 /// on the identified tagValue.
2014 ///
2015 /// # Example
2016 /// ```
2017 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
2018 /// use google_cloud_resourcemanager_v3::Result;
2019 /// async fn sample(
2020 /// client: &TagKeys
2021 /// ) -> Result<()> {
2022 /// let response = client
2023 /// .set_iam_policy()
2024 /// /* set fields */
2025 /// .send()
2026 /// .await?;
2027 /// println!("response {:?}", response);
2028 /// Ok(())
2029 /// }
2030 /// ```
2031 pub fn set_iam_policy(&self) -> super::builder::tag_keys::SetIamPolicy {
2032 super::builder::tag_keys::SetIamPolicy::new(self.inner.clone())
2033 }
2034
2035 /// Returns permissions that a caller has on the specified TagKey.
2036 /// The `resource` field should be the TagKey's resource name.
2037 /// For example, "tagKeys/1234".
2038 ///
2039 /// There are no permissions required for making this API call.
2040 ///
2041 /// # Example
2042 /// ```
2043 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
2044 /// use google_cloud_resourcemanager_v3::Result;
2045 /// async fn sample(
2046 /// client: &TagKeys
2047 /// ) -> Result<()> {
2048 /// let response = client
2049 /// .test_iam_permissions()
2050 /// /* set fields */
2051 /// .send()
2052 /// .await?;
2053 /// println!("response {:?}", response);
2054 /// Ok(())
2055 /// }
2056 /// ```
2057 pub fn test_iam_permissions(&self) -> super::builder::tag_keys::TestIamPermissions {
2058 super::builder::tag_keys::TestIamPermissions::new(self.inner.clone())
2059 }
2060
2061 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2062 ///
2063 /// [google.longrunning.Operations]: longrunning::client::Operations
2064 ///
2065 /// # Example
2066 /// ```
2067 /// # use google_cloud_resourcemanager_v3::client::TagKeys;
2068 /// use google_cloud_resourcemanager_v3::Result;
2069 /// async fn sample(
2070 /// client: &TagKeys
2071 /// ) -> Result<()> {
2072 /// let response = client
2073 /// .get_operation()
2074 /// /* set fields */
2075 /// .send()
2076 /// .await?;
2077 /// println!("response {:?}", response);
2078 /// Ok(())
2079 /// }
2080 /// ```
2081 pub fn get_operation(&self) -> super::builder::tag_keys::GetOperation {
2082 super::builder::tag_keys::GetOperation::new(self.inner.clone())
2083 }
2084}
2085
2086/// Implements a client for the Cloud Resource Manager API.
2087///
2088/// # Example
2089/// ```
2090/// # async fn sample() -> gax::client_builder::Result<()> {
2091/// # use google_cloud_resourcemanager_v3::client::TagValues;
2092/// let client = TagValues::builder().build().await?;
2093/// // use `client` to make requests to the Cloud Resource Manager API.
2094/// # Ok(()) }
2095/// ```
2096///
2097/// # Service Description
2098///
2099/// Allow users to create and manage tag values.
2100///
2101/// # Configuration
2102///
2103/// To configure `TagValues` use the `with_*` methods in the type returned
2104/// by [builder()][TagValues::builder]. The default configuration should
2105/// work for most applications. Common configuration changes include
2106///
2107/// * [with_endpoint()]: by default this client uses the global default endpoint
2108/// (`https://cloudresourcemanager.googleapis.com`). Applications using regional
2109/// endpoints or running in restricted networks (e.g. a network configured
2110// with [Private Google Access with VPC Service Controls]) may want to
2111/// override this default.
2112/// * [with_credentials()]: by default this client uses
2113/// [Application Default Credentials]. Applications using custom
2114/// authentication may need to override this default.
2115///
2116/// [with_endpoint()]: super::builder::tag_values::ClientBuilder::with_endpoint
2117/// [with_credentials()]: super::builder::tag_values::ClientBuilder::credentials
2118/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
2119/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
2120///
2121/// # Pooling and Cloning
2122///
2123/// `TagValues` holds a connection pool internally, it is advised to
2124/// create one and the reuse it. You do not need to wrap `TagValues` in
2125/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
2126/// already uses an `Arc` internally.
2127#[derive(Clone, Debug)]
2128pub struct TagValues {
2129 inner: std::sync::Arc<dyn super::stub::dynamic::TagValues>,
2130}
2131
2132impl TagValues {
2133 /// Returns a builder for [TagValues].
2134 ///
2135 /// ```
2136 /// # async fn sample() -> gax::client_builder::Result<()> {
2137 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2138 /// let client = TagValues::builder().build().await?;
2139 /// # Ok(()) }
2140 /// ```
2141 pub fn builder() -> super::builder::tag_values::ClientBuilder {
2142 gax::client_builder::internal::new_builder(super::builder::tag_values::client::Factory)
2143 }
2144
2145 /// Creates a new client from the provided stub.
2146 ///
2147 /// The most common case for calling this function is in tests mocking the
2148 /// client's behavior.
2149 pub fn from_stub<T>(stub: T) -> Self
2150 where
2151 T: super::stub::TagValues + 'static,
2152 {
2153 Self {
2154 inner: std::sync::Arc::new(stub),
2155 }
2156 }
2157
2158 pub(crate) async fn new(
2159 config: gaxi::options::ClientConfig,
2160 ) -> gax::client_builder::Result<Self> {
2161 let inner = Self::build_inner(config).await?;
2162 Ok(Self { inner })
2163 }
2164
2165 async fn build_inner(
2166 conf: gaxi::options::ClientConfig,
2167 ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::TagValues>> {
2168 if gaxi::options::tracing_enabled(&conf) {
2169 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
2170 }
2171 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
2172 }
2173
2174 async fn build_transport(
2175 conf: gaxi::options::ClientConfig,
2176 ) -> gax::client_builder::Result<impl super::stub::TagValues> {
2177 super::transport::TagValues::new(conf).await
2178 }
2179
2180 async fn build_with_tracing(
2181 conf: gaxi::options::ClientConfig,
2182 ) -> gax::client_builder::Result<impl super::stub::TagValues> {
2183 Self::build_transport(conf)
2184 .await
2185 .map(super::tracing::TagValues::new)
2186 }
2187
2188 /// Lists all TagValues for a specific TagKey.
2189 pub fn list_tag_values(&self) -> super::builder::tag_values::ListTagValues {
2190 super::builder::tag_values::ListTagValues::new(self.inner.clone())
2191 }
2192
2193 /// Retrieves a TagValue. This method will return `PERMISSION_DENIED` if the
2194 /// value does not exist or the user does not have permission to view it.
2195 ///
2196 /// # Example
2197 /// ```
2198 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2199 /// use google_cloud_resourcemanager_v3::Result;
2200 /// async fn sample(
2201 /// client: &TagValues,
2202 /// resource_name: &str
2203 /// ) -> Result<()> {
2204 /// let response = client
2205 /// .get_tag_value()
2206 /// .set_name(resource_name)
2207 /// .send()
2208 /// .await?;
2209 /// println!("response {:?}", response);
2210 /// Ok(())
2211 /// }
2212 /// ```
2213 pub fn get_tag_value(&self) -> super::builder::tag_values::GetTagValue {
2214 super::builder::tag_values::GetTagValue::new(self.inner.clone())
2215 }
2216
2217 /// Retrieves a TagValue by its namespaced name.
2218 /// This method will return `PERMISSION_DENIED` if the value does not exist
2219 /// or the user does not have permission to view it.
2220 ///
2221 /// # Example
2222 /// ```
2223 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2224 /// use google_cloud_resourcemanager_v3::Result;
2225 /// async fn sample(
2226 /// client: &TagValues,
2227 /// resource_name: &str
2228 /// ) -> Result<()> {
2229 /// let response = client
2230 /// .get_namespaced_tag_value()
2231 /// .set_name(resource_name)
2232 /// .send()
2233 /// .await?;
2234 /// println!("response {:?}", response);
2235 /// Ok(())
2236 /// }
2237 /// ```
2238 pub fn get_namespaced_tag_value(&self) -> super::builder::tag_values::GetNamespacedTagValue {
2239 super::builder::tag_values::GetNamespacedTagValue::new(self.inner.clone())
2240 }
2241
2242 /// Creates a TagValue as a child of the specified TagKey. If a another
2243 /// request with the same parameters is sent while the original request is in
2244 /// process the second request will receive an error. A maximum of 1000
2245 /// TagValues can exist under a TagKey at any given time.
2246 ///
2247 /// # Long running operations
2248 ///
2249 /// This method is used to start, and/or poll a [long-running Operation].
2250 /// The [Working with long-running operations] chapter in the [user guide]
2251 /// covers these operations in detail.
2252 ///
2253 /// [long-running operation]: https://google.aip.dev/151
2254 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2255 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2256 ///
2257 /// # Example
2258 /// ```
2259 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2260 /// # use lro::Poller;
2261 /// use google_cloud_resourcemanager_v3::Result;
2262 /// async fn sample(
2263 /// client: &TagValues
2264 /// ) -> Result<()> {
2265 /// let response = client
2266 /// .create_tag_value()
2267 /// /* set fields */
2268 /// .poller()
2269 /// .until_done()
2270 /// .await?;
2271 /// println!("response {:?}", response);
2272 /// Ok(())
2273 /// }
2274 /// ```
2275 pub fn create_tag_value(&self) -> super::builder::tag_values::CreateTagValue {
2276 super::builder::tag_values::CreateTagValue::new(self.inner.clone())
2277 }
2278
2279 /// Updates the attributes of the TagValue resource.
2280 ///
2281 /// # Long running operations
2282 ///
2283 /// This method is used to start, and/or poll a [long-running Operation].
2284 /// The [Working with long-running operations] chapter in the [user guide]
2285 /// covers these operations in detail.
2286 ///
2287 /// [long-running operation]: https://google.aip.dev/151
2288 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2289 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2290 ///
2291 /// # Example
2292 /// ```
2293 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2294 /// # use lro::Poller;
2295 /// use google_cloud_resourcemanager_v3::Result;
2296 /// async fn sample(
2297 /// client: &TagValues
2298 /// ) -> Result<()> {
2299 /// let response = client
2300 /// .update_tag_value()
2301 /// /* set fields */
2302 /// .poller()
2303 /// .until_done()
2304 /// .await?;
2305 /// println!("response {:?}", response);
2306 /// Ok(())
2307 /// }
2308 /// ```
2309 pub fn update_tag_value(&self) -> super::builder::tag_values::UpdateTagValue {
2310 super::builder::tag_values::UpdateTagValue::new(self.inner.clone())
2311 }
2312
2313 /// Deletes a TagValue. The TagValue cannot have any bindings when it is
2314 /// deleted.
2315 ///
2316 /// # Long running operations
2317 ///
2318 /// This method is used to start, and/or poll a [long-running Operation].
2319 /// The [Working with long-running operations] chapter in the [user guide]
2320 /// covers these operations in detail.
2321 ///
2322 /// [long-running operation]: https://google.aip.dev/151
2323 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2324 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2325 ///
2326 /// # Example
2327 /// ```
2328 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2329 /// # use lro::Poller;
2330 /// use google_cloud_resourcemanager_v3::Result;
2331 /// async fn sample(
2332 /// client: &TagValues,
2333 /// resource_name: &str
2334 /// ) -> Result<()> {
2335 /// let response = client
2336 /// .delete_tag_value()
2337 /// .set_name(resource_name)
2338 /// .poller()
2339 /// .until_done()
2340 /// .await?;
2341 /// println!("response {:?}", response);
2342 /// Ok(())
2343 /// }
2344 /// ```
2345 pub fn delete_tag_value(&self) -> super::builder::tag_values::DeleteTagValue {
2346 super::builder::tag_values::DeleteTagValue::new(self.inner.clone())
2347 }
2348
2349 /// Gets the access control policy for a TagValue. The returned policy may be
2350 /// empty if no such policy or resource exists. The `resource` field should
2351 /// be the TagValue's resource name. For example: `tagValues/1234`.
2352 /// The caller must have the
2353 /// `cloudresourcemanager.googleapis.com/tagValues.getIamPolicy` permission on
2354 /// the identified TagValue to get the access control policy.
2355 ///
2356 /// # Example
2357 /// ```
2358 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2359 /// use google_cloud_resourcemanager_v3::Result;
2360 /// async fn sample(
2361 /// client: &TagValues
2362 /// ) -> Result<()> {
2363 /// let response = client
2364 /// .get_iam_policy()
2365 /// /* set fields */
2366 /// .send()
2367 /// .await?;
2368 /// println!("response {:?}", response);
2369 /// Ok(())
2370 /// }
2371 /// ```
2372 pub fn get_iam_policy(&self) -> super::builder::tag_values::GetIamPolicy {
2373 super::builder::tag_values::GetIamPolicy::new(self.inner.clone())
2374 }
2375
2376 /// Sets the access control policy on a TagValue, replacing any existing
2377 /// policy. The `resource` field should be the TagValue's resource name.
2378 /// For example: `tagValues/1234`.
2379 /// The caller must have `resourcemanager.tagValues.setIamPolicy` permission
2380 /// on the identified tagValue.
2381 ///
2382 /// # Example
2383 /// ```
2384 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2385 /// use google_cloud_resourcemanager_v3::Result;
2386 /// async fn sample(
2387 /// client: &TagValues
2388 /// ) -> Result<()> {
2389 /// let response = client
2390 /// .set_iam_policy()
2391 /// /* set fields */
2392 /// .send()
2393 /// .await?;
2394 /// println!("response {:?}", response);
2395 /// Ok(())
2396 /// }
2397 /// ```
2398 pub fn set_iam_policy(&self) -> super::builder::tag_values::SetIamPolicy {
2399 super::builder::tag_values::SetIamPolicy::new(self.inner.clone())
2400 }
2401
2402 /// Returns permissions that a caller has on the specified TagValue.
2403 /// The `resource` field should be the TagValue's resource name. For example:
2404 /// `tagValues/1234`.
2405 ///
2406 /// There are no permissions required for making this API call.
2407 ///
2408 /// # Example
2409 /// ```
2410 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2411 /// use google_cloud_resourcemanager_v3::Result;
2412 /// async fn sample(
2413 /// client: &TagValues
2414 /// ) -> Result<()> {
2415 /// let response = client
2416 /// .test_iam_permissions()
2417 /// /* set fields */
2418 /// .send()
2419 /// .await?;
2420 /// println!("response {:?}", response);
2421 /// Ok(())
2422 /// }
2423 /// ```
2424 pub fn test_iam_permissions(&self) -> super::builder::tag_values::TestIamPermissions {
2425 super::builder::tag_values::TestIamPermissions::new(self.inner.clone())
2426 }
2427
2428 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
2429 ///
2430 /// [google.longrunning.Operations]: longrunning::client::Operations
2431 ///
2432 /// # Example
2433 /// ```
2434 /// # use google_cloud_resourcemanager_v3::client::TagValues;
2435 /// use google_cloud_resourcemanager_v3::Result;
2436 /// async fn sample(
2437 /// client: &TagValues
2438 /// ) -> Result<()> {
2439 /// let response = client
2440 /// .get_operation()
2441 /// /* set fields */
2442 /// .send()
2443 /// .await?;
2444 /// println!("response {:?}", response);
2445 /// Ok(())
2446 /// }
2447 /// ```
2448 pub fn get_operation(&self) -> super::builder::tag_values::GetOperation {
2449 super::builder::tag_values::GetOperation::new(self.inner.clone())
2450 }
2451}