google_cloud_kms_v1/client.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Cloud Key Management Service (KMS) API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_kms_v1::client::Autokey;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// parent: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = Autokey::builder().build().await?;
31/// let mut list = client.list_key_handles()
32/// .set_parent(parent)
33/// .by_item();
34/// while let Some(item) = list.next().await.transpose()? {
35/// println!("{:?}", item);
36/// }
37/// Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// Provides interfaces for using [Cloud KMS
44/// Autokey](https://cloud.google.com/kms/help/autokey) to provision new
45/// [CryptoKeys][google.cloud.kms.v1.CryptoKey], ready for Customer Managed
46/// Encryption Key (CMEK) use, on-demand. To support certain client tooling, this
47/// feature is modeled around a [KeyHandle][google.cloud.kms.v1.KeyHandle]
48/// resource: creating a [KeyHandle][google.cloud.kms.v1.KeyHandle] in a resource
49/// project and given location triggers Cloud KMS Autokey to provision a
50/// [CryptoKey][google.cloud.kms.v1.CryptoKey] in the configured key project and
51/// the same location.
52///
53/// Prior to use in a given resource project,
54/// [UpdateAutokeyConfig][google.cloud.kms.v1.AutokeyAdmin.UpdateAutokeyConfig]
55/// should have been called on an ancestor folder, setting the key project where
56/// Cloud KMS Autokey should create new
57/// [CryptoKeys][google.cloud.kms.v1.CryptoKey]. See documentation for additional
58/// prerequisites. To check what key project, if any, is currently configured on
59/// a resource project's ancestor folder, see
60/// [ShowEffectiveAutokeyConfig][google.cloud.kms.v1.AutokeyAdmin.ShowEffectiveAutokeyConfig].
61///
62/// [google.cloud.kms.v1.AutokeyAdmin.ShowEffectiveAutokeyConfig]: crate::client::AutokeyAdmin::show_effective_autokey_config
63/// [google.cloud.kms.v1.AutokeyAdmin.UpdateAutokeyConfig]: crate::client::AutokeyAdmin::update_autokey_config
64/// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
65/// [google.cloud.kms.v1.KeyHandle]: crate::model::KeyHandle
66///
67/// # Configuration
68///
69/// To configure `Autokey` use the `with_*` methods in the type returned
70/// by [builder()][Autokey::builder]. The default configuration should
71/// work for most applications. Common configuration changes include
72///
73/// * [with_endpoint()]: by default this client uses the global default endpoint
74/// (`https://cloudkms.googleapis.com`). Applications using regional
75/// endpoints or running in restricted networks (e.g. a network configured
76/// with [Private Google Access with VPC Service Controls]) may want to
77/// override this default.
78/// * [with_credentials()]: by default this client uses
79/// [Application Default Credentials]. Applications using custom
80/// authentication may need to override this default.
81///
82/// [with_endpoint()]: super::builder::autokey::ClientBuilder::with_endpoint
83/// [with_credentials()]: super::builder::autokey::ClientBuilder::with_credentials
84/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
85/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
86///
87/// # Pooling and Cloning
88///
89/// `Autokey` holds a connection pool internally, it is advised to
90/// create one and reuse it. You do not need to wrap `Autokey` in
91/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
92/// already uses an `Arc` internally.
93#[derive(Clone, Debug)]
94pub struct Autokey {
95 inner: std::sync::Arc<dyn super::stub::dynamic::Autokey>,
96}
97
98impl Autokey {
99 /// Returns a builder for [Autokey].
100 ///
101 /// ```
102 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
103 /// # use google_cloud_kms_v1::client::Autokey;
104 /// let client = Autokey::builder().build().await?;
105 /// # Ok(()) }
106 /// ```
107 pub fn builder() -> super::builder::autokey::ClientBuilder {
108 crate::new_client_builder(super::builder::autokey::client::Factory)
109 }
110
111 /// Creates a new client from the provided stub.
112 ///
113 /// The most common case for calling this function is in tests mocking the
114 /// client's behavior.
115 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
116 where
117 T: super::stub::Autokey + 'static,
118 {
119 Self { inner: stub.into() }
120 }
121
122 pub(crate) async fn new(
123 config: gaxi::options::ClientConfig,
124 ) -> crate::ClientBuilderResult<Self> {
125 let inner = Self::build_inner(config).await?;
126 Ok(Self { inner })
127 }
128
129 async fn build_inner(
130 conf: gaxi::options::ClientConfig,
131 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Autokey>> {
132 if gaxi::options::tracing_enabled(&conf) {
133 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
134 }
135 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
136 }
137
138 async fn build_transport(
139 conf: gaxi::options::ClientConfig,
140 ) -> crate::ClientBuilderResult<impl super::stub::Autokey> {
141 super::transport::Autokey::new(conf).await
142 }
143
144 async fn build_with_tracing(
145 conf: gaxi::options::ClientConfig,
146 ) -> crate::ClientBuilderResult<impl super::stub::Autokey> {
147 Self::build_transport(conf)
148 .await
149 .map(super::tracing::Autokey::new)
150 }
151
152 /// Creates a new [KeyHandle][google.cloud.kms.v1.KeyHandle], triggering the
153 /// provisioning of a new [CryptoKey][google.cloud.kms.v1.CryptoKey] for CMEK
154 /// use with the given resource type in the configured key project and the same
155 /// location. [GetOperation][google.longrunning.Operations.GetOperation] should
156 /// be used to resolve the resulting long-running operation and get the
157 /// resulting [KeyHandle][google.cloud.kms.v1.KeyHandle] and
158 /// [CryptoKey][google.cloud.kms.v1.CryptoKey].
159 ///
160 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
161 /// [google.cloud.kms.v1.KeyHandle]: crate::model::KeyHandle
162 ///
163 /// # Long running operations
164 ///
165 /// This method is used to start, and/or poll a [long-running Operation].
166 /// The [Working with long-running operations] chapter in the [user guide]
167 /// covers these operations in detail.
168 ///
169 /// [long-running operation]: https://google.aip.dev/151
170 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
171 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
172 ///
173 /// # Example
174 /// ```
175 /// # use google_cloud_kms_v1::client::Autokey;
176 /// use google_cloud_lro::Poller;
177 /// use google_cloud_kms_v1::model::KeyHandle;
178 /// use google_cloud_kms_v1::Result;
179 /// async fn sample(
180 /// client: &Autokey, parent: &str
181 /// ) -> Result<()> {
182 /// let response = client.create_key_handle()
183 /// .set_parent(parent)
184 /// .set_key_handle(
185 /// KeyHandle::new()/* set fields */
186 /// )
187 /// .poller().until_done().await?;
188 /// println!("response {:?}", response);
189 /// Ok(())
190 /// }
191 /// ```
192 pub fn create_key_handle(&self) -> super::builder::autokey::CreateKeyHandle {
193 super::builder::autokey::CreateKeyHandle::new(self.inner.clone())
194 }
195
196 /// Returns the [KeyHandle][google.cloud.kms.v1.KeyHandle].
197 ///
198 /// [google.cloud.kms.v1.KeyHandle]: crate::model::KeyHandle
199 ///
200 /// # Example
201 /// ```
202 /// # use google_cloud_kms_v1::client::Autokey;
203 /// use google_cloud_kms_v1::Result;
204 /// async fn sample(
205 /// client: &Autokey, project_id: &str, location_id: &str, key_handle_id: &str
206 /// ) -> Result<()> {
207 /// let response = client.get_key_handle()
208 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyHandles/{key_handle_id}"))
209 /// .send().await?;
210 /// println!("response {:?}", response);
211 /// Ok(())
212 /// }
213 /// ```
214 pub fn get_key_handle(&self) -> super::builder::autokey::GetKeyHandle {
215 super::builder::autokey::GetKeyHandle::new(self.inner.clone())
216 }
217
218 /// Lists [KeyHandles][google.cloud.kms.v1.KeyHandle].
219 ///
220 /// [google.cloud.kms.v1.KeyHandle]: crate::model::KeyHandle
221 ///
222 /// # Example
223 /// ```
224 /// # use google_cloud_kms_v1::client::Autokey;
225 /// use google_cloud_gax::paginator::ItemPaginator as _;
226 /// use google_cloud_kms_v1::Result;
227 /// async fn sample(
228 /// client: &Autokey, parent: &str
229 /// ) -> Result<()> {
230 /// let mut list = client.list_key_handles()
231 /// .set_parent(parent)
232 /// .by_item();
233 /// while let Some(item) = list.next().await.transpose()? {
234 /// println!("{:?}", item);
235 /// }
236 /// Ok(())
237 /// }
238 /// ```
239 pub fn list_key_handles(&self) -> super::builder::autokey::ListKeyHandles {
240 super::builder::autokey::ListKeyHandles::new(self.inner.clone())
241 }
242
243 /// Lists information about the supported locations for this service.
244 ///
245 /// This method lists locations based on the resource scope provided in
246 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
247 /// **Global locations**: If `name` is empty, the method lists the
248 /// public locations available to all projects. * **Project-specific
249 /// locations**: If `name` follows the format
250 /// `projects/{project}`, the method lists locations visible to that
251 /// specific project. This includes public, private, or other
252 /// project-specific locations enabled for the project.
253 ///
254 /// For gRPC and client library implementations, the resource name is
255 /// passed as the `name` field. For direct service calls, the resource
256 /// name is
257 /// incorporated into the request path based on the specific service
258 /// implementation and version.
259 ///
260 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
261 ///
262 /// # Example
263 /// ```
264 /// # use google_cloud_kms_v1::client::Autokey;
265 /// use google_cloud_gax::paginator::ItemPaginator as _;
266 /// use google_cloud_kms_v1::Result;
267 /// async fn sample(
268 /// client: &Autokey
269 /// ) -> Result<()> {
270 /// let mut list = client.list_locations()
271 /// /* set fields */
272 /// .by_item();
273 /// while let Some(item) = list.next().await.transpose()? {
274 /// println!("{:?}", item);
275 /// }
276 /// Ok(())
277 /// }
278 /// ```
279 pub fn list_locations(&self) -> super::builder::autokey::ListLocations {
280 super::builder::autokey::ListLocations::new(self.inner.clone())
281 }
282
283 /// Gets information about a location.
284 ///
285 /// # Example
286 /// ```
287 /// # use google_cloud_kms_v1::client::Autokey;
288 /// use google_cloud_kms_v1::Result;
289 /// async fn sample(
290 /// client: &Autokey
291 /// ) -> Result<()> {
292 /// let response = client.get_location()
293 /// /* set fields */
294 /// .send().await?;
295 /// println!("response {:?}", response);
296 /// Ok(())
297 /// }
298 /// ```
299 pub fn get_location(&self) -> super::builder::autokey::GetLocation {
300 super::builder::autokey::GetLocation::new(self.inner.clone())
301 }
302
303 /// Sets the access control policy on the specified resource. Replaces
304 /// any existing policy.
305 ///
306 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
307 /// errors.
308 ///
309 /// # Example
310 /// ```
311 /// # use google_cloud_kms_v1::client::Autokey;
312 /// use google_cloud_kms_v1::Result;
313 /// async fn sample(
314 /// client: &Autokey
315 /// ) -> Result<()> {
316 /// let response = client.set_iam_policy()
317 /// /* set fields */
318 /// .send().await?;
319 /// println!("response {:?}", response);
320 /// Ok(())
321 /// }
322 /// ```
323 pub fn set_iam_policy(&self) -> super::builder::autokey::SetIamPolicy {
324 super::builder::autokey::SetIamPolicy::new(self.inner.clone())
325 }
326
327 /// Gets the access control policy for a resource. Returns an empty policy
328 /// if the resource exists and does not have a policy set.
329 ///
330 /// # Example
331 /// ```
332 /// # use google_cloud_kms_v1::client::Autokey;
333 /// use google_cloud_kms_v1::Result;
334 /// async fn sample(
335 /// client: &Autokey
336 /// ) -> Result<()> {
337 /// let response = client.get_iam_policy()
338 /// /* set fields */
339 /// .send().await?;
340 /// println!("response {:?}", response);
341 /// Ok(())
342 /// }
343 /// ```
344 pub fn get_iam_policy(&self) -> super::builder::autokey::GetIamPolicy {
345 super::builder::autokey::GetIamPolicy::new(self.inner.clone())
346 }
347
348 /// Returns permissions that a caller has on the specified resource. If the
349 /// resource does not exist, this will return an empty set of
350 /// permissions, not a `NOT_FOUND` error.
351 ///
352 /// Note: This operation is designed to be used for building
353 /// permission-aware UIs and command-line tools, not for authorization
354 /// checking. This operation may "fail open" without warning.
355 ///
356 /// # Example
357 /// ```
358 /// # use google_cloud_kms_v1::client::Autokey;
359 /// use google_cloud_kms_v1::Result;
360 /// async fn sample(
361 /// client: &Autokey
362 /// ) -> Result<()> {
363 /// let response = client.test_iam_permissions()
364 /// /* set fields */
365 /// .send().await?;
366 /// println!("response {:?}", response);
367 /// Ok(())
368 /// }
369 /// ```
370 pub fn test_iam_permissions(&self) -> super::builder::autokey::TestIamPermissions {
371 super::builder::autokey::TestIamPermissions::new(self.inner.clone())
372 }
373
374 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
375 ///
376 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
377 ///
378 /// # Example
379 /// ```
380 /// # use google_cloud_kms_v1::client::Autokey;
381 /// use google_cloud_kms_v1::Result;
382 /// async fn sample(
383 /// client: &Autokey
384 /// ) -> Result<()> {
385 /// let response = client.get_operation()
386 /// /* set fields */
387 /// .send().await?;
388 /// println!("response {:?}", response);
389 /// Ok(())
390 /// }
391 /// ```
392 pub fn get_operation(&self) -> super::builder::autokey::GetOperation {
393 super::builder::autokey::GetOperation::new(self.inner.clone())
394 }
395}
396
397/// Implements a client for the Cloud Key Management Service (KMS) API.
398///
399/// # Example
400/// ```
401/// # use google_cloud_kms_v1::client::AutokeyAdmin;
402/// async fn sample(
403/// folder_id: &str,
404/// ) -> anyhow::Result<()> {
405/// let client = AutokeyAdmin::builder().build().await?;
406/// let response = client.get_autokey_config()
407/// .set_name(format!("folders/{folder_id}/autokeyConfig"))
408/// .send().await?;
409/// println!("response {:?}", response);
410/// Ok(())
411/// }
412/// ```
413///
414/// # Service Description
415///
416/// Provides interfaces for managing [Cloud KMS
417/// Autokey](https://cloud.google.com/kms/help/autokey) folder-level or
418/// project-level configurations. A configuration is inherited by all descendent
419/// folders and projects. A configuration at a folder or project overrides any
420/// other configurations in its ancestry. Setting a configuration on a folder is
421/// a prerequisite for Cloud KMS Autokey, so that users working in a descendant
422/// project can request provisioned [CryptoKeys][google.cloud.kms.v1.CryptoKey],
423/// ready for Customer Managed Encryption Key (CMEK) use, on-demand when using
424/// the dedicated key project mode. This is not required when using the delegated
425/// key management mode for same-project keys.
426///
427/// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
428///
429/// # Configuration
430///
431/// To configure `AutokeyAdmin` use the `with_*` methods in the type returned
432/// by [builder()][AutokeyAdmin::builder]. The default configuration should
433/// work for most applications. Common configuration changes include
434///
435/// * [with_endpoint()]: by default this client uses the global default endpoint
436/// (`https://cloudkms.googleapis.com`). Applications using regional
437/// endpoints or running in restricted networks (e.g. a network configured
438/// with [Private Google Access with VPC Service Controls]) may want to
439/// override this default.
440/// * [with_credentials()]: by default this client uses
441/// [Application Default Credentials]. Applications using custom
442/// authentication may need to override this default.
443///
444/// [with_endpoint()]: super::builder::autokey_admin::ClientBuilder::with_endpoint
445/// [with_credentials()]: super::builder::autokey_admin::ClientBuilder::with_credentials
446/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
447/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
448///
449/// # Pooling and Cloning
450///
451/// `AutokeyAdmin` holds a connection pool internally, it is advised to
452/// create one and reuse it. You do not need to wrap `AutokeyAdmin` in
453/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
454/// already uses an `Arc` internally.
455#[derive(Clone, Debug)]
456pub struct AutokeyAdmin {
457 inner: std::sync::Arc<dyn super::stub::dynamic::AutokeyAdmin>,
458}
459
460impl AutokeyAdmin {
461 /// Returns a builder for [AutokeyAdmin].
462 ///
463 /// ```
464 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
465 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
466 /// let client = AutokeyAdmin::builder().build().await?;
467 /// # Ok(()) }
468 /// ```
469 pub fn builder() -> super::builder::autokey_admin::ClientBuilder {
470 crate::new_client_builder(super::builder::autokey_admin::client::Factory)
471 }
472
473 /// Creates a new client from the provided stub.
474 ///
475 /// The most common case for calling this function is in tests mocking the
476 /// client's behavior.
477 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
478 where
479 T: super::stub::AutokeyAdmin + 'static,
480 {
481 Self { inner: stub.into() }
482 }
483
484 pub(crate) async fn new(
485 config: gaxi::options::ClientConfig,
486 ) -> crate::ClientBuilderResult<Self> {
487 let inner = Self::build_inner(config).await?;
488 Ok(Self { inner })
489 }
490
491 async fn build_inner(
492 conf: gaxi::options::ClientConfig,
493 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::AutokeyAdmin>> {
494 if gaxi::options::tracing_enabled(&conf) {
495 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
496 }
497 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
498 }
499
500 async fn build_transport(
501 conf: gaxi::options::ClientConfig,
502 ) -> crate::ClientBuilderResult<impl super::stub::AutokeyAdmin> {
503 super::transport::AutokeyAdmin::new(conf).await
504 }
505
506 async fn build_with_tracing(
507 conf: gaxi::options::ClientConfig,
508 ) -> crate::ClientBuilderResult<impl super::stub::AutokeyAdmin> {
509 Self::build_transport(conf)
510 .await
511 .map(super::tracing::AutokeyAdmin::new)
512 }
513
514 /// Updates the [AutokeyConfig][google.cloud.kms.v1.AutokeyConfig] for a folder
515 /// or a project. The caller must have both `cloudkms.autokeyConfigs.update`
516 /// permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy`
517 /// permission on the provided key project. A
518 /// [KeyHandle][google.cloud.kms.v1.KeyHandle] creation in the folder's
519 /// descendant projects will use this configuration to determine where to
520 /// create the resulting [CryptoKey][google.cloud.kms.v1.CryptoKey].
521 ///
522 /// [google.cloud.kms.v1.AutokeyConfig]: crate::model::AutokeyConfig
523 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
524 /// [google.cloud.kms.v1.KeyHandle]: crate::model::KeyHandle
525 ///
526 /// # Example
527 /// ```
528 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
529 /// # extern crate wkt as google_cloud_wkt;
530 /// use google_cloud_wkt::FieldMask;
531 /// use google_cloud_kms_v1::model::AutokeyConfig;
532 /// use google_cloud_kms_v1::Result;
533 /// async fn sample(
534 /// client: &AutokeyAdmin, folder_id: &str
535 /// ) -> Result<()> {
536 /// let response = client.update_autokey_config()
537 /// .set_autokey_config(
538 /// AutokeyConfig::new().set_name(format!("folders/{folder_id}/autokeyConfig"))/* set fields */
539 /// )
540 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
541 /// .send().await?;
542 /// println!("response {:?}", response);
543 /// Ok(())
544 /// }
545 /// ```
546 pub fn update_autokey_config(&self) -> super::builder::autokey_admin::UpdateAutokeyConfig {
547 super::builder::autokey_admin::UpdateAutokeyConfig::new(self.inner.clone())
548 }
549
550 /// Returns the [AutokeyConfig][google.cloud.kms.v1.AutokeyConfig] for a folder
551 /// or project.
552 ///
553 /// [google.cloud.kms.v1.AutokeyConfig]: crate::model::AutokeyConfig
554 ///
555 /// # Example
556 /// ```
557 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
558 /// use google_cloud_kms_v1::Result;
559 /// async fn sample(
560 /// client: &AutokeyAdmin, folder_id: &str
561 /// ) -> Result<()> {
562 /// let response = client.get_autokey_config()
563 /// .set_name(format!("folders/{folder_id}/autokeyConfig"))
564 /// .send().await?;
565 /// println!("response {:?}", response);
566 /// Ok(())
567 /// }
568 /// ```
569 pub fn get_autokey_config(&self) -> super::builder::autokey_admin::GetAutokeyConfig {
570 super::builder::autokey_admin::GetAutokeyConfig::new(self.inner.clone())
571 }
572
573 /// Returns the effective Cloud KMS Autokey configuration for a given project.
574 ///
575 /// # Example
576 /// ```
577 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
578 /// use google_cloud_kms_v1::Result;
579 /// async fn sample(
580 /// client: &AutokeyAdmin
581 /// ) -> Result<()> {
582 /// let response = client.show_effective_autokey_config()
583 /// /* set fields */
584 /// .send().await?;
585 /// println!("response {:?}", response);
586 /// Ok(())
587 /// }
588 /// ```
589 pub fn show_effective_autokey_config(
590 &self,
591 ) -> super::builder::autokey_admin::ShowEffectiveAutokeyConfig {
592 super::builder::autokey_admin::ShowEffectiveAutokeyConfig::new(self.inner.clone())
593 }
594
595 /// Lists information about the supported locations for this service.
596 ///
597 /// This method lists locations based on the resource scope provided in
598 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
599 /// **Global locations**: If `name` is empty, the method lists the
600 /// public locations available to all projects. * **Project-specific
601 /// locations**: If `name` follows the format
602 /// `projects/{project}`, the method lists locations visible to that
603 /// specific project. This includes public, private, or other
604 /// project-specific locations enabled for the project.
605 ///
606 /// For gRPC and client library implementations, the resource name is
607 /// passed as the `name` field. For direct service calls, the resource
608 /// name is
609 /// incorporated into the request path based on the specific service
610 /// implementation and version.
611 ///
612 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
613 ///
614 /// # Example
615 /// ```
616 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
617 /// use google_cloud_gax::paginator::ItemPaginator as _;
618 /// use google_cloud_kms_v1::Result;
619 /// async fn sample(
620 /// client: &AutokeyAdmin
621 /// ) -> Result<()> {
622 /// let mut list = client.list_locations()
623 /// /* set fields */
624 /// .by_item();
625 /// while let Some(item) = list.next().await.transpose()? {
626 /// println!("{:?}", item);
627 /// }
628 /// Ok(())
629 /// }
630 /// ```
631 pub fn list_locations(&self) -> super::builder::autokey_admin::ListLocations {
632 super::builder::autokey_admin::ListLocations::new(self.inner.clone())
633 }
634
635 /// Gets information about a location.
636 ///
637 /// # Example
638 /// ```
639 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
640 /// use google_cloud_kms_v1::Result;
641 /// async fn sample(
642 /// client: &AutokeyAdmin
643 /// ) -> Result<()> {
644 /// let response = client.get_location()
645 /// /* set fields */
646 /// .send().await?;
647 /// println!("response {:?}", response);
648 /// Ok(())
649 /// }
650 /// ```
651 pub fn get_location(&self) -> super::builder::autokey_admin::GetLocation {
652 super::builder::autokey_admin::GetLocation::new(self.inner.clone())
653 }
654
655 /// Sets the access control policy on the specified resource. Replaces
656 /// any existing policy.
657 ///
658 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
659 /// errors.
660 ///
661 /// # Example
662 /// ```
663 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
664 /// use google_cloud_kms_v1::Result;
665 /// async fn sample(
666 /// client: &AutokeyAdmin
667 /// ) -> Result<()> {
668 /// let response = client.set_iam_policy()
669 /// /* set fields */
670 /// .send().await?;
671 /// println!("response {:?}", response);
672 /// Ok(())
673 /// }
674 /// ```
675 pub fn set_iam_policy(&self) -> super::builder::autokey_admin::SetIamPolicy {
676 super::builder::autokey_admin::SetIamPolicy::new(self.inner.clone())
677 }
678
679 /// Gets the access control policy for a resource. Returns an empty policy
680 /// if the resource exists and does not have a policy set.
681 ///
682 /// # Example
683 /// ```
684 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
685 /// use google_cloud_kms_v1::Result;
686 /// async fn sample(
687 /// client: &AutokeyAdmin
688 /// ) -> Result<()> {
689 /// let response = client.get_iam_policy()
690 /// /* set fields */
691 /// .send().await?;
692 /// println!("response {:?}", response);
693 /// Ok(())
694 /// }
695 /// ```
696 pub fn get_iam_policy(&self) -> super::builder::autokey_admin::GetIamPolicy {
697 super::builder::autokey_admin::GetIamPolicy::new(self.inner.clone())
698 }
699
700 /// Returns permissions that a caller has on the specified resource. If the
701 /// resource does not exist, this will return an empty set of
702 /// permissions, not a `NOT_FOUND` error.
703 ///
704 /// Note: This operation is designed to be used for building
705 /// permission-aware UIs and command-line tools, not for authorization
706 /// checking. This operation may "fail open" without warning.
707 ///
708 /// # Example
709 /// ```
710 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
711 /// use google_cloud_kms_v1::Result;
712 /// async fn sample(
713 /// client: &AutokeyAdmin
714 /// ) -> Result<()> {
715 /// let response = client.test_iam_permissions()
716 /// /* set fields */
717 /// .send().await?;
718 /// println!("response {:?}", response);
719 /// Ok(())
720 /// }
721 /// ```
722 pub fn test_iam_permissions(&self) -> super::builder::autokey_admin::TestIamPermissions {
723 super::builder::autokey_admin::TestIamPermissions::new(self.inner.clone())
724 }
725
726 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
727 ///
728 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
729 ///
730 /// # Example
731 /// ```
732 /// # use google_cloud_kms_v1::client::AutokeyAdmin;
733 /// use google_cloud_kms_v1::Result;
734 /// async fn sample(
735 /// client: &AutokeyAdmin
736 /// ) -> Result<()> {
737 /// let response = client.get_operation()
738 /// /* set fields */
739 /// .send().await?;
740 /// println!("response {:?}", response);
741 /// Ok(())
742 /// }
743 /// ```
744 pub fn get_operation(&self) -> super::builder::autokey_admin::GetOperation {
745 super::builder::autokey_admin::GetOperation::new(self.inner.clone())
746 }
747}
748
749/// Implements a client for the Cloud Key Management Service (KMS) API.
750///
751/// # Example
752/// ```
753/// # use google_cloud_kms_v1::client::EkmService;
754/// use google_cloud_gax::paginator::ItemPaginator as _;
755/// async fn sample(
756/// parent: &str,
757/// ) -> anyhow::Result<()> {
758/// let client = EkmService::builder().build().await?;
759/// let mut list = client.list_ekm_connections()
760/// .set_parent(parent)
761/// .by_item();
762/// while let Some(item) = list.next().await.transpose()? {
763/// println!("{:?}", item);
764/// }
765/// Ok(())
766/// }
767/// ```
768///
769/// # Service Description
770///
771/// Google Cloud Key Management EKM Service
772///
773/// Manages external cryptographic keys and operations using those keys.
774/// Implements a REST model with the following objects:
775///
776/// * [EkmConnection][google.cloud.kms.v1.EkmConnection]
777///
778/// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
779///
780/// # Configuration
781///
782/// To configure `EkmService` use the `with_*` methods in the type returned
783/// by [builder()][EkmService::builder]. The default configuration should
784/// work for most applications. Common configuration changes include
785///
786/// * [with_endpoint()]: by default this client uses the global default endpoint
787/// (`https://cloudkms.googleapis.com`). Applications using regional
788/// endpoints or running in restricted networks (e.g. a network configured
789/// with [Private Google Access with VPC Service Controls]) may want to
790/// override this default.
791/// * [with_credentials()]: by default this client uses
792/// [Application Default Credentials]. Applications using custom
793/// authentication may need to override this default.
794///
795/// [with_endpoint()]: super::builder::ekm_service::ClientBuilder::with_endpoint
796/// [with_credentials()]: super::builder::ekm_service::ClientBuilder::with_credentials
797/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
798/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
799///
800/// # Pooling and Cloning
801///
802/// `EkmService` holds a connection pool internally, it is advised to
803/// create one and reuse it. You do not need to wrap `EkmService` in
804/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
805/// already uses an `Arc` internally.
806#[derive(Clone, Debug)]
807pub struct EkmService {
808 inner: std::sync::Arc<dyn super::stub::dynamic::EkmService>,
809}
810
811impl EkmService {
812 /// Returns a builder for [EkmService].
813 ///
814 /// ```
815 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
816 /// # use google_cloud_kms_v1::client::EkmService;
817 /// let client = EkmService::builder().build().await?;
818 /// # Ok(()) }
819 /// ```
820 pub fn builder() -> super::builder::ekm_service::ClientBuilder {
821 crate::new_client_builder(super::builder::ekm_service::client::Factory)
822 }
823
824 /// Creates a new client from the provided stub.
825 ///
826 /// The most common case for calling this function is in tests mocking the
827 /// client's behavior.
828 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
829 where
830 T: super::stub::EkmService + 'static,
831 {
832 Self { inner: stub.into() }
833 }
834
835 pub(crate) async fn new(
836 config: gaxi::options::ClientConfig,
837 ) -> crate::ClientBuilderResult<Self> {
838 let inner = Self::build_inner(config).await?;
839 Ok(Self { inner })
840 }
841
842 async fn build_inner(
843 conf: gaxi::options::ClientConfig,
844 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::EkmService>> {
845 if gaxi::options::tracing_enabled(&conf) {
846 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
847 }
848 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
849 }
850
851 async fn build_transport(
852 conf: gaxi::options::ClientConfig,
853 ) -> crate::ClientBuilderResult<impl super::stub::EkmService> {
854 super::transport::EkmService::new(conf).await
855 }
856
857 async fn build_with_tracing(
858 conf: gaxi::options::ClientConfig,
859 ) -> crate::ClientBuilderResult<impl super::stub::EkmService> {
860 Self::build_transport(conf)
861 .await
862 .map(super::tracing::EkmService::new)
863 }
864
865 /// Lists [EkmConnections][google.cloud.kms.v1.EkmConnection].
866 ///
867 /// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
868 ///
869 /// # Example
870 /// ```
871 /// # use google_cloud_kms_v1::client::EkmService;
872 /// use google_cloud_gax::paginator::ItemPaginator as _;
873 /// use google_cloud_kms_v1::Result;
874 /// async fn sample(
875 /// client: &EkmService, parent: &str
876 /// ) -> Result<()> {
877 /// let mut list = client.list_ekm_connections()
878 /// .set_parent(parent)
879 /// .by_item();
880 /// while let Some(item) = list.next().await.transpose()? {
881 /// println!("{:?}", item);
882 /// }
883 /// Ok(())
884 /// }
885 /// ```
886 pub fn list_ekm_connections(&self) -> super::builder::ekm_service::ListEkmConnections {
887 super::builder::ekm_service::ListEkmConnections::new(self.inner.clone())
888 }
889
890 /// Returns metadata for a given
891 /// [EkmConnection][google.cloud.kms.v1.EkmConnection].
892 ///
893 /// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
894 ///
895 /// # Example
896 /// ```
897 /// # use google_cloud_kms_v1::client::EkmService;
898 /// use google_cloud_kms_v1::Result;
899 /// async fn sample(
900 /// client: &EkmService, project_id: &str, location_id: &str, ekm_connection_id: &str
901 /// ) -> Result<()> {
902 /// let response = client.get_ekm_connection()
903 /// .set_name(format!("projects/{project_id}/locations/{location_id}/ekmConnections/{ekm_connection_id}"))
904 /// .send().await?;
905 /// println!("response {:?}", response);
906 /// Ok(())
907 /// }
908 /// ```
909 pub fn get_ekm_connection(&self) -> super::builder::ekm_service::GetEkmConnection {
910 super::builder::ekm_service::GetEkmConnection::new(self.inner.clone())
911 }
912
913 /// Creates a new [EkmConnection][google.cloud.kms.v1.EkmConnection] in a given
914 /// Project and Location.
915 ///
916 /// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
917 ///
918 /// # Example
919 /// ```
920 /// # use google_cloud_kms_v1::client::EkmService;
921 /// use google_cloud_kms_v1::model::EkmConnection;
922 /// use google_cloud_kms_v1::Result;
923 /// async fn sample(
924 /// client: &EkmService, parent: &str
925 /// ) -> Result<()> {
926 /// let response = client.create_ekm_connection()
927 /// .set_parent(parent)
928 /// .set_ekm_connection(
929 /// EkmConnection::new()/* set fields */
930 /// )
931 /// .send().await?;
932 /// println!("response {:?}", response);
933 /// Ok(())
934 /// }
935 /// ```
936 pub fn create_ekm_connection(&self) -> super::builder::ekm_service::CreateEkmConnection {
937 super::builder::ekm_service::CreateEkmConnection::new(self.inner.clone())
938 }
939
940 /// Updates an [EkmConnection][google.cloud.kms.v1.EkmConnection]'s metadata.
941 ///
942 /// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
943 ///
944 /// # Example
945 /// ```
946 /// # use google_cloud_kms_v1::client::EkmService;
947 /// # extern crate wkt as google_cloud_wkt;
948 /// use google_cloud_wkt::FieldMask;
949 /// use google_cloud_kms_v1::model::EkmConnection;
950 /// use google_cloud_kms_v1::Result;
951 /// async fn sample(
952 /// client: &EkmService, project_id: &str, location_id: &str, ekm_connection_id: &str
953 /// ) -> Result<()> {
954 /// let response = client.update_ekm_connection()
955 /// .set_ekm_connection(
956 /// EkmConnection::new().set_name(format!("projects/{project_id}/locations/{location_id}/ekmConnections/{ekm_connection_id}"))/* set fields */
957 /// )
958 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
959 /// .send().await?;
960 /// println!("response {:?}", response);
961 /// Ok(())
962 /// }
963 /// ```
964 pub fn update_ekm_connection(&self) -> super::builder::ekm_service::UpdateEkmConnection {
965 super::builder::ekm_service::UpdateEkmConnection::new(self.inner.clone())
966 }
967
968 /// Returns the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource
969 /// for a given project and location.
970 ///
971 /// [google.cloud.kms.v1.EkmConfig]: crate::model::EkmConfig
972 ///
973 /// # Example
974 /// ```
975 /// # use google_cloud_kms_v1::client::EkmService;
976 /// use google_cloud_kms_v1::Result;
977 /// async fn sample(
978 /// client: &EkmService, project_id: &str, location_id: &str
979 /// ) -> Result<()> {
980 /// let response = client.get_ekm_config()
981 /// .set_name(format!("projects/{project_id}/locations/{location_id}/ekmConfig"))
982 /// .send().await?;
983 /// println!("response {:?}", response);
984 /// Ok(())
985 /// }
986 /// ```
987 pub fn get_ekm_config(&self) -> super::builder::ekm_service::GetEkmConfig {
988 super::builder::ekm_service::GetEkmConfig::new(self.inner.clone())
989 }
990
991 /// Updates the [EkmConfig][google.cloud.kms.v1.EkmConfig] singleton resource
992 /// for a given project and location.
993 ///
994 /// [google.cloud.kms.v1.EkmConfig]: crate::model::EkmConfig
995 ///
996 /// # Example
997 /// ```
998 /// # use google_cloud_kms_v1::client::EkmService;
999 /// # extern crate wkt as google_cloud_wkt;
1000 /// use google_cloud_wkt::FieldMask;
1001 /// use google_cloud_kms_v1::model::EkmConfig;
1002 /// use google_cloud_kms_v1::Result;
1003 /// async fn sample(
1004 /// client: &EkmService, project_id: &str, location_id: &str
1005 /// ) -> Result<()> {
1006 /// let response = client.update_ekm_config()
1007 /// .set_ekm_config(
1008 /// EkmConfig::new().set_name(format!("projects/{project_id}/locations/{location_id}/ekmConfig"))/* set fields */
1009 /// )
1010 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1011 /// .send().await?;
1012 /// println!("response {:?}", response);
1013 /// Ok(())
1014 /// }
1015 /// ```
1016 pub fn update_ekm_config(&self) -> super::builder::ekm_service::UpdateEkmConfig {
1017 super::builder::ekm_service::UpdateEkmConfig::new(self.inner.clone())
1018 }
1019
1020 /// Verifies that Cloud KMS can successfully connect to the external key
1021 /// manager specified by an [EkmConnection][google.cloud.kms.v1.EkmConnection].
1022 /// If there is an error connecting to the EKM, this method returns a
1023 /// FAILED_PRECONDITION status containing structured information as described
1024 /// at <https://cloud.google.com/kms/docs/reference/ekm_errors>.
1025 ///
1026 /// [google.cloud.kms.v1.EkmConnection]: crate::model::EkmConnection
1027 ///
1028 /// # Example
1029 /// ```
1030 /// # use google_cloud_kms_v1::client::EkmService;
1031 /// use google_cloud_kms_v1::Result;
1032 /// async fn sample(
1033 /// client: &EkmService
1034 /// ) -> Result<()> {
1035 /// let response = client.verify_connectivity()
1036 /// /* set fields */
1037 /// .send().await?;
1038 /// println!("response {:?}", response);
1039 /// Ok(())
1040 /// }
1041 /// ```
1042 pub fn verify_connectivity(&self) -> super::builder::ekm_service::VerifyConnectivity {
1043 super::builder::ekm_service::VerifyConnectivity::new(self.inner.clone())
1044 }
1045
1046 /// Lists information about the supported locations for this service.
1047 ///
1048 /// This method lists locations based on the resource scope provided in
1049 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
1050 /// **Global locations**: If `name` is empty, the method lists the
1051 /// public locations available to all projects. * **Project-specific
1052 /// locations**: If `name` follows the format
1053 /// `projects/{project}`, the method lists locations visible to that
1054 /// specific project. This includes public, private, or other
1055 /// project-specific locations enabled for the project.
1056 ///
1057 /// For gRPC and client library implementations, the resource name is
1058 /// passed as the `name` field. For direct service calls, the resource
1059 /// name is
1060 /// incorporated into the request path based on the specific service
1061 /// implementation and version.
1062 ///
1063 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
1064 ///
1065 /// # Example
1066 /// ```
1067 /// # use google_cloud_kms_v1::client::EkmService;
1068 /// use google_cloud_gax::paginator::ItemPaginator as _;
1069 /// use google_cloud_kms_v1::Result;
1070 /// async fn sample(
1071 /// client: &EkmService
1072 /// ) -> Result<()> {
1073 /// let mut list = client.list_locations()
1074 /// /* set fields */
1075 /// .by_item();
1076 /// while let Some(item) = list.next().await.transpose()? {
1077 /// println!("{:?}", item);
1078 /// }
1079 /// Ok(())
1080 /// }
1081 /// ```
1082 pub fn list_locations(&self) -> super::builder::ekm_service::ListLocations {
1083 super::builder::ekm_service::ListLocations::new(self.inner.clone())
1084 }
1085
1086 /// Gets information about a location.
1087 ///
1088 /// # Example
1089 /// ```
1090 /// # use google_cloud_kms_v1::client::EkmService;
1091 /// use google_cloud_kms_v1::Result;
1092 /// async fn sample(
1093 /// client: &EkmService
1094 /// ) -> Result<()> {
1095 /// let response = client.get_location()
1096 /// /* set fields */
1097 /// .send().await?;
1098 /// println!("response {:?}", response);
1099 /// Ok(())
1100 /// }
1101 /// ```
1102 pub fn get_location(&self) -> super::builder::ekm_service::GetLocation {
1103 super::builder::ekm_service::GetLocation::new(self.inner.clone())
1104 }
1105
1106 /// Sets the access control policy on the specified resource. Replaces
1107 /// any existing policy.
1108 ///
1109 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1110 /// errors.
1111 ///
1112 /// # Example
1113 /// ```
1114 /// # use google_cloud_kms_v1::client::EkmService;
1115 /// use google_cloud_kms_v1::Result;
1116 /// async fn sample(
1117 /// client: &EkmService
1118 /// ) -> Result<()> {
1119 /// let response = client.set_iam_policy()
1120 /// /* set fields */
1121 /// .send().await?;
1122 /// println!("response {:?}", response);
1123 /// Ok(())
1124 /// }
1125 /// ```
1126 pub fn set_iam_policy(&self) -> super::builder::ekm_service::SetIamPolicy {
1127 super::builder::ekm_service::SetIamPolicy::new(self.inner.clone())
1128 }
1129
1130 /// Gets the access control policy for a resource. Returns an empty policy
1131 /// if the resource exists and does not have a policy set.
1132 ///
1133 /// # Example
1134 /// ```
1135 /// # use google_cloud_kms_v1::client::EkmService;
1136 /// use google_cloud_kms_v1::Result;
1137 /// async fn sample(
1138 /// client: &EkmService
1139 /// ) -> Result<()> {
1140 /// let response = client.get_iam_policy()
1141 /// /* set fields */
1142 /// .send().await?;
1143 /// println!("response {:?}", response);
1144 /// Ok(())
1145 /// }
1146 /// ```
1147 pub fn get_iam_policy(&self) -> super::builder::ekm_service::GetIamPolicy {
1148 super::builder::ekm_service::GetIamPolicy::new(self.inner.clone())
1149 }
1150
1151 /// Returns permissions that a caller has on the specified resource. If the
1152 /// resource does not exist, this will return an empty set of
1153 /// permissions, not a `NOT_FOUND` error.
1154 ///
1155 /// Note: This operation is designed to be used for building
1156 /// permission-aware UIs and command-line tools, not for authorization
1157 /// checking. This operation may "fail open" without warning.
1158 ///
1159 /// # Example
1160 /// ```
1161 /// # use google_cloud_kms_v1::client::EkmService;
1162 /// use google_cloud_kms_v1::Result;
1163 /// async fn sample(
1164 /// client: &EkmService
1165 /// ) -> Result<()> {
1166 /// let response = client.test_iam_permissions()
1167 /// /* set fields */
1168 /// .send().await?;
1169 /// println!("response {:?}", response);
1170 /// Ok(())
1171 /// }
1172 /// ```
1173 pub fn test_iam_permissions(&self) -> super::builder::ekm_service::TestIamPermissions {
1174 super::builder::ekm_service::TestIamPermissions::new(self.inner.clone())
1175 }
1176
1177 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1178 ///
1179 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1180 ///
1181 /// # Example
1182 /// ```
1183 /// # use google_cloud_kms_v1::client::EkmService;
1184 /// use google_cloud_kms_v1::Result;
1185 /// async fn sample(
1186 /// client: &EkmService
1187 /// ) -> Result<()> {
1188 /// let response = client.get_operation()
1189 /// /* set fields */
1190 /// .send().await?;
1191 /// println!("response {:?}", response);
1192 /// Ok(())
1193 /// }
1194 /// ```
1195 pub fn get_operation(&self) -> super::builder::ekm_service::GetOperation {
1196 super::builder::ekm_service::GetOperation::new(self.inner.clone())
1197 }
1198}
1199
1200/// Implements a client for the Cloud Key Management Service (KMS) API.
1201///
1202/// # Example
1203/// ```
1204/// # use google_cloud_kms_v1::client::HsmManagement;
1205/// use google_cloud_gax::paginator::ItemPaginator as _;
1206/// async fn sample(
1207/// parent: &str,
1208/// ) -> anyhow::Result<()> {
1209/// let client = HsmManagement::builder().build().await?;
1210/// let mut list = client.list_single_tenant_hsm_instances()
1211/// .set_parent(parent)
1212/// .by_item();
1213/// while let Some(item) = list.next().await.transpose()? {
1214/// println!("{:?}", item);
1215/// }
1216/// Ok(())
1217/// }
1218/// ```
1219///
1220/// # Service Description
1221///
1222/// Google Cloud HSM Management Service
1223///
1224/// Provides interfaces for managing HSM instances.
1225///
1226/// Implements a REST model with the following objects:
1227///
1228/// * [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance]
1229/// * [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
1230///
1231/// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1232/// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1233///
1234/// # Configuration
1235///
1236/// To configure `HsmManagement` use the `with_*` methods in the type returned
1237/// by [builder()][HsmManagement::builder]. The default configuration should
1238/// work for most applications. Common configuration changes include
1239///
1240/// * [with_endpoint()]: by default this client uses the global default endpoint
1241/// (`https://cloudkms.googleapis.com`). Applications using regional
1242/// endpoints or running in restricted networks (e.g. a network configured
1243/// with [Private Google Access with VPC Service Controls]) may want to
1244/// override this default.
1245/// * [with_credentials()]: by default this client uses
1246/// [Application Default Credentials]. Applications using custom
1247/// authentication may need to override this default.
1248///
1249/// [with_endpoint()]: super::builder::hsm_management::ClientBuilder::with_endpoint
1250/// [with_credentials()]: super::builder::hsm_management::ClientBuilder::with_credentials
1251/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1252/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1253///
1254/// # Pooling and Cloning
1255///
1256/// `HsmManagement` holds a connection pool internally, it is advised to
1257/// create one and reuse it. You do not need to wrap `HsmManagement` in
1258/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1259/// already uses an `Arc` internally.
1260#[derive(Clone, Debug)]
1261pub struct HsmManagement {
1262 inner: std::sync::Arc<dyn super::stub::dynamic::HsmManagement>,
1263}
1264
1265impl HsmManagement {
1266 /// Returns a builder for [HsmManagement].
1267 ///
1268 /// ```
1269 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1270 /// # use google_cloud_kms_v1::client::HsmManagement;
1271 /// let client = HsmManagement::builder().build().await?;
1272 /// # Ok(()) }
1273 /// ```
1274 pub fn builder() -> super::builder::hsm_management::ClientBuilder {
1275 crate::new_client_builder(super::builder::hsm_management::client::Factory)
1276 }
1277
1278 /// Creates a new client from the provided stub.
1279 ///
1280 /// The most common case for calling this function is in tests mocking the
1281 /// client's behavior.
1282 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1283 where
1284 T: super::stub::HsmManagement + 'static,
1285 {
1286 Self { inner: stub.into() }
1287 }
1288
1289 pub(crate) async fn new(
1290 config: gaxi::options::ClientConfig,
1291 ) -> crate::ClientBuilderResult<Self> {
1292 let inner = Self::build_inner(config).await?;
1293 Ok(Self { inner })
1294 }
1295
1296 async fn build_inner(
1297 conf: gaxi::options::ClientConfig,
1298 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::HsmManagement>> {
1299 if gaxi::options::tracing_enabled(&conf) {
1300 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1301 }
1302 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1303 }
1304
1305 async fn build_transport(
1306 conf: gaxi::options::ClientConfig,
1307 ) -> crate::ClientBuilderResult<impl super::stub::HsmManagement> {
1308 super::transport::HsmManagement::new(conf).await
1309 }
1310
1311 async fn build_with_tracing(
1312 conf: gaxi::options::ClientConfig,
1313 ) -> crate::ClientBuilderResult<impl super::stub::HsmManagement> {
1314 Self::build_transport(conf)
1315 .await
1316 .map(super::tracing::HsmManagement::new)
1317 }
1318
1319 /// Lists
1320 /// [SingleTenantHsmInstances][google.cloud.kms.v1.SingleTenantHsmInstance].
1321 ///
1322 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1323 ///
1324 /// # Example
1325 /// ```
1326 /// # use google_cloud_kms_v1::client::HsmManagement;
1327 /// use google_cloud_gax::paginator::ItemPaginator as _;
1328 /// use google_cloud_kms_v1::Result;
1329 /// async fn sample(
1330 /// client: &HsmManagement, parent: &str
1331 /// ) -> Result<()> {
1332 /// let mut list = client.list_single_tenant_hsm_instances()
1333 /// .set_parent(parent)
1334 /// .by_item();
1335 /// while let Some(item) = list.next().await.transpose()? {
1336 /// println!("{:?}", item);
1337 /// }
1338 /// Ok(())
1339 /// }
1340 /// ```
1341 pub fn list_single_tenant_hsm_instances(
1342 &self,
1343 ) -> super::builder::hsm_management::ListSingleTenantHsmInstances {
1344 super::builder::hsm_management::ListSingleTenantHsmInstances::new(self.inner.clone())
1345 }
1346
1347 /// Returns metadata for a given
1348 /// [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance].
1349 ///
1350 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1351 ///
1352 /// # Example
1353 /// ```
1354 /// # use google_cloud_kms_v1::client::HsmManagement;
1355 /// use google_cloud_kms_v1::Result;
1356 /// async fn sample(
1357 /// client: &HsmManagement, project_id: &str, location_id: &str, single_tenant_hsm_instance_id: &str
1358 /// ) -> Result<()> {
1359 /// let response = client.get_single_tenant_hsm_instance()
1360 /// .set_name(format!("projects/{project_id}/locations/{location_id}/singleTenantHsmInstances/{single_tenant_hsm_instance_id}"))
1361 /// .send().await?;
1362 /// println!("response {:?}", response);
1363 /// Ok(())
1364 /// }
1365 /// ```
1366 pub fn get_single_tenant_hsm_instance(
1367 &self,
1368 ) -> super::builder::hsm_management::GetSingleTenantHsmInstance {
1369 super::builder::hsm_management::GetSingleTenantHsmInstance::new(self.inner.clone())
1370 }
1371
1372 /// Creates a new
1373 /// [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance] in a
1374 /// given Project and Location. User must create a RegisterTwoFactorAuthKeys
1375 /// proposal with this single-tenant HSM instance to finish setup of the
1376 /// instance.
1377 ///
1378 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1379 ///
1380 /// # Long running operations
1381 ///
1382 /// This method is used to start, and/or poll a [long-running Operation].
1383 /// The [Working with long-running operations] chapter in the [user guide]
1384 /// covers these operations in detail.
1385 ///
1386 /// [long-running operation]: https://google.aip.dev/151
1387 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1388 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1389 ///
1390 /// # Example
1391 /// ```
1392 /// # use google_cloud_kms_v1::client::HsmManagement;
1393 /// use google_cloud_lro::Poller;
1394 /// use google_cloud_kms_v1::model::SingleTenantHsmInstance;
1395 /// use google_cloud_kms_v1::Result;
1396 /// async fn sample(
1397 /// client: &HsmManagement, parent: &str
1398 /// ) -> Result<()> {
1399 /// let response = client.create_single_tenant_hsm_instance()
1400 /// .set_parent(parent)
1401 /// .set_single_tenant_hsm_instance(
1402 /// SingleTenantHsmInstance::new()/* set fields */
1403 /// )
1404 /// .poller().until_done().await?;
1405 /// println!("response {:?}", response);
1406 /// Ok(())
1407 /// }
1408 /// ```
1409 pub fn create_single_tenant_hsm_instance(
1410 &self,
1411 ) -> super::builder::hsm_management::CreateSingleTenantHsmInstance {
1412 super::builder::hsm_management::CreateSingleTenantHsmInstance::new(self.inner.clone())
1413 }
1414
1415 /// Creates a new
1416 /// [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
1417 /// for a given
1418 /// [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance].
1419 ///
1420 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1421 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1422 ///
1423 /// # Long running operations
1424 ///
1425 /// This method is used to start, and/or poll a [long-running Operation].
1426 /// The [Working with long-running operations] chapter in the [user guide]
1427 /// covers these operations in detail.
1428 ///
1429 /// [long-running operation]: https://google.aip.dev/151
1430 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1431 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1432 ///
1433 /// # Example
1434 /// ```
1435 /// # use google_cloud_kms_v1::client::HsmManagement;
1436 /// use google_cloud_lro::Poller;
1437 /// use google_cloud_kms_v1::model::SingleTenantHsmInstanceProposal;
1438 /// use google_cloud_kms_v1::Result;
1439 /// async fn sample(
1440 /// client: &HsmManagement, project_id: &str, location_id: &str, single_tenant_hsm_instance_id: &str
1441 /// ) -> Result<()> {
1442 /// let response = client.create_single_tenant_hsm_instance_proposal()
1443 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/singleTenantHsmInstances/{single_tenant_hsm_instance_id}"))
1444 /// .set_single_tenant_hsm_instance_proposal(
1445 /// SingleTenantHsmInstanceProposal::new()/* set fields */
1446 /// )
1447 /// .poller().until_done().await?;
1448 /// println!("response {:?}", response);
1449 /// Ok(())
1450 /// }
1451 /// ```
1452 pub fn create_single_tenant_hsm_instance_proposal(
1453 &self,
1454 ) -> super::builder::hsm_management::CreateSingleTenantHsmInstanceProposal {
1455 super::builder::hsm_management::CreateSingleTenantHsmInstanceProposal::new(
1456 self.inner.clone(),
1457 )
1458 }
1459
1460 /// Approves a
1461 /// [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
1462 /// for a given
1463 /// [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance]. The
1464 /// proposal must be in the
1465 /// [PENDING][google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.PENDING]
1466 /// state.
1467 ///
1468 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1469 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1470 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.PENDING]: crate::model::single_tenant_hsm_instance_proposal::State::Pending
1471 ///
1472 /// # Example
1473 /// ```
1474 /// # use google_cloud_kms_v1::client::HsmManagement;
1475 /// use google_cloud_kms_v1::Result;
1476 /// async fn sample(
1477 /// client: &HsmManagement
1478 /// ) -> Result<()> {
1479 /// let response = client.approve_single_tenant_hsm_instance_proposal()
1480 /// /* set fields */
1481 /// .send().await?;
1482 /// println!("response {:?}", response);
1483 /// Ok(())
1484 /// }
1485 /// ```
1486 pub fn approve_single_tenant_hsm_instance_proposal(
1487 &self,
1488 ) -> super::builder::hsm_management::ApproveSingleTenantHsmInstanceProposal {
1489 super::builder::hsm_management::ApproveSingleTenantHsmInstanceProposal::new(
1490 self.inner.clone(),
1491 )
1492 }
1493
1494 /// Executes a
1495 /// [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal]
1496 /// for a given
1497 /// [SingleTenantHsmInstance][google.cloud.kms.v1.SingleTenantHsmInstance]. The
1498 /// proposal must be in the
1499 /// [APPROVED][google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.APPROVED]
1500 /// state.
1501 ///
1502 /// [google.cloud.kms.v1.SingleTenantHsmInstance]: crate::model::SingleTenantHsmInstance
1503 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1504 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.APPROVED]: crate::model::single_tenant_hsm_instance_proposal::State::Approved
1505 ///
1506 /// # Long running operations
1507 ///
1508 /// This method is used to start, and/or poll a [long-running Operation].
1509 /// The [Working with long-running operations] chapter in the [user guide]
1510 /// covers these operations in detail.
1511 ///
1512 /// [long-running operation]: https://google.aip.dev/151
1513 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
1514 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
1515 ///
1516 /// # Example
1517 /// ```
1518 /// # use google_cloud_kms_v1::client::HsmManagement;
1519 /// use google_cloud_lro::Poller;
1520 /// use google_cloud_kms_v1::Result;
1521 /// async fn sample(
1522 /// client: &HsmManagement
1523 /// ) -> Result<()> {
1524 /// let response = client.execute_single_tenant_hsm_instance_proposal()
1525 /// /* set fields */
1526 /// .poller().until_done().await?;
1527 /// println!("response {:?}", response);
1528 /// Ok(())
1529 /// }
1530 /// ```
1531 pub fn execute_single_tenant_hsm_instance_proposal(
1532 &self,
1533 ) -> super::builder::hsm_management::ExecuteSingleTenantHsmInstanceProposal {
1534 super::builder::hsm_management::ExecuteSingleTenantHsmInstanceProposal::new(
1535 self.inner.clone(),
1536 )
1537 }
1538
1539 /// Returns metadata for a given
1540 /// [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal].
1541 ///
1542 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1543 ///
1544 /// # Example
1545 /// ```
1546 /// # use google_cloud_kms_v1::client::HsmManagement;
1547 /// use google_cloud_kms_v1::Result;
1548 /// async fn sample(
1549 /// client: &HsmManagement, project_id: &str, location_id: &str, single_tenant_hsm_instance_id: &str, proposal_id: &str
1550 /// ) -> Result<()> {
1551 /// let response = client.get_single_tenant_hsm_instance_proposal()
1552 /// .set_name(format!("projects/{project_id}/locations/{location_id}/singleTenantHsmInstances/{single_tenant_hsm_instance_id}/proposals/{proposal_id}"))
1553 /// .send().await?;
1554 /// println!("response {:?}", response);
1555 /// Ok(())
1556 /// }
1557 /// ```
1558 pub fn get_single_tenant_hsm_instance_proposal(
1559 &self,
1560 ) -> super::builder::hsm_management::GetSingleTenantHsmInstanceProposal {
1561 super::builder::hsm_management::GetSingleTenantHsmInstanceProposal::new(self.inner.clone())
1562 }
1563
1564 /// Lists
1565 /// [SingleTenantHsmInstanceProposals][google.cloud.kms.v1.SingleTenantHsmInstanceProposal].
1566 ///
1567 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1568 ///
1569 /// # Example
1570 /// ```
1571 /// # use google_cloud_kms_v1::client::HsmManagement;
1572 /// use google_cloud_gax::paginator::ItemPaginator as _;
1573 /// use google_cloud_kms_v1::Result;
1574 /// async fn sample(
1575 /// client: &HsmManagement, project_id: &str, location_id: &str, single_tenant_hsm_instance_id: &str
1576 /// ) -> Result<()> {
1577 /// let mut list = client.list_single_tenant_hsm_instance_proposals()
1578 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/singleTenantHsmInstances/{single_tenant_hsm_instance_id}"))
1579 /// .by_item();
1580 /// while let Some(item) = list.next().await.transpose()? {
1581 /// println!("{:?}", item);
1582 /// }
1583 /// Ok(())
1584 /// }
1585 /// ```
1586 pub fn list_single_tenant_hsm_instance_proposals(
1587 &self,
1588 ) -> super::builder::hsm_management::ListSingleTenantHsmInstanceProposals {
1589 super::builder::hsm_management::ListSingleTenantHsmInstanceProposals::new(
1590 self.inner.clone(),
1591 )
1592 }
1593
1594 /// Deletes a
1595 /// [SingleTenantHsmInstanceProposal][google.cloud.kms.v1.SingleTenantHsmInstanceProposal].
1596 ///
1597 /// [google.cloud.kms.v1.SingleTenantHsmInstanceProposal]: crate::model::SingleTenantHsmInstanceProposal
1598 ///
1599 /// # Example
1600 /// ```
1601 /// # use google_cloud_kms_v1::client::HsmManagement;
1602 /// use google_cloud_kms_v1::Result;
1603 /// async fn sample(
1604 /// client: &HsmManagement, project_id: &str, location_id: &str, single_tenant_hsm_instance_id: &str, proposal_id: &str
1605 /// ) -> Result<()> {
1606 /// client.delete_single_tenant_hsm_instance_proposal()
1607 /// .set_name(format!("projects/{project_id}/locations/{location_id}/singleTenantHsmInstances/{single_tenant_hsm_instance_id}/proposals/{proposal_id}"))
1608 /// .send().await?;
1609 /// Ok(())
1610 /// }
1611 /// ```
1612 pub fn delete_single_tenant_hsm_instance_proposal(
1613 &self,
1614 ) -> super::builder::hsm_management::DeleteSingleTenantHsmInstanceProposal {
1615 super::builder::hsm_management::DeleteSingleTenantHsmInstanceProposal::new(
1616 self.inner.clone(),
1617 )
1618 }
1619
1620 /// Lists information about the supported locations for this service.
1621 ///
1622 /// This method lists locations based on the resource scope provided in
1623 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
1624 /// **Global locations**: If `name` is empty, the method lists the
1625 /// public locations available to all projects. * **Project-specific
1626 /// locations**: If `name` follows the format
1627 /// `projects/{project}`, the method lists locations visible to that
1628 /// specific project. This includes public, private, or other
1629 /// project-specific locations enabled for the project.
1630 ///
1631 /// For gRPC and client library implementations, the resource name is
1632 /// passed as the `name` field. For direct service calls, the resource
1633 /// name is
1634 /// incorporated into the request path based on the specific service
1635 /// implementation and version.
1636 ///
1637 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
1638 ///
1639 /// # Example
1640 /// ```
1641 /// # use google_cloud_kms_v1::client::HsmManagement;
1642 /// use google_cloud_gax::paginator::ItemPaginator as _;
1643 /// use google_cloud_kms_v1::Result;
1644 /// async fn sample(
1645 /// client: &HsmManagement
1646 /// ) -> Result<()> {
1647 /// let mut list = client.list_locations()
1648 /// /* set fields */
1649 /// .by_item();
1650 /// while let Some(item) = list.next().await.transpose()? {
1651 /// println!("{:?}", item);
1652 /// }
1653 /// Ok(())
1654 /// }
1655 /// ```
1656 pub fn list_locations(&self) -> super::builder::hsm_management::ListLocations {
1657 super::builder::hsm_management::ListLocations::new(self.inner.clone())
1658 }
1659
1660 /// Gets information about a location.
1661 ///
1662 /// # Example
1663 /// ```
1664 /// # use google_cloud_kms_v1::client::HsmManagement;
1665 /// use google_cloud_kms_v1::Result;
1666 /// async fn sample(
1667 /// client: &HsmManagement
1668 /// ) -> Result<()> {
1669 /// let response = client.get_location()
1670 /// /* set fields */
1671 /// .send().await?;
1672 /// println!("response {:?}", response);
1673 /// Ok(())
1674 /// }
1675 /// ```
1676 pub fn get_location(&self) -> super::builder::hsm_management::GetLocation {
1677 super::builder::hsm_management::GetLocation::new(self.inner.clone())
1678 }
1679
1680 /// Sets the access control policy on the specified resource. Replaces
1681 /// any existing policy.
1682 ///
1683 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1684 /// errors.
1685 ///
1686 /// # Example
1687 /// ```
1688 /// # use google_cloud_kms_v1::client::HsmManagement;
1689 /// use google_cloud_kms_v1::Result;
1690 /// async fn sample(
1691 /// client: &HsmManagement
1692 /// ) -> Result<()> {
1693 /// let response = client.set_iam_policy()
1694 /// /* set fields */
1695 /// .send().await?;
1696 /// println!("response {:?}", response);
1697 /// Ok(())
1698 /// }
1699 /// ```
1700 pub fn set_iam_policy(&self) -> super::builder::hsm_management::SetIamPolicy {
1701 super::builder::hsm_management::SetIamPolicy::new(self.inner.clone())
1702 }
1703
1704 /// Gets the access control policy for a resource. Returns an empty policy
1705 /// if the resource exists and does not have a policy set.
1706 ///
1707 /// # Example
1708 /// ```
1709 /// # use google_cloud_kms_v1::client::HsmManagement;
1710 /// use google_cloud_kms_v1::Result;
1711 /// async fn sample(
1712 /// client: &HsmManagement
1713 /// ) -> Result<()> {
1714 /// let response = client.get_iam_policy()
1715 /// /* set fields */
1716 /// .send().await?;
1717 /// println!("response {:?}", response);
1718 /// Ok(())
1719 /// }
1720 /// ```
1721 pub fn get_iam_policy(&self) -> super::builder::hsm_management::GetIamPolicy {
1722 super::builder::hsm_management::GetIamPolicy::new(self.inner.clone())
1723 }
1724
1725 /// Returns permissions that a caller has on the specified resource. If the
1726 /// resource does not exist, this will return an empty set of
1727 /// permissions, not a `NOT_FOUND` error.
1728 ///
1729 /// Note: This operation is designed to be used for building
1730 /// permission-aware UIs and command-line tools, not for authorization
1731 /// checking. This operation may "fail open" without warning.
1732 ///
1733 /// # Example
1734 /// ```
1735 /// # use google_cloud_kms_v1::client::HsmManagement;
1736 /// use google_cloud_kms_v1::Result;
1737 /// async fn sample(
1738 /// client: &HsmManagement
1739 /// ) -> Result<()> {
1740 /// let response = client.test_iam_permissions()
1741 /// /* set fields */
1742 /// .send().await?;
1743 /// println!("response {:?}", response);
1744 /// Ok(())
1745 /// }
1746 /// ```
1747 pub fn test_iam_permissions(&self) -> super::builder::hsm_management::TestIamPermissions {
1748 super::builder::hsm_management::TestIamPermissions::new(self.inner.clone())
1749 }
1750
1751 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
1752 ///
1753 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
1754 ///
1755 /// # Example
1756 /// ```
1757 /// # use google_cloud_kms_v1::client::HsmManagement;
1758 /// use google_cloud_kms_v1::Result;
1759 /// async fn sample(
1760 /// client: &HsmManagement
1761 /// ) -> Result<()> {
1762 /// let response = client.get_operation()
1763 /// /* set fields */
1764 /// .send().await?;
1765 /// println!("response {:?}", response);
1766 /// Ok(())
1767 /// }
1768 /// ```
1769 pub fn get_operation(&self) -> super::builder::hsm_management::GetOperation {
1770 super::builder::hsm_management::GetOperation::new(self.inner.clone())
1771 }
1772}
1773
1774/// Implements a client for the Cloud Key Management Service (KMS) API.
1775///
1776/// # Example
1777/// ```
1778/// # use google_cloud_kms_v1::client::KeyManagementService;
1779/// use google_cloud_gax::paginator::ItemPaginator as _;
1780/// async fn sample(
1781/// parent: &str,
1782/// ) -> anyhow::Result<()> {
1783/// let client = KeyManagementService::builder().build().await?;
1784/// let mut list = client.list_key_rings()
1785/// .set_parent(parent)
1786/// .by_item();
1787/// while let Some(item) = list.next().await.transpose()? {
1788/// println!("{:?}", item);
1789/// }
1790/// Ok(())
1791/// }
1792/// ```
1793///
1794/// # Service Description
1795///
1796/// Google Cloud Key Management Service
1797///
1798/// Manages cryptographic keys and operations using those keys. Implements a REST
1799/// model with the following objects:
1800///
1801/// * [KeyRing][google.cloud.kms.v1.KeyRing]
1802/// * [CryptoKey][google.cloud.kms.v1.CryptoKey]
1803/// * [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
1804/// * [ImportJob][google.cloud.kms.v1.ImportJob]
1805///
1806/// If you are using manual gRPC libraries, see
1807/// [Using gRPC with Cloud KMS](https://cloud.google.com/kms/docs/grpc).
1808///
1809/// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
1810/// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
1811/// [google.cloud.kms.v1.ImportJob]: crate::model::ImportJob
1812/// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
1813///
1814/// # Configuration
1815///
1816/// To configure `KeyManagementService` use the `with_*` methods in the type returned
1817/// by [builder()][KeyManagementService::builder]. The default configuration should
1818/// work for most applications. Common configuration changes include
1819///
1820/// * [with_endpoint()]: by default this client uses the global default endpoint
1821/// (`https://cloudkms.googleapis.com`). Applications using regional
1822/// endpoints or running in restricted networks (e.g. a network configured
1823/// with [Private Google Access with VPC Service Controls]) may want to
1824/// override this default.
1825/// * [with_credentials()]: by default this client uses
1826/// [Application Default Credentials]. Applications using custom
1827/// authentication may need to override this default.
1828///
1829/// [with_endpoint()]: super::builder::key_management_service::ClientBuilder::with_endpoint
1830/// [with_credentials()]: super::builder::key_management_service::ClientBuilder::with_credentials
1831/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
1832/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
1833///
1834/// # Pooling and Cloning
1835///
1836/// `KeyManagementService` holds a connection pool internally, it is advised to
1837/// create one and reuse it. You do not need to wrap `KeyManagementService` in
1838/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
1839/// already uses an `Arc` internally.
1840#[derive(Clone, Debug)]
1841pub struct KeyManagementService {
1842 inner: std::sync::Arc<dyn super::stub::dynamic::KeyManagementService>,
1843}
1844
1845impl KeyManagementService {
1846 /// Returns a builder for [KeyManagementService].
1847 ///
1848 /// ```
1849 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
1850 /// # use google_cloud_kms_v1::client::KeyManagementService;
1851 /// let client = KeyManagementService::builder().build().await?;
1852 /// # Ok(()) }
1853 /// ```
1854 pub fn builder() -> super::builder::key_management_service::ClientBuilder {
1855 crate::new_client_builder(super::builder::key_management_service::client::Factory)
1856 }
1857
1858 /// Creates a new client from the provided stub.
1859 ///
1860 /// The most common case for calling this function is in tests mocking the
1861 /// client's behavior.
1862 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
1863 where
1864 T: super::stub::KeyManagementService + 'static,
1865 {
1866 Self { inner: stub.into() }
1867 }
1868
1869 pub(crate) async fn new(
1870 config: gaxi::options::ClientConfig,
1871 ) -> crate::ClientBuilderResult<Self> {
1872 let inner = Self::build_inner(config).await?;
1873 Ok(Self { inner })
1874 }
1875
1876 async fn build_inner(
1877 conf: gaxi::options::ClientConfig,
1878 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::KeyManagementService>>
1879 {
1880 if gaxi::options::tracing_enabled(&conf) {
1881 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
1882 }
1883 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
1884 }
1885
1886 async fn build_transport(
1887 conf: gaxi::options::ClientConfig,
1888 ) -> crate::ClientBuilderResult<impl super::stub::KeyManagementService> {
1889 super::transport::KeyManagementService::new(conf).await
1890 }
1891
1892 async fn build_with_tracing(
1893 conf: gaxi::options::ClientConfig,
1894 ) -> crate::ClientBuilderResult<impl super::stub::KeyManagementService> {
1895 Self::build_transport(conf)
1896 .await
1897 .map(super::tracing::KeyManagementService::new)
1898 }
1899
1900 /// Lists [KeyRings][google.cloud.kms.v1.KeyRing].
1901 ///
1902 /// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
1903 ///
1904 /// # Example
1905 /// ```
1906 /// # use google_cloud_kms_v1::client::KeyManagementService;
1907 /// use google_cloud_gax::paginator::ItemPaginator as _;
1908 /// use google_cloud_kms_v1::Result;
1909 /// async fn sample(
1910 /// client: &KeyManagementService, parent: &str
1911 /// ) -> Result<()> {
1912 /// let mut list = client.list_key_rings()
1913 /// .set_parent(parent)
1914 /// .by_item();
1915 /// while let Some(item) = list.next().await.transpose()? {
1916 /// println!("{:?}", item);
1917 /// }
1918 /// Ok(())
1919 /// }
1920 /// ```
1921 pub fn list_key_rings(&self) -> super::builder::key_management_service::ListKeyRings {
1922 super::builder::key_management_service::ListKeyRings::new(self.inner.clone())
1923 }
1924
1925 /// Lists [CryptoKeys][google.cloud.kms.v1.CryptoKey].
1926 ///
1927 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
1928 ///
1929 /// # Example
1930 /// ```
1931 /// # use google_cloud_kms_v1::client::KeyManagementService;
1932 /// use google_cloud_gax::paginator::ItemPaginator as _;
1933 /// use google_cloud_kms_v1::Result;
1934 /// async fn sample(
1935 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str
1936 /// ) -> Result<()> {
1937 /// let mut list = client.list_crypto_keys()
1938 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}"))
1939 /// .by_item();
1940 /// while let Some(item) = list.next().await.transpose()? {
1941 /// println!("{:?}", item);
1942 /// }
1943 /// Ok(())
1944 /// }
1945 /// ```
1946 pub fn list_crypto_keys(&self) -> super::builder::key_management_service::ListCryptoKeys {
1947 super::builder::key_management_service::ListCryptoKeys::new(self.inner.clone())
1948 }
1949
1950 /// Lists [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion].
1951 ///
1952 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
1953 ///
1954 /// # Example
1955 /// ```
1956 /// # use google_cloud_kms_v1::client::KeyManagementService;
1957 /// use google_cloud_gax::paginator::ItemPaginator as _;
1958 /// use google_cloud_kms_v1::Result;
1959 /// async fn sample(
1960 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str
1961 /// ) -> Result<()> {
1962 /// let mut list = client.list_crypto_key_versions()
1963 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}"))
1964 /// .by_item();
1965 /// while let Some(item) = list.next().await.transpose()? {
1966 /// println!("{:?}", item);
1967 /// }
1968 /// Ok(())
1969 /// }
1970 /// ```
1971 pub fn list_crypto_key_versions(
1972 &self,
1973 ) -> super::builder::key_management_service::ListCryptoKeyVersions {
1974 super::builder::key_management_service::ListCryptoKeyVersions::new(self.inner.clone())
1975 }
1976
1977 /// Lists [ImportJobs][google.cloud.kms.v1.ImportJob].
1978 ///
1979 /// [google.cloud.kms.v1.ImportJob]: crate::model::ImportJob
1980 ///
1981 /// # Example
1982 /// ```
1983 /// # use google_cloud_kms_v1::client::KeyManagementService;
1984 /// use google_cloud_gax::paginator::ItemPaginator as _;
1985 /// use google_cloud_kms_v1::Result;
1986 /// async fn sample(
1987 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str
1988 /// ) -> Result<()> {
1989 /// let mut list = client.list_import_jobs()
1990 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}"))
1991 /// .by_item();
1992 /// while let Some(item) = list.next().await.transpose()? {
1993 /// println!("{:?}", item);
1994 /// }
1995 /// Ok(())
1996 /// }
1997 /// ```
1998 pub fn list_import_jobs(&self) -> super::builder::key_management_service::ListImportJobs {
1999 super::builder::key_management_service::ListImportJobs::new(self.inner.clone())
2000 }
2001
2002 /// Lists the [RetiredResources][google.cloud.kms.v1.RetiredResource] which are
2003 /// the records of deleted [CryptoKeys][google.cloud.kms.v1.CryptoKey].
2004 /// RetiredResources prevent the reuse of these resource names after deletion.
2005 ///
2006 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2007 /// [google.cloud.kms.v1.RetiredResource]: crate::model::RetiredResource
2008 ///
2009 /// # Example
2010 /// ```
2011 /// # use google_cloud_kms_v1::client::KeyManagementService;
2012 /// use google_cloud_gax::paginator::ItemPaginator as _;
2013 /// use google_cloud_kms_v1::Result;
2014 /// async fn sample(
2015 /// client: &KeyManagementService, project_id: &str, location_id: &str
2016 /// ) -> Result<()> {
2017 /// let mut list = client.list_retired_resources()
2018 /// .set_parent(format!("projects/{project_id}/locations/{location_id}"))
2019 /// .by_item();
2020 /// while let Some(item) = list.next().await.transpose()? {
2021 /// println!("{:?}", item);
2022 /// }
2023 /// Ok(())
2024 /// }
2025 /// ```
2026 pub fn list_retired_resources(
2027 &self,
2028 ) -> super::builder::key_management_service::ListRetiredResources {
2029 super::builder::key_management_service::ListRetiredResources::new(self.inner.clone())
2030 }
2031
2032 /// Returns metadata for a given [KeyRing][google.cloud.kms.v1.KeyRing].
2033 ///
2034 /// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
2035 ///
2036 /// # Example
2037 /// ```
2038 /// # use google_cloud_kms_v1::client::KeyManagementService;
2039 /// use google_cloud_kms_v1::Result;
2040 /// async fn sample(
2041 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str
2042 /// ) -> Result<()> {
2043 /// let response = client.get_key_ring()
2044 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}"))
2045 /// .send().await?;
2046 /// println!("response {:?}", response);
2047 /// Ok(())
2048 /// }
2049 /// ```
2050 pub fn get_key_ring(&self) -> super::builder::key_management_service::GetKeyRing {
2051 super::builder::key_management_service::GetKeyRing::new(self.inner.clone())
2052 }
2053
2054 /// Returns metadata for a given [CryptoKey][google.cloud.kms.v1.CryptoKey], as
2055 /// well as its [primary][google.cloud.kms.v1.CryptoKey.primary]
2056 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
2057 ///
2058 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2059 /// [google.cloud.kms.v1.CryptoKey.primary]: crate::model::CryptoKey::primary
2060 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2061 ///
2062 /// # Example
2063 /// ```
2064 /// # use google_cloud_kms_v1::client::KeyManagementService;
2065 /// use google_cloud_kms_v1::Result;
2066 /// async fn sample(
2067 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str
2068 /// ) -> Result<()> {
2069 /// let response = client.get_crypto_key()
2070 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}"))
2071 /// .send().await?;
2072 /// println!("response {:?}", response);
2073 /// Ok(())
2074 /// }
2075 /// ```
2076 pub fn get_crypto_key(&self) -> super::builder::key_management_service::GetCryptoKey {
2077 super::builder::key_management_service::GetCryptoKey::new(self.inner.clone())
2078 }
2079
2080 /// Returns metadata for a given
2081 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
2082 ///
2083 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2084 ///
2085 /// # Example
2086 /// ```
2087 /// # use google_cloud_kms_v1::client::KeyManagementService;
2088 /// use google_cloud_kms_v1::Result;
2089 /// async fn sample(
2090 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str, crypto_key_version_id: &str
2091 /// ) -> Result<()> {
2092 /// let response = client.get_crypto_key_version()
2093 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}/cryptoKeyVersions/{crypto_key_version_id}"))
2094 /// .send().await?;
2095 /// println!("response {:?}", response);
2096 /// Ok(())
2097 /// }
2098 /// ```
2099 pub fn get_crypto_key_version(
2100 &self,
2101 ) -> super::builder::key_management_service::GetCryptoKeyVersion {
2102 super::builder::key_management_service::GetCryptoKeyVersion::new(self.inner.clone())
2103 }
2104
2105 /// Returns the public key for the given
2106 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. The
2107 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
2108 /// [ASYMMETRIC_SIGN][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN]
2109 /// or
2110 /// [ASYMMETRIC_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT].
2111 ///
2112 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::AsymmetricDecrypt
2113 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN]: crate::model::crypto_key::CryptoKeyPurpose::AsymmetricSign
2114 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2115 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2116 ///
2117 /// # Example
2118 /// ```
2119 /// # use google_cloud_kms_v1::client::KeyManagementService;
2120 /// use google_cloud_kms_v1::Result;
2121 /// async fn sample(
2122 /// client: &KeyManagementService
2123 /// ) -> Result<()> {
2124 /// let response = client.get_public_key()
2125 /// /* set fields */
2126 /// .send().await?;
2127 /// println!("response {:?}", response);
2128 /// Ok(())
2129 /// }
2130 /// ```
2131 pub fn get_public_key(&self) -> super::builder::key_management_service::GetPublicKey {
2132 super::builder::key_management_service::GetPublicKey::new(self.inner.clone())
2133 }
2134
2135 /// Returns metadata for a given [ImportJob][google.cloud.kms.v1.ImportJob].
2136 ///
2137 /// [google.cloud.kms.v1.ImportJob]: crate::model::ImportJob
2138 ///
2139 /// # Example
2140 /// ```
2141 /// # use google_cloud_kms_v1::client::KeyManagementService;
2142 /// use google_cloud_kms_v1::Result;
2143 /// async fn sample(
2144 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, import_job_id: &str
2145 /// ) -> Result<()> {
2146 /// let response = client.get_import_job()
2147 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/importJobs/{import_job_id}"))
2148 /// .send().await?;
2149 /// println!("response {:?}", response);
2150 /// Ok(())
2151 /// }
2152 /// ```
2153 pub fn get_import_job(&self) -> super::builder::key_management_service::GetImportJob {
2154 super::builder::key_management_service::GetImportJob::new(self.inner.clone())
2155 }
2156
2157 /// Retrieves a specific [RetiredResource][google.cloud.kms.v1.RetiredResource]
2158 /// resource, which represents the record of a deleted
2159 /// [CryptoKey][google.cloud.kms.v1.CryptoKey].
2160 ///
2161 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2162 /// [google.cloud.kms.v1.RetiredResource]: crate::model::RetiredResource
2163 ///
2164 /// # Example
2165 /// ```
2166 /// # use google_cloud_kms_v1::client::KeyManagementService;
2167 /// use google_cloud_kms_v1::Result;
2168 /// async fn sample(
2169 /// client: &KeyManagementService, project_id: &str, location_id: &str, retired_resource_id: &str
2170 /// ) -> Result<()> {
2171 /// let response = client.get_retired_resource()
2172 /// .set_name(format!("projects/{project_id}/locations/{location_id}/retiredResources/{retired_resource_id}"))
2173 /// .send().await?;
2174 /// println!("response {:?}", response);
2175 /// Ok(())
2176 /// }
2177 /// ```
2178 pub fn get_retired_resource(
2179 &self,
2180 ) -> super::builder::key_management_service::GetRetiredResource {
2181 super::builder::key_management_service::GetRetiredResource::new(self.inner.clone())
2182 }
2183
2184 /// Create a new [KeyRing][google.cloud.kms.v1.KeyRing] in a given Project and
2185 /// Location.
2186 ///
2187 /// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
2188 ///
2189 /// # Example
2190 /// ```
2191 /// # use google_cloud_kms_v1::client::KeyManagementService;
2192 /// use google_cloud_kms_v1::model::KeyRing;
2193 /// use google_cloud_kms_v1::Result;
2194 /// async fn sample(
2195 /// client: &KeyManagementService, parent: &str
2196 /// ) -> Result<()> {
2197 /// let response = client.create_key_ring()
2198 /// .set_parent(parent)
2199 /// .set_key_ring(
2200 /// KeyRing::new()/* set fields */
2201 /// )
2202 /// .send().await?;
2203 /// println!("response {:?}", response);
2204 /// Ok(())
2205 /// }
2206 /// ```
2207 pub fn create_key_ring(&self) -> super::builder::key_management_service::CreateKeyRing {
2208 super::builder::key_management_service::CreateKeyRing::new(self.inner.clone())
2209 }
2210
2211 /// Create a new [CryptoKey][google.cloud.kms.v1.CryptoKey] within a
2212 /// [KeyRing][google.cloud.kms.v1.KeyRing].
2213 ///
2214 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] and
2215 /// [CryptoKey.version_template.algorithm][google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]
2216 /// are required.
2217 ///
2218 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2219 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2220 /// [google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm]: crate::model::CryptoKeyVersionTemplate::algorithm
2221 /// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
2222 ///
2223 /// # Example
2224 /// ```
2225 /// # use google_cloud_kms_v1::client::KeyManagementService;
2226 /// use google_cloud_kms_v1::model::CryptoKey;
2227 /// use google_cloud_kms_v1::Result;
2228 /// async fn sample(
2229 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str
2230 /// ) -> Result<()> {
2231 /// let response = client.create_crypto_key()
2232 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}"))
2233 /// .set_crypto_key(
2234 /// CryptoKey::new()/* set fields */
2235 /// )
2236 /// .send().await?;
2237 /// println!("response {:?}", response);
2238 /// Ok(())
2239 /// }
2240 /// ```
2241 pub fn create_crypto_key(&self) -> super::builder::key_management_service::CreateCryptoKey {
2242 super::builder::key_management_service::CreateCryptoKey::new(self.inner.clone())
2243 }
2244
2245 /// Create a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in a
2246 /// [CryptoKey][google.cloud.kms.v1.CryptoKey].
2247 ///
2248 /// The server will assign the next sequential id. If unset,
2249 /// [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2250 /// [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED].
2251 ///
2252 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2253 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2254 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED]: crate::model::crypto_key_version::CryptoKeyVersionState::Enabled
2255 /// [google.cloud.kms.v1.CryptoKeyVersion.state]: crate::model::CryptoKeyVersion::state
2256 ///
2257 /// # Example
2258 /// ```
2259 /// # use google_cloud_kms_v1::client::KeyManagementService;
2260 /// use google_cloud_kms_v1::model::CryptoKeyVersion;
2261 /// use google_cloud_kms_v1::Result;
2262 /// async fn sample(
2263 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str
2264 /// ) -> Result<()> {
2265 /// let response = client.create_crypto_key_version()
2266 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}"))
2267 /// .set_crypto_key_version(
2268 /// CryptoKeyVersion::new()/* set fields */
2269 /// )
2270 /// .send().await?;
2271 /// println!("response {:?}", response);
2272 /// Ok(())
2273 /// }
2274 /// ```
2275 pub fn create_crypto_key_version(
2276 &self,
2277 ) -> super::builder::key_management_service::CreateCryptoKeyVersion {
2278 super::builder::key_management_service::CreateCryptoKeyVersion::new(self.inner.clone())
2279 }
2280
2281 /// Permanently deletes the given [CryptoKey][google.cloud.kms.v1.CryptoKey].
2282 /// All child [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion] must
2283 /// have been previously deleted using
2284 /// [KeyManagementService.DeleteCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DeleteCryptoKeyVersion].
2285 /// The specified crypto key will be immediately and permanently deleted upon
2286 /// calling this method. This action cannot be undone.
2287 ///
2288 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2289 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2290 /// [google.cloud.kms.v1.KeyManagementService.DeleteCryptoKeyVersion]: crate::client::KeyManagementService::delete_crypto_key_version
2291 ///
2292 /// # Long running operations
2293 ///
2294 /// This method is used to start, and/or poll a [long-running Operation].
2295 /// The [Working with long-running operations] chapter in the [user guide]
2296 /// covers these operations in detail.
2297 ///
2298 /// [long-running operation]: https://google.aip.dev/151
2299 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2300 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2301 ///
2302 /// # Example
2303 /// ```
2304 /// # use google_cloud_kms_v1::client::KeyManagementService;
2305 /// use google_cloud_lro::Poller;
2306 /// use google_cloud_kms_v1::Result;
2307 /// async fn sample(
2308 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str
2309 /// ) -> Result<()> {
2310 /// client.delete_crypto_key()
2311 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}"))
2312 /// .poller().until_done().await?;
2313 /// Ok(())
2314 /// }
2315 /// ```
2316 pub fn delete_crypto_key(&self) -> super::builder::key_management_service::DeleteCryptoKey {
2317 super::builder::key_management_service::DeleteCryptoKey::new(self.inner.clone())
2318 }
2319
2320 /// Permanently deletes the given
2321 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. Only possible if
2322 /// the version has not been previously imported and if its
2323 /// [state][google.cloud.kms.v1.CryptoKeyVersion.state] is one of
2324 /// [DESTROYED][CryptoKeyVersionState.DESTROYED],
2325 /// [IMPORT_FAILED][CryptoKeyVersionState.IMPORT_FAILED], or
2326 /// [GENERATION_FAILED][CryptoKeyVersionState.GENERATION_FAILED].
2327 /// Successfully imported
2328 /// [CryptoKeyVersions][google.cloud.kms.v1.CryptoKeyVersion] cannot be deleted
2329 /// at this time. The specified version will be immediately and permanently
2330 /// deleted upon calling this method. This action cannot be undone.
2331 ///
2332 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2333 /// [google.cloud.kms.v1.CryptoKeyVersion.state]: crate::model::CryptoKeyVersion::state
2334 ///
2335 /// # Long running operations
2336 ///
2337 /// This method is used to start, and/or poll a [long-running Operation].
2338 /// The [Working with long-running operations] chapter in the [user guide]
2339 /// covers these operations in detail.
2340 ///
2341 /// [long-running operation]: https://google.aip.dev/151
2342 /// [user guide]: https://googleapis.github.io/google-cloud-rust/
2343 /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
2344 ///
2345 /// # Example
2346 /// ```
2347 /// # use google_cloud_kms_v1::client::KeyManagementService;
2348 /// use google_cloud_lro::Poller;
2349 /// use google_cloud_kms_v1::Result;
2350 /// async fn sample(
2351 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str, crypto_key_version_id: &str
2352 /// ) -> Result<()> {
2353 /// client.delete_crypto_key_version()
2354 /// .set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}/cryptoKeyVersions/{crypto_key_version_id}"))
2355 /// .poller().until_done().await?;
2356 /// Ok(())
2357 /// }
2358 /// ```
2359 pub fn delete_crypto_key_version(
2360 &self,
2361 ) -> super::builder::key_management_service::DeleteCryptoKeyVersion {
2362 super::builder::key_management_service::DeleteCryptoKeyVersion::new(self.inner.clone())
2363 }
2364
2365 /// Import wrapped key material into a
2366 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion].
2367 ///
2368 /// All requests must specify a [CryptoKey][google.cloud.kms.v1.CryptoKey]. If
2369 /// a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] is additionally
2370 /// specified in the request, key material will be reimported into that
2371 /// version. Otherwise, a new version will be created, and will be assigned the
2372 /// next sequential id within the [CryptoKey][google.cloud.kms.v1.CryptoKey].
2373 ///
2374 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2375 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2376 ///
2377 /// # Example
2378 /// ```
2379 /// # use google_cloud_kms_v1::client::KeyManagementService;
2380 /// use google_cloud_kms_v1::Result;
2381 /// async fn sample(
2382 /// client: &KeyManagementService
2383 /// ) -> Result<()> {
2384 /// let response = client.import_crypto_key_version()
2385 /// /* set fields */
2386 /// .send().await?;
2387 /// println!("response {:?}", response);
2388 /// Ok(())
2389 /// }
2390 /// ```
2391 pub fn import_crypto_key_version(
2392 &self,
2393 ) -> super::builder::key_management_service::ImportCryptoKeyVersion {
2394 super::builder::key_management_service::ImportCryptoKeyVersion::new(self.inner.clone())
2395 }
2396
2397 /// Create a new [ImportJob][google.cloud.kms.v1.ImportJob] within a
2398 /// [KeyRing][google.cloud.kms.v1.KeyRing].
2399 ///
2400 /// [ImportJob.import_method][google.cloud.kms.v1.ImportJob.import_method] is
2401 /// required.
2402 ///
2403 /// [google.cloud.kms.v1.ImportJob]: crate::model::ImportJob
2404 /// [google.cloud.kms.v1.ImportJob.import_method]: crate::model::ImportJob::import_method
2405 /// [google.cloud.kms.v1.KeyRing]: crate::model::KeyRing
2406 ///
2407 /// # Example
2408 /// ```
2409 /// # use google_cloud_kms_v1::client::KeyManagementService;
2410 /// use google_cloud_kms_v1::model::ImportJob;
2411 /// use google_cloud_kms_v1::Result;
2412 /// async fn sample(
2413 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str
2414 /// ) -> Result<()> {
2415 /// let response = client.create_import_job()
2416 /// .set_parent(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}"))
2417 /// .set_import_job(
2418 /// ImportJob::new()/* set fields */
2419 /// )
2420 /// .send().await?;
2421 /// println!("response {:?}", response);
2422 /// Ok(())
2423 /// }
2424 /// ```
2425 pub fn create_import_job(&self) -> super::builder::key_management_service::CreateImportJob {
2426 super::builder::key_management_service::CreateImportJob::new(self.inner.clone())
2427 }
2428
2429 /// Update a [CryptoKey][google.cloud.kms.v1.CryptoKey].
2430 ///
2431 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2432 ///
2433 /// # Example
2434 /// ```
2435 /// # use google_cloud_kms_v1::client::KeyManagementService;
2436 /// # extern crate wkt as google_cloud_wkt;
2437 /// use google_cloud_wkt::FieldMask;
2438 /// use google_cloud_kms_v1::model::CryptoKey;
2439 /// use google_cloud_kms_v1::Result;
2440 /// async fn sample(
2441 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str
2442 /// ) -> Result<()> {
2443 /// let response = client.update_crypto_key()
2444 /// .set_crypto_key(
2445 /// CryptoKey::new().set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}"))/* set fields */
2446 /// )
2447 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2448 /// .send().await?;
2449 /// println!("response {:?}", response);
2450 /// Ok(())
2451 /// }
2452 /// ```
2453 pub fn update_crypto_key(&self) -> super::builder::key_management_service::UpdateCryptoKey {
2454 super::builder::key_management_service::UpdateCryptoKey::new(self.inner.clone())
2455 }
2456
2457 /// Update a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]'s
2458 /// metadata.
2459 ///
2460 /// [state][google.cloud.kms.v1.CryptoKeyVersion.state] may be changed between
2461 /// [ENABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED]
2462 /// and
2463 /// [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED]
2464 /// using this method. See
2465 /// [DestroyCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion]
2466 /// and
2467 /// [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion]
2468 /// to move between other states.
2469 ///
2470 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2471 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED]: crate::model::crypto_key_version::CryptoKeyVersionState::Disabled
2472 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED]: crate::model::crypto_key_version::CryptoKeyVersionState::Enabled
2473 /// [google.cloud.kms.v1.CryptoKeyVersion.state]: crate::model::CryptoKeyVersion::state
2474 /// [google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion]: crate::client::KeyManagementService::destroy_crypto_key_version
2475 /// [google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion]: crate::client::KeyManagementService::restore_crypto_key_version
2476 ///
2477 /// # Example
2478 /// ```
2479 /// # use google_cloud_kms_v1::client::KeyManagementService;
2480 /// # extern crate wkt as google_cloud_wkt;
2481 /// use google_cloud_wkt::FieldMask;
2482 /// use google_cloud_kms_v1::model::CryptoKeyVersion;
2483 /// use google_cloud_kms_v1::Result;
2484 /// async fn sample(
2485 /// client: &KeyManagementService, project_id: &str, location_id: &str, key_ring_id: &str, crypto_key_id: &str, crypto_key_version_id: &str
2486 /// ) -> Result<()> {
2487 /// let response = client.update_crypto_key_version()
2488 /// .set_crypto_key_version(
2489 /// CryptoKeyVersion::new().set_name(format!("projects/{project_id}/locations/{location_id}/keyRings/{key_ring_id}/cryptoKeys/{crypto_key_id}/cryptoKeyVersions/{crypto_key_version_id}"))/* set fields */
2490 /// )
2491 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2492 /// .send().await?;
2493 /// println!("response {:?}", response);
2494 /// Ok(())
2495 /// }
2496 /// ```
2497 pub fn update_crypto_key_version(
2498 &self,
2499 ) -> super::builder::key_management_service::UpdateCryptoKeyVersion {
2500 super::builder::key_management_service::UpdateCryptoKeyVersion::new(self.inner.clone())
2501 }
2502
2503 /// Update the version of a [CryptoKey][google.cloud.kms.v1.CryptoKey] that
2504 /// will be used in
2505 /// [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt].
2506 ///
2507 /// Returns an error if called on a key whose purpose is not
2508 /// [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2509 ///
2510 /// [google.cloud.kms.v1.CryptoKey]: crate::model::CryptoKey
2511 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::EncryptDecrypt
2512 /// [google.cloud.kms.v1.KeyManagementService.Encrypt]: crate::client::KeyManagementService::encrypt
2513 ///
2514 /// # Example
2515 /// ```
2516 /// # use google_cloud_kms_v1::client::KeyManagementService;
2517 /// use google_cloud_kms_v1::Result;
2518 /// async fn sample(
2519 /// client: &KeyManagementService
2520 /// ) -> Result<()> {
2521 /// let response = client.update_crypto_key_primary_version()
2522 /// /* set fields */
2523 /// .send().await?;
2524 /// println!("response {:?}", response);
2525 /// Ok(())
2526 /// }
2527 /// ```
2528 pub fn update_crypto_key_primary_version(
2529 &self,
2530 ) -> super::builder::key_management_service::UpdateCryptoKeyPrimaryVersion {
2531 super::builder::key_management_service::UpdateCryptoKeyPrimaryVersion::new(
2532 self.inner.clone(),
2533 )
2534 }
2535
2536 /// Schedule a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] for
2537 /// destruction.
2538 ///
2539 /// Upon calling this method,
2540 /// [CryptoKeyVersion.state][google.cloud.kms.v1.CryptoKeyVersion.state] will
2541 /// be set to
2542 /// [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED],
2543 /// and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will
2544 /// be set to the time
2545 /// [destroy_scheduled_duration][google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration]
2546 /// in the future. At that time, the
2547 /// [state][google.cloud.kms.v1.CryptoKeyVersion.state] will automatically
2548 /// change to
2549 /// [DESTROYED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED],
2550 /// and the key material will be irrevocably destroyed.
2551 ///
2552 /// Before the
2553 /// [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] is
2554 /// reached,
2555 /// [RestoreCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion]
2556 /// may be called to reverse the process.
2557 ///
2558 /// [google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration]: crate::model::CryptoKey::destroy_scheduled_duration
2559 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2560 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED]: crate::model::crypto_key_version::CryptoKeyVersionState::Destroyed
2561 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]: crate::model::crypto_key_version::CryptoKeyVersionState::DestroyScheduled
2562 /// [google.cloud.kms.v1.CryptoKeyVersion.destroy_time]: crate::model::CryptoKeyVersion::destroy_time
2563 /// [google.cloud.kms.v1.CryptoKeyVersion.state]: crate::model::CryptoKeyVersion::state
2564 /// [google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion]: crate::client::KeyManagementService::restore_crypto_key_version
2565 ///
2566 /// # Example
2567 /// ```
2568 /// # use google_cloud_kms_v1::client::KeyManagementService;
2569 /// use google_cloud_kms_v1::Result;
2570 /// async fn sample(
2571 /// client: &KeyManagementService
2572 /// ) -> Result<()> {
2573 /// let response = client.destroy_crypto_key_version()
2574 /// /* set fields */
2575 /// .send().await?;
2576 /// println!("response {:?}", response);
2577 /// Ok(())
2578 /// }
2579 /// ```
2580 pub fn destroy_crypto_key_version(
2581 &self,
2582 ) -> super::builder::key_management_service::DestroyCryptoKeyVersion {
2583 super::builder::key_management_service::DestroyCryptoKeyVersion::new(self.inner.clone())
2584 }
2585
2586 /// Restore a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] in the
2587 /// [DESTROY_SCHEDULED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]
2588 /// state.
2589 ///
2590 /// Upon restoration of the CryptoKeyVersion,
2591 /// [state][google.cloud.kms.v1.CryptoKeyVersion.state] will be set to
2592 /// [DISABLED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED],
2593 /// and [destroy_time][google.cloud.kms.v1.CryptoKeyVersion.destroy_time] will
2594 /// be cleared.
2595 ///
2596 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2597 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED]: crate::model::crypto_key_version::CryptoKeyVersionState::DestroyScheduled
2598 /// [google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED]: crate::model::crypto_key_version::CryptoKeyVersionState::Disabled
2599 /// [google.cloud.kms.v1.CryptoKeyVersion.destroy_time]: crate::model::CryptoKeyVersion::destroy_time
2600 /// [google.cloud.kms.v1.CryptoKeyVersion.state]: crate::model::CryptoKeyVersion::state
2601 ///
2602 /// # Example
2603 /// ```
2604 /// # use google_cloud_kms_v1::client::KeyManagementService;
2605 /// use google_cloud_kms_v1::Result;
2606 /// async fn sample(
2607 /// client: &KeyManagementService
2608 /// ) -> Result<()> {
2609 /// let response = client.restore_crypto_key_version()
2610 /// /* set fields */
2611 /// .send().await?;
2612 /// println!("response {:?}", response);
2613 /// Ok(())
2614 /// }
2615 /// ```
2616 pub fn restore_crypto_key_version(
2617 &self,
2618 ) -> super::builder::key_management_service::RestoreCryptoKeyVersion {
2619 super::builder::key_management_service::RestoreCryptoKeyVersion::new(self.inner.clone())
2620 }
2621
2622 /// Encrypts data, so that it can only be recovered by a call to
2623 /// [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt]. The
2624 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
2625 /// [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2626 ///
2627 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::EncryptDecrypt
2628 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2629 /// [google.cloud.kms.v1.KeyManagementService.Decrypt]: crate::client::KeyManagementService::decrypt
2630 ///
2631 /// # Example
2632 /// ```
2633 /// # use google_cloud_kms_v1::client::KeyManagementService;
2634 /// use google_cloud_kms_v1::Result;
2635 /// async fn sample(
2636 /// client: &KeyManagementService
2637 /// ) -> Result<()> {
2638 /// let response = client.encrypt()
2639 /// /* set fields */
2640 /// .send().await?;
2641 /// println!("response {:?}", response);
2642 /// Ok(())
2643 /// }
2644 /// ```
2645 pub fn encrypt(&self) -> super::builder::key_management_service::Encrypt {
2646 super::builder::key_management_service::Encrypt::new(self.inner.clone())
2647 }
2648
2649 /// Decrypts data that was protected by
2650 /// [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt]. The
2651 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
2652 /// [ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT].
2653 ///
2654 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::EncryptDecrypt
2655 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2656 /// [google.cloud.kms.v1.KeyManagementService.Encrypt]: crate::client::KeyManagementService::encrypt
2657 ///
2658 /// # Example
2659 /// ```
2660 /// # use google_cloud_kms_v1::client::KeyManagementService;
2661 /// use google_cloud_kms_v1::Result;
2662 /// async fn sample(
2663 /// client: &KeyManagementService
2664 /// ) -> Result<()> {
2665 /// let response = client.decrypt()
2666 /// /* set fields */
2667 /// .send().await?;
2668 /// println!("response {:?}", response);
2669 /// Ok(())
2670 /// }
2671 /// ```
2672 pub fn decrypt(&self) -> super::builder::key_management_service::Decrypt {
2673 super::builder::key_management_service::Decrypt::new(self.inner.clone())
2674 }
2675
2676 /// Encrypts data using portable cryptographic primitives. Most users should
2677 /// choose [Encrypt][google.cloud.kms.v1.KeyManagementService.Encrypt] and
2678 /// [Decrypt][google.cloud.kms.v1.KeyManagementService.Decrypt] rather than
2679 /// their raw counterparts. The
2680 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] must be
2681 /// [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT].
2682 ///
2683 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::RawEncryptDecrypt
2684 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2685 /// [google.cloud.kms.v1.KeyManagementService.Decrypt]: crate::client::KeyManagementService::decrypt
2686 /// [google.cloud.kms.v1.KeyManagementService.Encrypt]: crate::client::KeyManagementService::encrypt
2687 ///
2688 /// # Example
2689 /// ```
2690 /// # use google_cloud_kms_v1::client::KeyManagementService;
2691 /// use google_cloud_kms_v1::Result;
2692 /// async fn sample(
2693 /// client: &KeyManagementService
2694 /// ) -> Result<()> {
2695 /// let response = client.raw_encrypt()
2696 /// /* set fields */
2697 /// .send().await?;
2698 /// println!("response {:?}", response);
2699 /// Ok(())
2700 /// }
2701 /// ```
2702 pub fn raw_encrypt(&self) -> super::builder::key_management_service::RawEncrypt {
2703 super::builder::key_management_service::RawEncrypt::new(self.inner.clone())
2704 }
2705
2706 /// Decrypts data that was originally encrypted using a raw cryptographic
2707 /// mechanism. The [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
2708 /// must be
2709 /// [RAW_ENCRYPT_DECRYPT][google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT].
2710 ///
2711 /// [google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT]: crate::model::crypto_key::CryptoKeyPurpose::RawEncryptDecrypt
2712 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2713 ///
2714 /// # Example
2715 /// ```
2716 /// # use google_cloud_kms_v1::client::KeyManagementService;
2717 /// use google_cloud_kms_v1::Result;
2718 /// async fn sample(
2719 /// client: &KeyManagementService
2720 /// ) -> Result<()> {
2721 /// let response = client.raw_decrypt()
2722 /// /* set fields */
2723 /// .send().await?;
2724 /// println!("response {:?}", response);
2725 /// Ok(())
2726 /// }
2727 /// ```
2728 pub fn raw_decrypt(&self) -> super::builder::key_management_service::RawDecrypt {
2729 super::builder::key_management_service::RawDecrypt::new(self.inner.clone())
2730 }
2731
2732 /// Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
2733 /// with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
2734 /// ASYMMETRIC_SIGN, producing a signature that can be verified with the public
2735 /// key retrieved from
2736 /// [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
2737 ///
2738 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2739 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2740 /// [google.cloud.kms.v1.KeyManagementService.GetPublicKey]: crate::client::KeyManagementService::get_public_key
2741 ///
2742 /// # Example
2743 /// ```
2744 /// # use google_cloud_kms_v1::client::KeyManagementService;
2745 /// use google_cloud_kms_v1::Result;
2746 /// async fn sample(
2747 /// client: &KeyManagementService
2748 /// ) -> Result<()> {
2749 /// let response = client.asymmetric_sign()
2750 /// /* set fields */
2751 /// .send().await?;
2752 /// println!("response {:?}", response);
2753 /// Ok(())
2754 /// }
2755 /// ```
2756 pub fn asymmetric_sign(&self) -> super::builder::key_management_service::AsymmetricSign {
2757 super::builder::key_management_service::AsymmetricSign::new(self.inner.clone())
2758 }
2759
2760 /// Decrypts data that was encrypted with a public key retrieved from
2761 /// [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]
2762 /// corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
2763 /// with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
2764 /// ASYMMETRIC_DECRYPT.
2765 ///
2766 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2767 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2768 /// [google.cloud.kms.v1.KeyManagementService.GetPublicKey]: crate::client::KeyManagementService::get_public_key
2769 ///
2770 /// # Example
2771 /// ```
2772 /// # use google_cloud_kms_v1::client::KeyManagementService;
2773 /// use google_cloud_kms_v1::Result;
2774 /// async fn sample(
2775 /// client: &KeyManagementService
2776 /// ) -> Result<()> {
2777 /// let response = client.asymmetric_decrypt()
2778 /// /* set fields */
2779 /// .send().await?;
2780 /// println!("response {:?}", response);
2781 /// Ok(())
2782 /// }
2783 /// ```
2784 pub fn asymmetric_decrypt(&self) -> super::builder::key_management_service::AsymmetricDecrypt {
2785 super::builder::key_management_service::AsymmetricDecrypt::new(self.inner.clone())
2786 }
2787
2788 /// Signs data using a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
2789 /// with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC,
2790 /// producing a tag that can be verified by another source with the same key.
2791 ///
2792 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2793 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2794 ///
2795 /// # Example
2796 /// ```
2797 /// # use google_cloud_kms_v1::client::KeyManagementService;
2798 /// use google_cloud_kms_v1::Result;
2799 /// async fn sample(
2800 /// client: &KeyManagementService
2801 /// ) -> Result<()> {
2802 /// let response = client.mac_sign()
2803 /// /* set fields */
2804 /// .send().await?;
2805 /// println!("response {:?}", response);
2806 /// Ok(())
2807 /// }
2808 /// ```
2809 pub fn mac_sign(&self) -> super::builder::key_management_service::MacSign {
2810 super::builder::key_management_service::MacSign::new(self.inner.clone())
2811 }
2812
2813 /// Verifies MAC tag using a
2814 /// [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] with
2815 /// [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose] MAC, and returns
2816 /// a response that indicates whether or not the verification was successful.
2817 ///
2818 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2819 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2820 ///
2821 /// # Example
2822 /// ```
2823 /// # use google_cloud_kms_v1::client::KeyManagementService;
2824 /// use google_cloud_kms_v1::Result;
2825 /// async fn sample(
2826 /// client: &KeyManagementService
2827 /// ) -> Result<()> {
2828 /// let response = client.mac_verify()
2829 /// /* set fields */
2830 /// .send().await?;
2831 /// println!("response {:?}", response);
2832 /// Ok(())
2833 /// }
2834 /// ```
2835 pub fn mac_verify(&self) -> super::builder::key_management_service::MacVerify {
2836 super::builder::key_management_service::MacVerify::new(self.inner.clone())
2837 }
2838
2839 /// Decapsulates data that was encapsulated with a public key retrieved from
2840 /// [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey]
2841 /// corresponding to a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]
2842 /// with [CryptoKey.purpose][google.cloud.kms.v1.CryptoKey.purpose]
2843 /// KEY_ENCAPSULATION.
2844 ///
2845 /// [google.cloud.kms.v1.CryptoKey.purpose]: crate::model::CryptoKey::purpose
2846 /// [google.cloud.kms.v1.CryptoKeyVersion]: crate::model::CryptoKeyVersion
2847 /// [google.cloud.kms.v1.KeyManagementService.GetPublicKey]: crate::client::KeyManagementService::get_public_key
2848 ///
2849 /// # Example
2850 /// ```
2851 /// # use google_cloud_kms_v1::client::KeyManagementService;
2852 /// use google_cloud_kms_v1::Result;
2853 /// async fn sample(
2854 /// client: &KeyManagementService
2855 /// ) -> Result<()> {
2856 /// let response = client.decapsulate()
2857 /// /* set fields */
2858 /// .send().await?;
2859 /// println!("response {:?}", response);
2860 /// Ok(())
2861 /// }
2862 /// ```
2863 pub fn decapsulate(&self) -> super::builder::key_management_service::Decapsulate {
2864 super::builder::key_management_service::Decapsulate::new(self.inner.clone())
2865 }
2866
2867 /// Generate random bytes using the Cloud KMS randomness source in the provided
2868 /// location.
2869 ///
2870 /// # Example
2871 /// ```
2872 /// # use google_cloud_kms_v1::client::KeyManagementService;
2873 /// use google_cloud_kms_v1::Result;
2874 /// async fn sample(
2875 /// client: &KeyManagementService
2876 /// ) -> Result<()> {
2877 /// let response = client.generate_random_bytes()
2878 /// /* set fields */
2879 /// .send().await?;
2880 /// println!("response {:?}", response);
2881 /// Ok(())
2882 /// }
2883 /// ```
2884 pub fn generate_random_bytes(
2885 &self,
2886 ) -> super::builder::key_management_service::GenerateRandomBytes {
2887 super::builder::key_management_service::GenerateRandomBytes::new(self.inner.clone())
2888 }
2889
2890 /// Lists information about the supported locations for this service.
2891 ///
2892 /// This method lists locations based on the resource scope provided in
2893 /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
2894 /// **Global locations**: If `name` is empty, the method lists the
2895 /// public locations available to all projects. * **Project-specific
2896 /// locations**: If `name` follows the format
2897 /// `projects/{project}`, the method lists locations visible to that
2898 /// specific project. This includes public, private, or other
2899 /// project-specific locations enabled for the project.
2900 ///
2901 /// For gRPC and client library implementations, the resource name is
2902 /// passed as the `name` field. For direct service calls, the resource
2903 /// name is
2904 /// incorporated into the request path based on the specific service
2905 /// implementation and version.
2906 ///
2907 /// [google.cloud.location.ListLocationsRequest.name]: google_cloud_location::model::ListLocationsRequest::name
2908 ///
2909 /// # Example
2910 /// ```
2911 /// # use google_cloud_kms_v1::client::KeyManagementService;
2912 /// use google_cloud_gax::paginator::ItemPaginator as _;
2913 /// use google_cloud_kms_v1::Result;
2914 /// async fn sample(
2915 /// client: &KeyManagementService
2916 /// ) -> Result<()> {
2917 /// let mut list = client.list_locations()
2918 /// /* set fields */
2919 /// .by_item();
2920 /// while let Some(item) = list.next().await.transpose()? {
2921 /// println!("{:?}", item);
2922 /// }
2923 /// Ok(())
2924 /// }
2925 /// ```
2926 pub fn list_locations(&self) -> super::builder::key_management_service::ListLocations {
2927 super::builder::key_management_service::ListLocations::new(self.inner.clone())
2928 }
2929
2930 /// Gets information about a location.
2931 ///
2932 /// # Example
2933 /// ```
2934 /// # use google_cloud_kms_v1::client::KeyManagementService;
2935 /// use google_cloud_kms_v1::Result;
2936 /// async fn sample(
2937 /// client: &KeyManagementService
2938 /// ) -> Result<()> {
2939 /// let response = client.get_location()
2940 /// /* set fields */
2941 /// .send().await?;
2942 /// println!("response {:?}", response);
2943 /// Ok(())
2944 /// }
2945 /// ```
2946 pub fn get_location(&self) -> super::builder::key_management_service::GetLocation {
2947 super::builder::key_management_service::GetLocation::new(self.inner.clone())
2948 }
2949
2950 /// Sets the access control policy on the specified resource. Replaces
2951 /// any existing policy.
2952 ///
2953 /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
2954 /// errors.
2955 ///
2956 /// # Example
2957 /// ```
2958 /// # use google_cloud_kms_v1::client::KeyManagementService;
2959 /// use google_cloud_kms_v1::Result;
2960 /// async fn sample(
2961 /// client: &KeyManagementService
2962 /// ) -> Result<()> {
2963 /// let response = client.set_iam_policy()
2964 /// /* set fields */
2965 /// .send().await?;
2966 /// println!("response {:?}", response);
2967 /// Ok(())
2968 /// }
2969 /// ```
2970 pub fn set_iam_policy(&self) -> super::builder::key_management_service::SetIamPolicy {
2971 super::builder::key_management_service::SetIamPolicy::new(self.inner.clone())
2972 }
2973
2974 /// Gets the access control policy for a resource. Returns an empty policy
2975 /// if the resource exists and does not have a policy set.
2976 ///
2977 /// # Example
2978 /// ```
2979 /// # use google_cloud_kms_v1::client::KeyManagementService;
2980 /// use google_cloud_kms_v1::Result;
2981 /// async fn sample(
2982 /// client: &KeyManagementService
2983 /// ) -> Result<()> {
2984 /// let response = client.get_iam_policy()
2985 /// /* set fields */
2986 /// .send().await?;
2987 /// println!("response {:?}", response);
2988 /// Ok(())
2989 /// }
2990 /// ```
2991 pub fn get_iam_policy(&self) -> super::builder::key_management_service::GetIamPolicy {
2992 super::builder::key_management_service::GetIamPolicy::new(self.inner.clone())
2993 }
2994
2995 /// Returns permissions that a caller has on the specified resource. If the
2996 /// resource does not exist, this will return an empty set of
2997 /// permissions, not a `NOT_FOUND` error.
2998 ///
2999 /// Note: This operation is designed to be used for building
3000 /// permission-aware UIs and command-line tools, not for authorization
3001 /// checking. This operation may "fail open" without warning.
3002 ///
3003 /// # Example
3004 /// ```
3005 /// # use google_cloud_kms_v1::client::KeyManagementService;
3006 /// use google_cloud_kms_v1::Result;
3007 /// async fn sample(
3008 /// client: &KeyManagementService
3009 /// ) -> Result<()> {
3010 /// let response = client.test_iam_permissions()
3011 /// /* set fields */
3012 /// .send().await?;
3013 /// println!("response {:?}", response);
3014 /// Ok(())
3015 /// }
3016 /// ```
3017 pub fn test_iam_permissions(
3018 &self,
3019 ) -> super::builder::key_management_service::TestIamPermissions {
3020 super::builder::key_management_service::TestIamPermissions::new(self.inner.clone())
3021 }
3022
3023 /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
3024 ///
3025 /// [google.longrunning.Operations]: google-cloud-longrunning::client::Operations
3026 ///
3027 /// # Example
3028 /// ```
3029 /// # use google_cloud_kms_v1::client::KeyManagementService;
3030 /// use google_cloud_kms_v1::Result;
3031 /// async fn sample(
3032 /// client: &KeyManagementService
3033 /// ) -> Result<()> {
3034 /// let response = client.get_operation()
3035 /// /* set fields */
3036 /// .send().await?;
3037 /// println!("response {:?}", response);
3038 /// Ok(())
3039 /// }
3040 /// ```
3041 pub fn get_operation(&self) -> super::builder::key_management_service::GetOperation {
3042 super::builder::key_management_service::GetOperation::new(self.inner.clone())
3043 }
3044}