google_cloud_kms_inventory_v1/model.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
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_kms_v1;
25extern crate lazy_static;
26extern crate serde;
27extern crate serde_json;
28extern crate serde_with;
29extern crate std;
30extern crate tracing;
31extern crate wkt;
32
33mod debug;
34mod deserialize;
35mod serialize;
36
37/// Request message for
38/// [KeyDashboardService.ListCryptoKeys][google.cloud.kms.inventory.v1.KeyDashboardService.ListCryptoKeys].
39///
40/// [google.cloud.kms.inventory.v1.KeyDashboardService.ListCryptoKeys]: crate::client::KeyDashboardService::list_crypto_keys
41#[derive(Clone, Default, PartialEq)]
42#[non_exhaustive]
43pub struct ListCryptoKeysRequest {
44 /// Required. The Google Cloud project for which to retrieve key metadata, in
45 /// the format `projects/*`
46 pub parent: std::string::String,
47
48 /// Optional. The maximum number of keys to return. The service may return
49 /// fewer than this value. If unspecified, at most 1000 keys will be returned.
50 /// The maximum value is 1000; values above 1000 will be coerced to 1000.
51 pub page_size: i32,
52
53 /// Optional. Pass this into a subsequent request in order to receive the next
54 /// page of results.
55 pub page_token: std::string::String,
56
57 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
58}
59
60impl ListCryptoKeysRequest {
61 pub fn new() -> Self {
62 std::default::Default::default()
63 }
64
65 /// Sets the value of [parent][crate::model::ListCryptoKeysRequest::parent].
66 ///
67 /// # Example
68 /// ```ignore,no_run
69 /// # use google_cloud_kms_inventory_v1::model::ListCryptoKeysRequest;
70 /// let x = ListCryptoKeysRequest::new().set_parent("example");
71 /// ```
72 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
73 self.parent = v.into();
74 self
75 }
76
77 /// Sets the value of [page_size][crate::model::ListCryptoKeysRequest::page_size].
78 ///
79 /// # Example
80 /// ```ignore,no_run
81 /// # use google_cloud_kms_inventory_v1::model::ListCryptoKeysRequest;
82 /// let x = ListCryptoKeysRequest::new().set_page_size(42);
83 /// ```
84 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
85 self.page_size = v.into();
86 self
87 }
88
89 /// Sets the value of [page_token][crate::model::ListCryptoKeysRequest::page_token].
90 ///
91 /// # Example
92 /// ```ignore,no_run
93 /// # use google_cloud_kms_inventory_v1::model::ListCryptoKeysRequest;
94 /// let x = ListCryptoKeysRequest::new().set_page_token("example");
95 /// ```
96 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
97 self.page_token = v.into();
98 self
99 }
100}
101
102impl wkt::message::Message for ListCryptoKeysRequest {
103 fn typename() -> &'static str {
104 "type.googleapis.com/google.cloud.kms.inventory.v1.ListCryptoKeysRequest"
105 }
106}
107
108/// Response message for
109/// [KeyDashboardService.ListCryptoKeys][google.cloud.kms.inventory.v1.KeyDashboardService.ListCryptoKeys].
110///
111/// [google.cloud.kms.inventory.v1.KeyDashboardService.ListCryptoKeys]: crate::client::KeyDashboardService::list_crypto_keys
112#[derive(Clone, Default, PartialEq)]
113#[non_exhaustive]
114pub struct ListCryptoKeysResponse {
115 /// The list of [CryptoKeys][google.cloud.kms.v1.CryptoKey].
116 ///
117 /// [google.cloud.kms.v1.CryptoKey]: google_cloud_kms_v1::model::CryptoKey
118 pub crypto_keys: std::vec::Vec<google_cloud_kms_v1::model::CryptoKey>,
119
120 /// The page token returned from the previous response if the next page is
121 /// desired.
122 pub next_page_token: std::string::String,
123
124 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
125}
126
127impl ListCryptoKeysResponse {
128 pub fn new() -> Self {
129 std::default::Default::default()
130 }
131
132 /// Sets the value of [crypto_keys][crate::model::ListCryptoKeysResponse::crypto_keys].
133 ///
134 /// # Example
135 /// ```ignore,no_run
136 /// # use google_cloud_kms_inventory_v1::model::ListCryptoKeysResponse;
137 /// use google_cloud_kms_v1::model::CryptoKey;
138 /// let x = ListCryptoKeysResponse::new()
139 /// .set_crypto_keys([
140 /// CryptoKey::default()/* use setters */,
141 /// CryptoKey::default()/* use (different) setters */,
142 /// ]);
143 /// ```
144 pub fn set_crypto_keys<T, V>(mut self, v: T) -> Self
145 where
146 T: std::iter::IntoIterator<Item = V>,
147 V: std::convert::Into<google_cloud_kms_v1::model::CryptoKey>,
148 {
149 use std::iter::Iterator;
150 self.crypto_keys = v.into_iter().map(|i| i.into()).collect();
151 self
152 }
153
154 /// Sets the value of [next_page_token][crate::model::ListCryptoKeysResponse::next_page_token].
155 ///
156 /// # Example
157 /// ```ignore,no_run
158 /// # use google_cloud_kms_inventory_v1::model::ListCryptoKeysResponse;
159 /// let x = ListCryptoKeysResponse::new().set_next_page_token("example");
160 /// ```
161 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
162 self.next_page_token = v.into();
163 self
164 }
165}
166
167impl wkt::message::Message for ListCryptoKeysResponse {
168 fn typename() -> &'static str {
169 "type.googleapis.com/google.cloud.kms.inventory.v1.ListCryptoKeysResponse"
170 }
171}
172
173#[doc(hidden)]
174impl google_cloud_gax::paginator::internal::PageableResponse for ListCryptoKeysResponse {
175 type PageItem = google_cloud_kms_v1::model::CryptoKey;
176
177 fn items(self) -> std::vec::Vec<Self::PageItem> {
178 self.crypto_keys
179 }
180
181 fn next_page_token(&self) -> std::string::String {
182 use std::clone::Clone;
183 self.next_page_token.clone()
184 }
185}
186
187/// Request message for
188/// [KeyTrackingService.GetProtectedResourcesSummary][google.cloud.kms.inventory.v1.KeyTrackingService.GetProtectedResourcesSummary].
189///
190/// [google.cloud.kms.inventory.v1.KeyTrackingService.GetProtectedResourcesSummary]: crate::client::KeyTrackingService::get_protected_resources_summary
191#[derive(Clone, Default, PartialEq)]
192#[non_exhaustive]
193pub struct GetProtectedResourcesSummaryRequest {
194 /// Required. The resource name of the
195 /// [CryptoKey][google.cloud.kms.v1.CryptoKey].
196 ///
197 /// [google.cloud.kms.v1.CryptoKey]: google_cloud_kms_v1::model::CryptoKey
198 pub name: std::string::String,
199
200 /// Optional. The scope to use if the kms organization service account is not
201 /// configured.
202 pub fallback_scope: crate::model::FallbackScope,
203
204 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
205}
206
207impl GetProtectedResourcesSummaryRequest {
208 pub fn new() -> Self {
209 std::default::Default::default()
210 }
211
212 /// Sets the value of [name][crate::model::GetProtectedResourcesSummaryRequest::name].
213 ///
214 /// # Example
215 /// ```ignore,no_run
216 /// # use google_cloud_kms_inventory_v1::model::GetProtectedResourcesSummaryRequest;
217 /// let x = GetProtectedResourcesSummaryRequest::new().set_name("example");
218 /// ```
219 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
220 self.name = v.into();
221 self
222 }
223
224 /// Sets the value of [fallback_scope][crate::model::GetProtectedResourcesSummaryRequest::fallback_scope].
225 ///
226 /// # Example
227 /// ```ignore,no_run
228 /// # use google_cloud_kms_inventory_v1::model::GetProtectedResourcesSummaryRequest;
229 /// use google_cloud_kms_inventory_v1::model::FallbackScope;
230 /// let x0 = GetProtectedResourcesSummaryRequest::new().set_fallback_scope(FallbackScope::Project);
231 /// ```
232 pub fn set_fallback_scope<T: std::convert::Into<crate::model::FallbackScope>>(
233 mut self,
234 v: T,
235 ) -> Self {
236 self.fallback_scope = v.into();
237 self
238 }
239}
240
241impl wkt::message::Message for GetProtectedResourcesSummaryRequest {
242 fn typename() -> &'static str {
243 "type.googleapis.com/google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest"
244 }
245}
246
247/// Aggregate information about the resources protected by a Cloud KMS key in the
248/// same Cloud organization/project as the key.
249#[derive(Clone, Default, PartialEq)]
250#[non_exhaustive]
251pub struct ProtectedResourcesSummary {
252 /// The full name of the ProtectedResourcesSummary resource.
253 /// Example:
254 /// projects/test-project/locations/us/keyRings/test-keyring/cryptoKeys/test-key/protectedResourcesSummary
255 pub name: std::string::String,
256
257 /// The total number of protected resources in the same Cloud organization as
258 /// the key.
259 pub resource_count: i64,
260
261 /// The number of distinct Cloud projects in the same Cloud organization as the
262 /// key that have resources protected by the key.
263 pub project_count: i32,
264
265 /// The number of resources protected by the key grouped by resource type.
266 pub resource_types: std::collections::HashMap<std::string::String, i64>,
267
268 /// The number of resources protected by the key grouped by Cloud product.
269 pub cloud_products: std::collections::HashMap<std::string::String, i64>,
270
271 /// The number of resources protected by the key grouped by region.
272 pub locations: std::collections::HashMap<std::string::String, i64>,
273
274 /// Warning messages for the state of response
275 /// [ProtectedResourcesSummary][google.cloud.kms.inventory.v1.ProtectedResourcesSummary]
276 /// For example, if the organization service account is not configured,
277 /// INSUFFICIENT_PERMISSIONS_PARTIAL_DATA warning will be returned.
278 ///
279 /// [google.cloud.kms.inventory.v1.ProtectedResourcesSummary]: crate::model::ProtectedResourcesSummary
280 pub warnings: std::vec::Vec<crate::model::Warning>,
281
282 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
283}
284
285impl ProtectedResourcesSummary {
286 pub fn new() -> Self {
287 std::default::Default::default()
288 }
289
290 /// Sets the value of [name][crate::model::ProtectedResourcesSummary::name].
291 ///
292 /// # Example
293 /// ```ignore,no_run
294 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
295 /// let x = ProtectedResourcesSummary::new().set_name("example");
296 /// ```
297 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
298 self.name = v.into();
299 self
300 }
301
302 /// Sets the value of [resource_count][crate::model::ProtectedResourcesSummary::resource_count].
303 ///
304 /// # Example
305 /// ```ignore,no_run
306 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
307 /// let x = ProtectedResourcesSummary::new().set_resource_count(42);
308 /// ```
309 pub fn set_resource_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
310 self.resource_count = v.into();
311 self
312 }
313
314 /// Sets the value of [project_count][crate::model::ProtectedResourcesSummary::project_count].
315 ///
316 /// # Example
317 /// ```ignore,no_run
318 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
319 /// let x = ProtectedResourcesSummary::new().set_project_count(42);
320 /// ```
321 pub fn set_project_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
322 self.project_count = v.into();
323 self
324 }
325
326 /// Sets the value of [resource_types][crate::model::ProtectedResourcesSummary::resource_types].
327 ///
328 /// # Example
329 /// ```ignore,no_run
330 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
331 /// let x = ProtectedResourcesSummary::new().set_resource_types([
332 /// ("key0", 123),
333 /// ("key1", 456),
334 /// ]);
335 /// ```
336 pub fn set_resource_types<T, K, V>(mut self, v: T) -> Self
337 where
338 T: std::iter::IntoIterator<Item = (K, V)>,
339 K: std::convert::Into<std::string::String>,
340 V: std::convert::Into<i64>,
341 {
342 use std::iter::Iterator;
343 self.resource_types = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
344 self
345 }
346
347 /// Sets the value of [cloud_products][crate::model::ProtectedResourcesSummary::cloud_products].
348 ///
349 /// # Example
350 /// ```ignore,no_run
351 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
352 /// let x = ProtectedResourcesSummary::new().set_cloud_products([
353 /// ("key0", 123),
354 /// ("key1", 456),
355 /// ]);
356 /// ```
357 pub fn set_cloud_products<T, K, V>(mut self, v: T) -> Self
358 where
359 T: std::iter::IntoIterator<Item = (K, V)>,
360 K: std::convert::Into<std::string::String>,
361 V: std::convert::Into<i64>,
362 {
363 use std::iter::Iterator;
364 self.cloud_products = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
365 self
366 }
367
368 /// Sets the value of [locations][crate::model::ProtectedResourcesSummary::locations].
369 ///
370 /// # Example
371 /// ```ignore,no_run
372 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
373 /// let x = ProtectedResourcesSummary::new().set_locations([
374 /// ("key0", 123),
375 /// ("key1", 456),
376 /// ]);
377 /// ```
378 pub fn set_locations<T, K, V>(mut self, v: T) -> Self
379 where
380 T: std::iter::IntoIterator<Item = (K, V)>,
381 K: std::convert::Into<std::string::String>,
382 V: std::convert::Into<i64>,
383 {
384 use std::iter::Iterator;
385 self.locations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
386 self
387 }
388
389 /// Sets the value of [warnings][crate::model::ProtectedResourcesSummary::warnings].
390 ///
391 /// # Example
392 /// ```ignore,no_run
393 /// # use google_cloud_kms_inventory_v1::model::ProtectedResourcesSummary;
394 /// use google_cloud_kms_inventory_v1::model::Warning;
395 /// let x = ProtectedResourcesSummary::new()
396 /// .set_warnings([
397 /// Warning::default()/* use setters */,
398 /// Warning::default()/* use (different) setters */,
399 /// ]);
400 /// ```
401 pub fn set_warnings<T, V>(mut self, v: T) -> Self
402 where
403 T: std::iter::IntoIterator<Item = V>,
404 V: std::convert::Into<crate::model::Warning>,
405 {
406 use std::iter::Iterator;
407 self.warnings = v.into_iter().map(|i| i.into()).collect();
408 self
409 }
410}
411
412impl wkt::message::Message for ProtectedResourcesSummary {
413 fn typename() -> &'static str {
414 "type.googleapis.com/google.cloud.kms.inventory.v1.ProtectedResourcesSummary"
415 }
416}
417
418/// Request message for
419/// [KeyTrackingService.SearchProtectedResources][google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources].
420///
421/// [google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources]: crate::client::KeyTrackingService::search_protected_resources
422#[derive(Clone, Default, PartialEq)]
423#[non_exhaustive]
424pub struct SearchProtectedResourcesRequest {
425 /// Required. A scope can be an organization or a project. Resources protected
426 /// by the crypto key in provided scope will be returned.
427 ///
428 /// The following values are allowed:
429 ///
430 /// * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678")
431 /// * projects/{PROJECT_ID} (e.g., "projects/foo-bar")
432 /// * projects/{PROJECT_NUMBER} (e.g., "projects/12345678")
433 pub scope: std::string::String,
434
435 /// Required. The resource name of the
436 /// [CryptoKey][google.cloud.kms.v1.CryptoKey].
437 ///
438 /// [google.cloud.kms.v1.CryptoKey]: google_cloud_kms_v1::model::CryptoKey
439 pub crypto_key: std::string::String,
440
441 /// The maximum number of resources to return. The service may return fewer
442 /// than this value.
443 /// If unspecified, at most 500 resources will be returned.
444 /// The maximum value is 500; values above 500 will be coerced to 500.
445 pub page_size: i32,
446
447 /// A page token, received from a previous
448 /// [KeyTrackingService.SearchProtectedResources][google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources]
449 /// call. Provide this to retrieve the subsequent page.
450 ///
451 /// When paginating, all other parameters provided to
452 /// [KeyTrackingService.SearchProtectedResources][google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources]
453 /// must match the call that provided the page token.
454 ///
455 /// [google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources]: crate::client::KeyTrackingService::search_protected_resources
456 pub page_token: std::string::String,
457
458 /// Optional. A list of resource types that this request searches for. If
459 /// empty, it will search all the [trackable resource
460 /// types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types).
461 ///
462 /// Regular expressions are also supported. For example:
463 ///
464 /// * `compute.googleapis.com.*` snapshots resources whose type starts
465 /// with `compute.googleapis.com`.
466 /// * `.*Image` snapshots resources whose type ends with `Image`.
467 /// * `.*Image.*` snapshots resources whose type contains `Image`.
468 ///
469 /// See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported
470 /// regular expression syntax. If the regular expression does not match any
471 /// supported resource type, an INVALID_ARGUMENT error will be returned.
472 pub resource_types: std::vec::Vec<std::string::String>,
473
474 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
475}
476
477impl SearchProtectedResourcesRequest {
478 pub fn new() -> Self {
479 std::default::Default::default()
480 }
481
482 /// Sets the value of [scope][crate::model::SearchProtectedResourcesRequest::scope].
483 ///
484 /// # Example
485 /// ```ignore,no_run
486 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesRequest;
487 /// let x = SearchProtectedResourcesRequest::new().set_scope("example");
488 /// ```
489 pub fn set_scope<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
490 self.scope = v.into();
491 self
492 }
493
494 /// Sets the value of [crypto_key][crate::model::SearchProtectedResourcesRequest::crypto_key].
495 ///
496 /// # Example
497 /// ```ignore,no_run
498 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesRequest;
499 /// let x = SearchProtectedResourcesRequest::new().set_crypto_key("example");
500 /// ```
501 pub fn set_crypto_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
502 self.crypto_key = v.into();
503 self
504 }
505
506 /// Sets the value of [page_size][crate::model::SearchProtectedResourcesRequest::page_size].
507 ///
508 /// # Example
509 /// ```ignore,no_run
510 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesRequest;
511 /// let x = SearchProtectedResourcesRequest::new().set_page_size(42);
512 /// ```
513 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
514 self.page_size = v.into();
515 self
516 }
517
518 /// Sets the value of [page_token][crate::model::SearchProtectedResourcesRequest::page_token].
519 ///
520 /// # Example
521 /// ```ignore,no_run
522 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesRequest;
523 /// let x = SearchProtectedResourcesRequest::new().set_page_token("example");
524 /// ```
525 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
526 self.page_token = v.into();
527 self
528 }
529
530 /// Sets the value of [resource_types][crate::model::SearchProtectedResourcesRequest::resource_types].
531 ///
532 /// # Example
533 /// ```ignore,no_run
534 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesRequest;
535 /// let x = SearchProtectedResourcesRequest::new().set_resource_types(["a", "b", "c"]);
536 /// ```
537 pub fn set_resource_types<T, V>(mut self, v: T) -> Self
538 where
539 T: std::iter::IntoIterator<Item = V>,
540 V: std::convert::Into<std::string::String>,
541 {
542 use std::iter::Iterator;
543 self.resource_types = v.into_iter().map(|i| i.into()).collect();
544 self
545 }
546}
547
548impl wkt::message::Message for SearchProtectedResourcesRequest {
549 fn typename() -> &'static str {
550 "type.googleapis.com/google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest"
551 }
552}
553
554/// Response message for
555/// [KeyTrackingService.SearchProtectedResources][google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources].
556///
557/// [google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources]: crate::client::KeyTrackingService::search_protected_resources
558#[derive(Clone, Default, PartialEq)]
559#[non_exhaustive]
560pub struct SearchProtectedResourcesResponse {
561 /// Protected resources for this page.
562 pub protected_resources: std::vec::Vec<crate::model::ProtectedResource>,
563
564 /// A token that can be sent as `page_token` to retrieve the next page.
565 /// If this field is omitted, there are no subsequent pages.
566 pub next_page_token: std::string::String,
567
568 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
569}
570
571impl SearchProtectedResourcesResponse {
572 pub fn new() -> Self {
573 std::default::Default::default()
574 }
575
576 /// Sets the value of [protected_resources][crate::model::SearchProtectedResourcesResponse::protected_resources].
577 ///
578 /// # Example
579 /// ```ignore,no_run
580 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesResponse;
581 /// use google_cloud_kms_inventory_v1::model::ProtectedResource;
582 /// let x = SearchProtectedResourcesResponse::new()
583 /// .set_protected_resources([
584 /// ProtectedResource::default()/* use setters */,
585 /// ProtectedResource::default()/* use (different) setters */,
586 /// ]);
587 /// ```
588 pub fn set_protected_resources<T, V>(mut self, v: T) -> Self
589 where
590 T: std::iter::IntoIterator<Item = V>,
591 V: std::convert::Into<crate::model::ProtectedResource>,
592 {
593 use std::iter::Iterator;
594 self.protected_resources = v.into_iter().map(|i| i.into()).collect();
595 self
596 }
597
598 /// Sets the value of [next_page_token][crate::model::SearchProtectedResourcesResponse::next_page_token].
599 ///
600 /// # Example
601 /// ```ignore,no_run
602 /// # use google_cloud_kms_inventory_v1::model::SearchProtectedResourcesResponse;
603 /// let x = SearchProtectedResourcesResponse::new().set_next_page_token("example");
604 /// ```
605 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
606 self.next_page_token = v.into();
607 self
608 }
609}
610
611impl wkt::message::Message for SearchProtectedResourcesResponse {
612 fn typename() -> &'static str {
613 "type.googleapis.com/google.cloud.kms.inventory.v1.SearchProtectedResourcesResponse"
614 }
615}
616
617#[doc(hidden)]
618impl google_cloud_gax::paginator::internal::PageableResponse for SearchProtectedResourcesResponse {
619 type PageItem = crate::model::ProtectedResource;
620
621 fn items(self) -> std::vec::Vec<Self::PageItem> {
622 self.protected_resources
623 }
624
625 fn next_page_token(&self) -> std::string::String {
626 use std::clone::Clone;
627 self.next_page_token.clone()
628 }
629}
630
631/// Metadata about a resource protected by a Cloud KMS key.
632#[derive(Clone, Default, PartialEq)]
633#[non_exhaustive]
634pub struct ProtectedResource {
635 /// The full resource name of the resource.
636 /// Example:
637 /// `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
638 pub name: std::string::String,
639
640 /// Format: `projects/{PROJECT_NUMBER}`.
641 pub project: std::string::String,
642
643 /// The ID of the project that owns the resource.
644 pub project_id: std::string::String,
645
646 /// The Cloud product that owns the resource.
647 /// Example: `compute`
648 pub cloud_product: std::string::String,
649
650 /// Example: `compute.googleapis.com/Disk`
651 pub resource_type: std::string::String,
652
653 /// Location can be `global`, regional like `us-east1`, or zonal like
654 /// `us-west1-b`.
655 pub location: std::string::String,
656
657 /// A key-value pair of the resource's labels (v1) to their values.
658 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
659
660 /// The name of the Cloud KMS
661 /// [CryptoKeyVersion](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions?hl=en)
662 /// used to protect this resource via CMEK. This field is empty if the
663 /// Google Cloud product owning the resource does not provide key version data
664 /// to Asset Inventory. If there are multiple key versions protecting the
665 /// resource, then this is same value as the first element of
666 /// crypto_key_versions.
667 pub crypto_key_version: std::string::String,
668
669 /// The names of the Cloud KMS
670 /// [CryptoKeyVersion](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions?hl=en)
671 /// used to protect this resource via CMEK. This field is empty if the
672 /// Google Cloud product owning the resource does not provide key versions data
673 /// to Asset Inventory. The first element of this field is stored in
674 /// crypto_key_version.
675 pub crypto_key_versions: std::vec::Vec<std::string::String>,
676
677 /// Output only. The time at which this resource was created. The granularity
678 /// is in seconds. Timestamp.nanos will always be 0.
679 pub create_time: std::option::Option<wkt::Timestamp>,
680
681 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
682}
683
684impl ProtectedResource {
685 pub fn new() -> Self {
686 std::default::Default::default()
687 }
688
689 /// Sets the value of [name][crate::model::ProtectedResource::name].
690 ///
691 /// # Example
692 /// ```ignore,no_run
693 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
694 /// let x = ProtectedResource::new().set_name("example");
695 /// ```
696 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
697 self.name = v.into();
698 self
699 }
700
701 /// Sets the value of [project][crate::model::ProtectedResource::project].
702 ///
703 /// # Example
704 /// ```ignore,no_run
705 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
706 /// let x = ProtectedResource::new().set_project("example");
707 /// ```
708 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
709 self.project = v.into();
710 self
711 }
712
713 /// Sets the value of [project_id][crate::model::ProtectedResource::project_id].
714 ///
715 /// # Example
716 /// ```ignore,no_run
717 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
718 /// let x = ProtectedResource::new().set_project_id("example");
719 /// ```
720 pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
721 self.project_id = v.into();
722 self
723 }
724
725 /// Sets the value of [cloud_product][crate::model::ProtectedResource::cloud_product].
726 ///
727 /// # Example
728 /// ```ignore,no_run
729 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
730 /// let x = ProtectedResource::new().set_cloud_product("example");
731 /// ```
732 pub fn set_cloud_product<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
733 self.cloud_product = v.into();
734 self
735 }
736
737 /// Sets the value of [resource_type][crate::model::ProtectedResource::resource_type].
738 ///
739 /// # Example
740 /// ```ignore,no_run
741 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
742 /// let x = ProtectedResource::new().set_resource_type("example");
743 /// ```
744 pub fn set_resource_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
745 self.resource_type = v.into();
746 self
747 }
748
749 /// Sets the value of [location][crate::model::ProtectedResource::location].
750 ///
751 /// # Example
752 /// ```ignore,no_run
753 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
754 /// let x = ProtectedResource::new().set_location("example");
755 /// ```
756 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
757 self.location = v.into();
758 self
759 }
760
761 /// Sets the value of [labels][crate::model::ProtectedResource::labels].
762 ///
763 /// # Example
764 /// ```ignore,no_run
765 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
766 /// let x = ProtectedResource::new().set_labels([
767 /// ("key0", "abc"),
768 /// ("key1", "xyz"),
769 /// ]);
770 /// ```
771 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
772 where
773 T: std::iter::IntoIterator<Item = (K, V)>,
774 K: std::convert::Into<std::string::String>,
775 V: std::convert::Into<std::string::String>,
776 {
777 use std::iter::Iterator;
778 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
779 self
780 }
781
782 /// Sets the value of [crypto_key_version][crate::model::ProtectedResource::crypto_key_version].
783 ///
784 /// # Example
785 /// ```ignore,no_run
786 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
787 /// let x = ProtectedResource::new().set_crypto_key_version("example");
788 /// ```
789 pub fn set_crypto_key_version<T: std::convert::Into<std::string::String>>(
790 mut self,
791 v: T,
792 ) -> Self {
793 self.crypto_key_version = v.into();
794 self
795 }
796
797 /// Sets the value of [crypto_key_versions][crate::model::ProtectedResource::crypto_key_versions].
798 ///
799 /// # Example
800 /// ```ignore,no_run
801 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
802 /// let x = ProtectedResource::new().set_crypto_key_versions(["a", "b", "c"]);
803 /// ```
804 pub fn set_crypto_key_versions<T, V>(mut self, v: T) -> Self
805 where
806 T: std::iter::IntoIterator<Item = V>,
807 V: std::convert::Into<std::string::String>,
808 {
809 use std::iter::Iterator;
810 self.crypto_key_versions = v.into_iter().map(|i| i.into()).collect();
811 self
812 }
813
814 /// Sets the value of [create_time][crate::model::ProtectedResource::create_time].
815 ///
816 /// # Example
817 /// ```ignore,no_run
818 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
819 /// use wkt::Timestamp;
820 /// let x = ProtectedResource::new().set_create_time(Timestamp::default()/* use setters */);
821 /// ```
822 pub fn set_create_time<T>(mut self, v: T) -> Self
823 where
824 T: std::convert::Into<wkt::Timestamp>,
825 {
826 self.create_time = std::option::Option::Some(v.into());
827 self
828 }
829
830 /// Sets or clears the value of [create_time][crate::model::ProtectedResource::create_time].
831 ///
832 /// # Example
833 /// ```ignore,no_run
834 /// # use google_cloud_kms_inventory_v1::model::ProtectedResource;
835 /// use wkt::Timestamp;
836 /// let x = ProtectedResource::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
837 /// let x = ProtectedResource::new().set_or_clear_create_time(None::<Timestamp>);
838 /// ```
839 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
840 where
841 T: std::convert::Into<wkt::Timestamp>,
842 {
843 self.create_time = v.map(|x| x.into());
844 self
845 }
846}
847
848impl wkt::message::Message for ProtectedResource {
849 fn typename() -> &'static str {
850 "type.googleapis.com/google.cloud.kms.inventory.v1.ProtectedResource"
851 }
852}
853
854/// A warning message that indicates potential problems with the response data.
855#[derive(Clone, Default, PartialEq)]
856#[non_exhaustive]
857pub struct Warning {
858 /// The specific warning code for the displayed message.
859 pub warning_code: crate::model::warning::WarningCode,
860
861 /// The literal message providing context and details about the warnings.
862 pub display_message: std::string::String,
863
864 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
865}
866
867impl Warning {
868 pub fn new() -> Self {
869 std::default::Default::default()
870 }
871
872 /// Sets the value of [warning_code][crate::model::Warning::warning_code].
873 ///
874 /// # Example
875 /// ```ignore,no_run
876 /// # use google_cloud_kms_inventory_v1::model::Warning;
877 /// use google_cloud_kms_inventory_v1::model::warning::WarningCode;
878 /// let x0 = Warning::new().set_warning_code(WarningCode::InsufficientPermissionsPartialData);
879 /// let x1 = Warning::new().set_warning_code(WarningCode::ResourceLimitExceededPartialData);
880 /// let x2 = Warning::new().set_warning_code(WarningCode::OrgLessProjectPartialData);
881 /// ```
882 pub fn set_warning_code<T: std::convert::Into<crate::model::warning::WarningCode>>(
883 mut self,
884 v: T,
885 ) -> Self {
886 self.warning_code = v.into();
887 self
888 }
889
890 /// Sets the value of [display_message][crate::model::Warning::display_message].
891 ///
892 /// # Example
893 /// ```ignore,no_run
894 /// # use google_cloud_kms_inventory_v1::model::Warning;
895 /// let x = Warning::new().set_display_message("example");
896 /// ```
897 pub fn set_display_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
898 self.display_message = v.into();
899 self
900 }
901}
902
903impl wkt::message::Message for Warning {
904 fn typename() -> &'static str {
905 "type.googleapis.com/google.cloud.kms.inventory.v1.Warning"
906 }
907}
908
909/// Defines additional types related to [Warning].
910pub mod warning {
911 #[allow(unused_imports)]
912 use super::*;
913
914 /// Different types of warnings that can be returned to the user.
915 /// The display_message contains detailed information regarding the
916 /// warning_code.
917 ///
918 /// # Working with unknown values
919 ///
920 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
921 /// additional enum variants at any time. Adding new variants is not considered
922 /// a breaking change. Applications should write their code in anticipation of:
923 ///
924 /// - New values appearing in future releases of the client library, **and**
925 /// - New values received dynamically, without application changes.
926 ///
927 /// Please consult the [Working with enums] section in the user guide for some
928 /// guidelines.
929 ///
930 /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
931 #[derive(Clone, Debug, PartialEq)]
932 #[non_exhaustive]
933 pub enum WarningCode {
934 /// Default value. This value is unused.
935 Unspecified,
936 /// Indicates that the caller or service agent lacks necessary permissions
937 /// to view some of the requested data. The response may be partial.
938 /// Example:
939 ///
940 /// - KMS organization service agent {service_agent_name} lacks the
941 /// `cloudasset.assets.searchAllResources` permission on the scope.
942 InsufficientPermissionsPartialData,
943 /// Indicates that a resource limit has been exceeded, resulting in partial
944 /// data. Example:
945 ///
946 /// - The project has more than 10,000 assets (resources,
947 /// crypto keys, key handles, IAM policies, etc).
948 ResourceLimitExceededPartialData,
949 /// Indicates that the project exists outside of an organization resource.
950 /// Thus the analysis is only done for the project level data and results
951 /// might be partial.
952 OrgLessProjectPartialData,
953 /// If set, the enum was initialized with an unknown value.
954 ///
955 /// Applications can examine the value using [WarningCode::value] or
956 /// [WarningCode::name].
957 UnknownValue(warning_code::UnknownValue),
958 }
959
960 #[doc(hidden)]
961 pub mod warning_code {
962 #[allow(unused_imports)]
963 use super::*;
964 #[derive(Clone, Debug, PartialEq)]
965 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
966 }
967
968 impl WarningCode {
969 /// Gets the enum value.
970 ///
971 /// Returns `None` if the enum contains an unknown value deserialized from
972 /// the string representation of enums.
973 pub fn value(&self) -> std::option::Option<i32> {
974 match self {
975 Self::Unspecified => std::option::Option::Some(0),
976 Self::InsufficientPermissionsPartialData => std::option::Option::Some(1),
977 Self::ResourceLimitExceededPartialData => std::option::Option::Some(2),
978 Self::OrgLessProjectPartialData => std::option::Option::Some(3),
979 Self::UnknownValue(u) => u.0.value(),
980 }
981 }
982
983 /// Gets the enum value as a string.
984 ///
985 /// Returns `None` if the enum contains an unknown value deserialized from
986 /// the integer representation of enums.
987 pub fn name(&self) -> std::option::Option<&str> {
988 match self {
989 Self::Unspecified => std::option::Option::Some("WARNING_CODE_UNSPECIFIED"),
990 Self::InsufficientPermissionsPartialData => {
991 std::option::Option::Some("INSUFFICIENT_PERMISSIONS_PARTIAL_DATA")
992 }
993 Self::ResourceLimitExceededPartialData => {
994 std::option::Option::Some("RESOURCE_LIMIT_EXCEEDED_PARTIAL_DATA")
995 }
996 Self::OrgLessProjectPartialData => {
997 std::option::Option::Some("ORG_LESS_PROJECT_PARTIAL_DATA")
998 }
999 Self::UnknownValue(u) => u.0.name(),
1000 }
1001 }
1002 }
1003
1004 impl std::default::Default for WarningCode {
1005 fn default() -> Self {
1006 use std::convert::From;
1007 Self::from(0)
1008 }
1009 }
1010
1011 impl std::fmt::Display for WarningCode {
1012 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1013 wkt::internal::display_enum(f, self.name(), self.value())
1014 }
1015 }
1016
1017 impl std::convert::From<i32> for WarningCode {
1018 fn from(value: i32) -> Self {
1019 match value {
1020 0 => Self::Unspecified,
1021 1 => Self::InsufficientPermissionsPartialData,
1022 2 => Self::ResourceLimitExceededPartialData,
1023 3 => Self::OrgLessProjectPartialData,
1024 _ => Self::UnknownValue(warning_code::UnknownValue(
1025 wkt::internal::UnknownEnumValue::Integer(value),
1026 )),
1027 }
1028 }
1029 }
1030
1031 impl std::convert::From<&str> for WarningCode {
1032 fn from(value: &str) -> Self {
1033 use std::string::ToString;
1034 match value {
1035 "WARNING_CODE_UNSPECIFIED" => Self::Unspecified,
1036 "INSUFFICIENT_PERMISSIONS_PARTIAL_DATA" => Self::InsufficientPermissionsPartialData,
1037 "RESOURCE_LIMIT_EXCEEDED_PARTIAL_DATA" => Self::ResourceLimitExceededPartialData,
1038 "ORG_LESS_PROJECT_PARTIAL_DATA" => Self::OrgLessProjectPartialData,
1039 _ => Self::UnknownValue(warning_code::UnknownValue(
1040 wkt::internal::UnknownEnumValue::String(value.to_string()),
1041 )),
1042 }
1043 }
1044 }
1045
1046 impl serde::ser::Serialize for WarningCode {
1047 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1048 where
1049 S: serde::Serializer,
1050 {
1051 match self {
1052 Self::Unspecified => serializer.serialize_i32(0),
1053 Self::InsufficientPermissionsPartialData => serializer.serialize_i32(1),
1054 Self::ResourceLimitExceededPartialData => serializer.serialize_i32(2),
1055 Self::OrgLessProjectPartialData => serializer.serialize_i32(3),
1056 Self::UnknownValue(u) => u.0.serialize(serializer),
1057 }
1058 }
1059 }
1060
1061 impl<'de> serde::de::Deserialize<'de> for WarningCode {
1062 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1063 where
1064 D: serde::Deserializer<'de>,
1065 {
1066 deserializer.deserialize_any(wkt::internal::EnumVisitor::<WarningCode>::new(
1067 ".google.cloud.kms.inventory.v1.Warning.WarningCode",
1068 ))
1069 }
1070 }
1071}
1072
1073/// Specifies the scope to use if the organization service agent is not
1074/// configured.
1075///
1076/// # Working with unknown values
1077///
1078/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1079/// additional enum variants at any time. Adding new variants is not considered
1080/// a breaking change. Applications should write their code in anticipation of:
1081///
1082/// - New values appearing in future releases of the client library, **and**
1083/// - New values received dynamically, without application changes.
1084///
1085/// Please consult the [Working with enums] section in the user guide for some
1086/// guidelines.
1087///
1088/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1089#[derive(Clone, Debug, PartialEq)]
1090#[non_exhaustive]
1091pub enum FallbackScope {
1092 /// Unspecified scope type.
1093 Unspecified,
1094 /// If set to `FALLBACK_SCOPE_PROJECT`, the API will fall back to using key's
1095 /// project as request scope if the kms organization service account is not
1096 /// configured.
1097 Project,
1098 /// If set, the enum was initialized with an unknown value.
1099 ///
1100 /// Applications can examine the value using [FallbackScope::value] or
1101 /// [FallbackScope::name].
1102 UnknownValue(fallback_scope::UnknownValue),
1103}
1104
1105#[doc(hidden)]
1106pub mod fallback_scope {
1107 #[allow(unused_imports)]
1108 use super::*;
1109 #[derive(Clone, Debug, PartialEq)]
1110 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1111}
1112
1113impl FallbackScope {
1114 /// Gets the enum value.
1115 ///
1116 /// Returns `None` if the enum contains an unknown value deserialized from
1117 /// the string representation of enums.
1118 pub fn value(&self) -> std::option::Option<i32> {
1119 match self {
1120 Self::Unspecified => std::option::Option::Some(0),
1121 Self::Project => std::option::Option::Some(1),
1122 Self::UnknownValue(u) => u.0.value(),
1123 }
1124 }
1125
1126 /// Gets the enum value as a string.
1127 ///
1128 /// Returns `None` if the enum contains an unknown value deserialized from
1129 /// the integer representation of enums.
1130 pub fn name(&self) -> std::option::Option<&str> {
1131 match self {
1132 Self::Unspecified => std::option::Option::Some("FALLBACK_SCOPE_UNSPECIFIED"),
1133 Self::Project => std::option::Option::Some("FALLBACK_SCOPE_PROJECT"),
1134 Self::UnknownValue(u) => u.0.name(),
1135 }
1136 }
1137}
1138
1139impl std::default::Default for FallbackScope {
1140 fn default() -> Self {
1141 use std::convert::From;
1142 Self::from(0)
1143 }
1144}
1145
1146impl std::fmt::Display for FallbackScope {
1147 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1148 wkt::internal::display_enum(f, self.name(), self.value())
1149 }
1150}
1151
1152impl std::convert::From<i32> for FallbackScope {
1153 fn from(value: i32) -> Self {
1154 match value {
1155 0 => Self::Unspecified,
1156 1 => Self::Project,
1157 _ => Self::UnknownValue(fallback_scope::UnknownValue(
1158 wkt::internal::UnknownEnumValue::Integer(value),
1159 )),
1160 }
1161 }
1162}
1163
1164impl std::convert::From<&str> for FallbackScope {
1165 fn from(value: &str) -> Self {
1166 use std::string::ToString;
1167 match value {
1168 "FALLBACK_SCOPE_UNSPECIFIED" => Self::Unspecified,
1169 "FALLBACK_SCOPE_PROJECT" => Self::Project,
1170 _ => Self::UnknownValue(fallback_scope::UnknownValue(
1171 wkt::internal::UnknownEnumValue::String(value.to_string()),
1172 )),
1173 }
1174 }
1175}
1176
1177impl serde::ser::Serialize for FallbackScope {
1178 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1179 where
1180 S: serde::Serializer,
1181 {
1182 match self {
1183 Self::Unspecified => serializer.serialize_i32(0),
1184 Self::Project => serializer.serialize_i32(1),
1185 Self::UnknownValue(u) => u.0.serialize(serializer),
1186 }
1187 }
1188}
1189
1190impl<'de> serde::de::Deserialize<'de> for FallbackScope {
1191 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1192 where
1193 D: serde::Deserializer<'de>,
1194 {
1195 deserializer.deserialize_any(wkt::internal::EnumVisitor::<FallbackScope>::new(
1196 ".google.cloud.kms.inventory.v1.FallbackScope",
1197 ))
1198 }
1199}