google_cloud_apikeys_v2/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_longrunning;
25extern crate google_cloud_lro;
26extern crate lazy_static;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// Request message for `CreateKey` method.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct CreateKeyRequest {
42 /// Required. The project in which the API key is created.
43 pub parent: std::string::String,
44
45 /// Required. The API key fields to set at creation time.
46 /// You can configure only the `display_name`, `restrictions`, and
47 /// `annotations` fields.
48 pub key: std::option::Option<crate::model::Key>,
49
50 /// User specified key id (optional). If specified, it will become the final
51 /// component of the key resource name.
52 ///
53 /// The id must be unique within the project, must conform with RFC-1034,
54 /// is restricted to lower-cased letters, and has a maximum length of 63
55 /// characters. In another word, the id must match the regular
56 /// expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
57 ///
58 /// The id must NOT be a UUID-like string.
59 pub key_id: std::string::String,
60
61 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
62}
63
64impl CreateKeyRequest {
65 pub fn new() -> Self {
66 std::default::Default::default()
67 }
68
69 /// Sets the value of [parent][crate::model::CreateKeyRequest::parent].
70 ///
71 /// # Example
72 /// ```ignore,no_run
73 /// # use google_cloud_apikeys_v2::model::CreateKeyRequest;
74 /// let x = CreateKeyRequest::new().set_parent("example");
75 /// ```
76 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
77 self.parent = v.into();
78 self
79 }
80
81 /// Sets the value of [key][crate::model::CreateKeyRequest::key].
82 ///
83 /// # Example
84 /// ```ignore,no_run
85 /// # use google_cloud_apikeys_v2::model::CreateKeyRequest;
86 /// use google_cloud_apikeys_v2::model::Key;
87 /// let x = CreateKeyRequest::new().set_key(Key::default()/* use setters */);
88 /// ```
89 pub fn set_key<T>(mut self, v: T) -> Self
90 where
91 T: std::convert::Into<crate::model::Key>,
92 {
93 self.key = std::option::Option::Some(v.into());
94 self
95 }
96
97 /// Sets or clears the value of [key][crate::model::CreateKeyRequest::key].
98 ///
99 /// # Example
100 /// ```ignore,no_run
101 /// # use google_cloud_apikeys_v2::model::CreateKeyRequest;
102 /// use google_cloud_apikeys_v2::model::Key;
103 /// let x = CreateKeyRequest::new().set_or_clear_key(Some(Key::default()/* use setters */));
104 /// let x = CreateKeyRequest::new().set_or_clear_key(None::<Key>);
105 /// ```
106 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
107 where
108 T: std::convert::Into<crate::model::Key>,
109 {
110 self.key = v.map(|x| x.into());
111 self
112 }
113
114 /// Sets the value of [key_id][crate::model::CreateKeyRequest::key_id].
115 ///
116 /// # Example
117 /// ```ignore,no_run
118 /// # use google_cloud_apikeys_v2::model::CreateKeyRequest;
119 /// let x = CreateKeyRequest::new().set_key_id("example");
120 /// ```
121 pub fn set_key_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
122 self.key_id = v.into();
123 self
124 }
125}
126
127impl wkt::message::Message for CreateKeyRequest {
128 fn typename() -> &'static str {
129 "type.googleapis.com/google.api.apikeys.v2.CreateKeyRequest"
130 }
131}
132
133/// Request message for `ListKeys` method.
134#[derive(Clone, Default, PartialEq)]
135#[non_exhaustive]
136pub struct ListKeysRequest {
137 /// Required. Lists all API keys associated with this project.
138 pub parent: std::string::String,
139
140 /// Optional. Specifies the maximum number of results to be returned at a time.
141 pub page_size: i32,
142
143 /// Optional. Requests a specific page of results.
144 pub page_token: std::string::String,
145
146 /// Optional. Indicate that keys deleted in the past 30 days should also be
147 /// returned.
148 pub show_deleted: bool,
149
150 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
151}
152
153impl ListKeysRequest {
154 pub fn new() -> Self {
155 std::default::Default::default()
156 }
157
158 /// Sets the value of [parent][crate::model::ListKeysRequest::parent].
159 ///
160 /// # Example
161 /// ```ignore,no_run
162 /// # use google_cloud_apikeys_v2::model::ListKeysRequest;
163 /// let x = ListKeysRequest::new().set_parent("example");
164 /// ```
165 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
166 self.parent = v.into();
167 self
168 }
169
170 /// Sets the value of [page_size][crate::model::ListKeysRequest::page_size].
171 ///
172 /// # Example
173 /// ```ignore,no_run
174 /// # use google_cloud_apikeys_v2::model::ListKeysRequest;
175 /// let x = ListKeysRequest::new().set_page_size(42);
176 /// ```
177 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
178 self.page_size = v.into();
179 self
180 }
181
182 /// Sets the value of [page_token][crate::model::ListKeysRequest::page_token].
183 ///
184 /// # Example
185 /// ```ignore,no_run
186 /// # use google_cloud_apikeys_v2::model::ListKeysRequest;
187 /// let x = ListKeysRequest::new().set_page_token("example");
188 /// ```
189 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
190 self.page_token = v.into();
191 self
192 }
193
194 /// Sets the value of [show_deleted][crate::model::ListKeysRequest::show_deleted].
195 ///
196 /// # Example
197 /// ```ignore,no_run
198 /// # use google_cloud_apikeys_v2::model::ListKeysRequest;
199 /// let x = ListKeysRequest::new().set_show_deleted(true);
200 /// ```
201 pub fn set_show_deleted<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
202 self.show_deleted = v.into();
203 self
204 }
205}
206
207impl wkt::message::Message for ListKeysRequest {
208 fn typename() -> &'static str {
209 "type.googleapis.com/google.api.apikeys.v2.ListKeysRequest"
210 }
211}
212
213/// Response message for `ListKeys` method.
214#[derive(Clone, Default, PartialEq)]
215#[non_exhaustive]
216pub struct ListKeysResponse {
217 /// A list of API keys.
218 pub keys: std::vec::Vec<crate::model::Key>,
219
220 /// The pagination token for the next page of results.
221 pub next_page_token: std::string::String,
222
223 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
224}
225
226impl ListKeysResponse {
227 pub fn new() -> Self {
228 std::default::Default::default()
229 }
230
231 /// Sets the value of [keys][crate::model::ListKeysResponse::keys].
232 ///
233 /// # Example
234 /// ```ignore,no_run
235 /// # use google_cloud_apikeys_v2::model::ListKeysResponse;
236 /// use google_cloud_apikeys_v2::model::Key;
237 /// let x = ListKeysResponse::new()
238 /// .set_keys([
239 /// Key::default()/* use setters */,
240 /// Key::default()/* use (different) setters */,
241 /// ]);
242 /// ```
243 pub fn set_keys<T, V>(mut self, v: T) -> Self
244 where
245 T: std::iter::IntoIterator<Item = V>,
246 V: std::convert::Into<crate::model::Key>,
247 {
248 use std::iter::Iterator;
249 self.keys = v.into_iter().map(|i| i.into()).collect();
250 self
251 }
252
253 /// Sets the value of [next_page_token][crate::model::ListKeysResponse::next_page_token].
254 ///
255 /// # Example
256 /// ```ignore,no_run
257 /// # use google_cloud_apikeys_v2::model::ListKeysResponse;
258 /// let x = ListKeysResponse::new().set_next_page_token("example");
259 /// ```
260 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
261 self.next_page_token = v.into();
262 self
263 }
264}
265
266impl wkt::message::Message for ListKeysResponse {
267 fn typename() -> &'static str {
268 "type.googleapis.com/google.api.apikeys.v2.ListKeysResponse"
269 }
270}
271
272#[doc(hidden)]
273impl google_cloud_gax::paginator::internal::PageableResponse for ListKeysResponse {
274 type PageItem = crate::model::Key;
275
276 fn items(self) -> std::vec::Vec<Self::PageItem> {
277 self.keys
278 }
279
280 fn next_page_token(&self) -> std::string::String {
281 use std::clone::Clone;
282 self.next_page_token.clone()
283 }
284}
285
286/// Request message for `GetKey` method.
287#[derive(Clone, Default, PartialEq)]
288#[non_exhaustive]
289pub struct GetKeyRequest {
290 /// Required. The resource name of the API key to get.
291 pub name: std::string::String,
292
293 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
294}
295
296impl GetKeyRequest {
297 pub fn new() -> Self {
298 std::default::Default::default()
299 }
300
301 /// Sets the value of [name][crate::model::GetKeyRequest::name].
302 ///
303 /// # Example
304 /// ```ignore,no_run
305 /// # use google_cloud_apikeys_v2::model::GetKeyRequest;
306 /// let x = GetKeyRequest::new().set_name("example");
307 /// ```
308 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
309 self.name = v.into();
310 self
311 }
312}
313
314impl wkt::message::Message for GetKeyRequest {
315 fn typename() -> &'static str {
316 "type.googleapis.com/google.api.apikeys.v2.GetKeyRequest"
317 }
318}
319
320/// Request message for `GetKeyString` method.
321#[derive(Clone, Default, PartialEq)]
322#[non_exhaustive]
323pub struct GetKeyStringRequest {
324 /// Required. The resource name of the API key to be retrieved.
325 pub name: std::string::String,
326
327 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
328}
329
330impl GetKeyStringRequest {
331 pub fn new() -> Self {
332 std::default::Default::default()
333 }
334
335 /// Sets the value of [name][crate::model::GetKeyStringRequest::name].
336 ///
337 /// # Example
338 /// ```ignore,no_run
339 /// # use google_cloud_apikeys_v2::model::GetKeyStringRequest;
340 /// let x = GetKeyStringRequest::new().set_name("example");
341 /// ```
342 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
343 self.name = v.into();
344 self
345 }
346}
347
348impl wkt::message::Message for GetKeyStringRequest {
349 fn typename() -> &'static str {
350 "type.googleapis.com/google.api.apikeys.v2.GetKeyStringRequest"
351 }
352}
353
354/// Response message for `GetKeyString` method.
355#[derive(Clone, Default, PartialEq)]
356#[non_exhaustive]
357pub struct GetKeyStringResponse {
358 /// An encrypted and signed value of the key.
359 pub key_string: std::string::String,
360
361 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
362}
363
364impl GetKeyStringResponse {
365 pub fn new() -> Self {
366 std::default::Default::default()
367 }
368
369 /// Sets the value of [key_string][crate::model::GetKeyStringResponse::key_string].
370 ///
371 /// # Example
372 /// ```ignore,no_run
373 /// # use google_cloud_apikeys_v2::model::GetKeyStringResponse;
374 /// let x = GetKeyStringResponse::new().set_key_string("example");
375 /// ```
376 pub fn set_key_string<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
377 self.key_string = v.into();
378 self
379 }
380}
381
382impl wkt::message::Message for GetKeyStringResponse {
383 fn typename() -> &'static str {
384 "type.googleapis.com/google.api.apikeys.v2.GetKeyStringResponse"
385 }
386}
387
388/// Request message for `UpdateKey` method.
389#[derive(Clone, Default, PartialEq)]
390#[non_exhaustive]
391pub struct UpdateKeyRequest {
392 /// Required. Set the `name` field to the resource name of the API key to be
393 /// updated. You can update only the `display_name`, `restrictions`, and
394 /// `annotations` fields.
395 pub key: std::option::Option<crate::model::Key>,
396
397 /// The field mask specifies which fields to be updated as part of this
398 /// request. All other fields are ignored.
399 /// Mutable fields are: `display_name`, `restrictions`, and `annotations`.
400 /// If an update mask is not provided, the service treats it as an implied mask
401 /// equivalent to all allowed fields that are set on the wire. If the field
402 /// mask has a special value "*", the service treats it equivalent to replace
403 /// all allowed mutable fields.
404 pub update_mask: std::option::Option<wkt::FieldMask>,
405
406 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
407}
408
409impl UpdateKeyRequest {
410 pub fn new() -> Self {
411 std::default::Default::default()
412 }
413
414 /// Sets the value of [key][crate::model::UpdateKeyRequest::key].
415 ///
416 /// # Example
417 /// ```ignore,no_run
418 /// # use google_cloud_apikeys_v2::model::UpdateKeyRequest;
419 /// use google_cloud_apikeys_v2::model::Key;
420 /// let x = UpdateKeyRequest::new().set_key(Key::default()/* use setters */);
421 /// ```
422 pub fn set_key<T>(mut self, v: T) -> Self
423 where
424 T: std::convert::Into<crate::model::Key>,
425 {
426 self.key = std::option::Option::Some(v.into());
427 self
428 }
429
430 /// Sets or clears the value of [key][crate::model::UpdateKeyRequest::key].
431 ///
432 /// # Example
433 /// ```ignore,no_run
434 /// # use google_cloud_apikeys_v2::model::UpdateKeyRequest;
435 /// use google_cloud_apikeys_v2::model::Key;
436 /// let x = UpdateKeyRequest::new().set_or_clear_key(Some(Key::default()/* use setters */));
437 /// let x = UpdateKeyRequest::new().set_or_clear_key(None::<Key>);
438 /// ```
439 pub fn set_or_clear_key<T>(mut self, v: std::option::Option<T>) -> Self
440 where
441 T: std::convert::Into<crate::model::Key>,
442 {
443 self.key = v.map(|x| x.into());
444 self
445 }
446
447 /// Sets the value of [update_mask][crate::model::UpdateKeyRequest::update_mask].
448 ///
449 /// # Example
450 /// ```ignore,no_run
451 /// # use google_cloud_apikeys_v2::model::UpdateKeyRequest;
452 /// use wkt::FieldMask;
453 /// let x = UpdateKeyRequest::new().set_update_mask(FieldMask::default()/* use setters */);
454 /// ```
455 pub fn set_update_mask<T>(mut self, v: T) -> Self
456 where
457 T: std::convert::Into<wkt::FieldMask>,
458 {
459 self.update_mask = std::option::Option::Some(v.into());
460 self
461 }
462
463 /// Sets or clears the value of [update_mask][crate::model::UpdateKeyRequest::update_mask].
464 ///
465 /// # Example
466 /// ```ignore,no_run
467 /// # use google_cloud_apikeys_v2::model::UpdateKeyRequest;
468 /// use wkt::FieldMask;
469 /// let x = UpdateKeyRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
470 /// let x = UpdateKeyRequest::new().set_or_clear_update_mask(None::<FieldMask>);
471 /// ```
472 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
473 where
474 T: std::convert::Into<wkt::FieldMask>,
475 {
476 self.update_mask = v.map(|x| x.into());
477 self
478 }
479}
480
481impl wkt::message::Message for UpdateKeyRequest {
482 fn typename() -> &'static str {
483 "type.googleapis.com/google.api.apikeys.v2.UpdateKeyRequest"
484 }
485}
486
487/// Request message for `DeleteKey` method.
488#[derive(Clone, Default, PartialEq)]
489#[non_exhaustive]
490pub struct DeleteKeyRequest {
491 /// Required. The resource name of the API key to be deleted.
492 pub name: std::string::String,
493
494 /// Optional. The etag known to the client for the expected state of the key.
495 /// This is to be used for optimistic concurrency.
496 pub etag: std::string::String,
497
498 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
499}
500
501impl DeleteKeyRequest {
502 pub fn new() -> Self {
503 std::default::Default::default()
504 }
505
506 /// Sets the value of [name][crate::model::DeleteKeyRequest::name].
507 ///
508 /// # Example
509 /// ```ignore,no_run
510 /// # use google_cloud_apikeys_v2::model::DeleteKeyRequest;
511 /// let x = DeleteKeyRequest::new().set_name("example");
512 /// ```
513 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
514 self.name = v.into();
515 self
516 }
517
518 /// Sets the value of [etag][crate::model::DeleteKeyRequest::etag].
519 ///
520 /// # Example
521 /// ```ignore,no_run
522 /// # use google_cloud_apikeys_v2::model::DeleteKeyRequest;
523 /// let x = DeleteKeyRequest::new().set_etag("example");
524 /// ```
525 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
526 self.etag = v.into();
527 self
528 }
529}
530
531impl wkt::message::Message for DeleteKeyRequest {
532 fn typename() -> &'static str {
533 "type.googleapis.com/google.api.apikeys.v2.DeleteKeyRequest"
534 }
535}
536
537/// Request message for `UndeleteKey` method.
538#[derive(Clone, Default, PartialEq)]
539#[non_exhaustive]
540pub struct UndeleteKeyRequest {
541 /// Required. The resource name of the API key to be undeleted.
542 pub name: std::string::String,
543
544 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
545}
546
547impl UndeleteKeyRequest {
548 pub fn new() -> Self {
549 std::default::Default::default()
550 }
551
552 /// Sets the value of [name][crate::model::UndeleteKeyRequest::name].
553 ///
554 /// # Example
555 /// ```ignore,no_run
556 /// # use google_cloud_apikeys_v2::model::UndeleteKeyRequest;
557 /// let x = UndeleteKeyRequest::new().set_name("example");
558 /// ```
559 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
560 self.name = v.into();
561 self
562 }
563}
564
565impl wkt::message::Message for UndeleteKeyRequest {
566 fn typename() -> &'static str {
567 "type.googleapis.com/google.api.apikeys.v2.UndeleteKeyRequest"
568 }
569}
570
571/// Request message for `LookupKey` method.
572#[derive(Clone, Default, PartialEq)]
573#[non_exhaustive]
574pub struct LookupKeyRequest {
575 /// Required. Finds the project that owns the key string value.
576 pub key_string: std::string::String,
577
578 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
579}
580
581impl LookupKeyRequest {
582 pub fn new() -> Self {
583 std::default::Default::default()
584 }
585
586 /// Sets the value of [key_string][crate::model::LookupKeyRequest::key_string].
587 ///
588 /// # Example
589 /// ```ignore,no_run
590 /// # use google_cloud_apikeys_v2::model::LookupKeyRequest;
591 /// let x = LookupKeyRequest::new().set_key_string("example");
592 /// ```
593 pub fn set_key_string<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
594 self.key_string = v.into();
595 self
596 }
597}
598
599impl wkt::message::Message for LookupKeyRequest {
600 fn typename() -> &'static str {
601 "type.googleapis.com/google.api.apikeys.v2.LookupKeyRequest"
602 }
603}
604
605/// Response message for `LookupKey` method.
606#[derive(Clone, Default, PartialEq)]
607#[non_exhaustive]
608pub struct LookupKeyResponse {
609 /// The project that owns the key with the value specified in the request.
610 pub parent: std::string::String,
611
612 /// The resource name of the API key. If the API key has been purged,
613 /// resource name is empty.
614 pub name: std::string::String,
615
616 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
617}
618
619impl LookupKeyResponse {
620 pub fn new() -> Self {
621 std::default::Default::default()
622 }
623
624 /// Sets the value of [parent][crate::model::LookupKeyResponse::parent].
625 ///
626 /// # Example
627 /// ```ignore,no_run
628 /// # use google_cloud_apikeys_v2::model::LookupKeyResponse;
629 /// let x = LookupKeyResponse::new().set_parent("example");
630 /// ```
631 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
632 self.parent = v.into();
633 self
634 }
635
636 /// Sets the value of [name][crate::model::LookupKeyResponse::name].
637 ///
638 /// # Example
639 /// ```ignore,no_run
640 /// # use google_cloud_apikeys_v2::model::LookupKeyResponse;
641 /// let x = LookupKeyResponse::new().set_name("example");
642 /// ```
643 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
644 self.name = v.into();
645 self
646 }
647}
648
649impl wkt::message::Message for LookupKeyResponse {
650 fn typename() -> &'static str {
651 "type.googleapis.com/google.api.apikeys.v2.LookupKeyResponse"
652 }
653}
654
655/// The representation of a key managed by the API Keys API.
656#[derive(Clone, Default, PartialEq)]
657#[non_exhaustive]
658pub struct Key {
659 /// Output only. The resource name of the key.
660 /// The `name` has the form:
661 /// `projects/<PROJECT_NUMBER>/locations/global/keys/<KEY_ID>`.
662 /// For example:
663 /// `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd-3855ee9b5dd2`
664 ///
665 /// NOTE: Key is a global resource; hence the only supported value for
666 /// location is `global`.
667 pub name: std::string::String,
668
669 /// Output only. Unique id in UUID4 format.
670 pub uid: std::string::String,
671
672 /// Human-readable display name of this key that you can modify.
673 /// The maximum length is 63 characters.
674 pub display_name: std::string::String,
675
676 /// Output only. An encrypted and signed value held by this key.
677 /// This field can be accessed only through the `GetKeyString` method.
678 pub key_string: std::string::String,
679
680 /// Output only. A timestamp identifying the time this key was originally
681 /// created.
682 pub create_time: std::option::Option<wkt::Timestamp>,
683
684 /// Output only. A timestamp identifying the time this key was last
685 /// updated.
686 pub update_time: std::option::Option<wkt::Timestamp>,
687
688 /// Output only. A timestamp when this key was deleted. If the resource is not
689 /// deleted, this must be empty.
690 pub delete_time: std::option::Option<wkt::Timestamp>,
691
692 /// Annotations is an unstructured key-value map stored with a policy that
693 /// may be set by external tools to store and retrieve arbitrary metadata.
694 /// They are not queryable and should be preserved when modifying objects.
695 pub annotations: std::collections::HashMap<std::string::String, std::string::String>,
696
697 /// Key restrictions.
698 pub restrictions: std::option::Option<crate::model::Restrictions>,
699
700 /// Output only. A checksum computed by the server based on the current value
701 /// of the Key resource. This may be sent on update and delete requests to
702 /// ensure the client has an up-to-date value before proceeding. See
703 /// <https://google.aip.dev/154>.
704 pub etag: std::string::String,
705
706 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
707}
708
709impl Key {
710 pub fn new() -> Self {
711 std::default::Default::default()
712 }
713
714 /// Sets the value of [name][crate::model::Key::name].
715 ///
716 /// # Example
717 /// ```ignore,no_run
718 /// # use google_cloud_apikeys_v2::model::Key;
719 /// let x = Key::new().set_name("example");
720 /// ```
721 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
722 self.name = v.into();
723 self
724 }
725
726 /// Sets the value of [uid][crate::model::Key::uid].
727 ///
728 /// # Example
729 /// ```ignore,no_run
730 /// # use google_cloud_apikeys_v2::model::Key;
731 /// let x = Key::new().set_uid("example");
732 /// ```
733 pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
734 self.uid = v.into();
735 self
736 }
737
738 /// Sets the value of [display_name][crate::model::Key::display_name].
739 ///
740 /// # Example
741 /// ```ignore,no_run
742 /// # use google_cloud_apikeys_v2::model::Key;
743 /// let x = Key::new().set_display_name("example");
744 /// ```
745 pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
746 self.display_name = v.into();
747 self
748 }
749
750 /// Sets the value of [key_string][crate::model::Key::key_string].
751 ///
752 /// # Example
753 /// ```ignore,no_run
754 /// # use google_cloud_apikeys_v2::model::Key;
755 /// let x = Key::new().set_key_string("example");
756 /// ```
757 pub fn set_key_string<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
758 self.key_string = v.into();
759 self
760 }
761
762 /// Sets the value of [create_time][crate::model::Key::create_time].
763 ///
764 /// # Example
765 /// ```ignore,no_run
766 /// # use google_cloud_apikeys_v2::model::Key;
767 /// use wkt::Timestamp;
768 /// let x = Key::new().set_create_time(Timestamp::default()/* use setters */);
769 /// ```
770 pub fn set_create_time<T>(mut self, v: T) -> Self
771 where
772 T: std::convert::Into<wkt::Timestamp>,
773 {
774 self.create_time = std::option::Option::Some(v.into());
775 self
776 }
777
778 /// Sets or clears the value of [create_time][crate::model::Key::create_time].
779 ///
780 /// # Example
781 /// ```ignore,no_run
782 /// # use google_cloud_apikeys_v2::model::Key;
783 /// use wkt::Timestamp;
784 /// let x = Key::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
785 /// let x = Key::new().set_or_clear_create_time(None::<Timestamp>);
786 /// ```
787 pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
788 where
789 T: std::convert::Into<wkt::Timestamp>,
790 {
791 self.create_time = v.map(|x| x.into());
792 self
793 }
794
795 /// Sets the value of [update_time][crate::model::Key::update_time].
796 ///
797 /// # Example
798 /// ```ignore,no_run
799 /// # use google_cloud_apikeys_v2::model::Key;
800 /// use wkt::Timestamp;
801 /// let x = Key::new().set_update_time(Timestamp::default()/* use setters */);
802 /// ```
803 pub fn set_update_time<T>(mut self, v: T) -> Self
804 where
805 T: std::convert::Into<wkt::Timestamp>,
806 {
807 self.update_time = std::option::Option::Some(v.into());
808 self
809 }
810
811 /// Sets or clears the value of [update_time][crate::model::Key::update_time].
812 ///
813 /// # Example
814 /// ```ignore,no_run
815 /// # use google_cloud_apikeys_v2::model::Key;
816 /// use wkt::Timestamp;
817 /// let x = Key::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
818 /// let x = Key::new().set_or_clear_update_time(None::<Timestamp>);
819 /// ```
820 pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
821 where
822 T: std::convert::Into<wkt::Timestamp>,
823 {
824 self.update_time = v.map(|x| x.into());
825 self
826 }
827
828 /// Sets the value of [delete_time][crate::model::Key::delete_time].
829 ///
830 /// # Example
831 /// ```ignore,no_run
832 /// # use google_cloud_apikeys_v2::model::Key;
833 /// use wkt::Timestamp;
834 /// let x = Key::new().set_delete_time(Timestamp::default()/* use setters */);
835 /// ```
836 pub fn set_delete_time<T>(mut self, v: T) -> Self
837 where
838 T: std::convert::Into<wkt::Timestamp>,
839 {
840 self.delete_time = std::option::Option::Some(v.into());
841 self
842 }
843
844 /// Sets or clears the value of [delete_time][crate::model::Key::delete_time].
845 ///
846 /// # Example
847 /// ```ignore,no_run
848 /// # use google_cloud_apikeys_v2::model::Key;
849 /// use wkt::Timestamp;
850 /// let x = Key::new().set_or_clear_delete_time(Some(Timestamp::default()/* use setters */));
851 /// let x = Key::new().set_or_clear_delete_time(None::<Timestamp>);
852 /// ```
853 pub fn set_or_clear_delete_time<T>(mut self, v: std::option::Option<T>) -> Self
854 where
855 T: std::convert::Into<wkt::Timestamp>,
856 {
857 self.delete_time = v.map(|x| x.into());
858 self
859 }
860
861 /// Sets the value of [annotations][crate::model::Key::annotations].
862 ///
863 /// # Example
864 /// ```ignore,no_run
865 /// # use google_cloud_apikeys_v2::model::Key;
866 /// let x = Key::new().set_annotations([
867 /// ("key0", "abc"),
868 /// ("key1", "xyz"),
869 /// ]);
870 /// ```
871 pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
872 where
873 T: std::iter::IntoIterator<Item = (K, V)>,
874 K: std::convert::Into<std::string::String>,
875 V: std::convert::Into<std::string::String>,
876 {
877 use std::iter::Iterator;
878 self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
879 self
880 }
881
882 /// Sets the value of [restrictions][crate::model::Key::restrictions].
883 ///
884 /// # Example
885 /// ```ignore,no_run
886 /// # use google_cloud_apikeys_v2::model::Key;
887 /// use google_cloud_apikeys_v2::model::Restrictions;
888 /// let x = Key::new().set_restrictions(Restrictions::default()/* use setters */);
889 /// ```
890 pub fn set_restrictions<T>(mut self, v: T) -> Self
891 where
892 T: std::convert::Into<crate::model::Restrictions>,
893 {
894 self.restrictions = std::option::Option::Some(v.into());
895 self
896 }
897
898 /// Sets or clears the value of [restrictions][crate::model::Key::restrictions].
899 ///
900 /// # Example
901 /// ```ignore,no_run
902 /// # use google_cloud_apikeys_v2::model::Key;
903 /// use google_cloud_apikeys_v2::model::Restrictions;
904 /// let x = Key::new().set_or_clear_restrictions(Some(Restrictions::default()/* use setters */));
905 /// let x = Key::new().set_or_clear_restrictions(None::<Restrictions>);
906 /// ```
907 pub fn set_or_clear_restrictions<T>(mut self, v: std::option::Option<T>) -> Self
908 where
909 T: std::convert::Into<crate::model::Restrictions>,
910 {
911 self.restrictions = v.map(|x| x.into());
912 self
913 }
914
915 /// Sets the value of [etag][crate::model::Key::etag].
916 ///
917 /// # Example
918 /// ```ignore,no_run
919 /// # use google_cloud_apikeys_v2::model::Key;
920 /// let x = Key::new().set_etag("example");
921 /// ```
922 pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
923 self.etag = v.into();
924 self
925 }
926}
927
928impl wkt::message::Message for Key {
929 fn typename() -> &'static str {
930 "type.googleapis.com/google.api.apikeys.v2.Key"
931 }
932}
933
934/// Describes the restrictions on the key.
935#[derive(Clone, Default, PartialEq)]
936#[non_exhaustive]
937pub struct Restrictions {
938 /// A restriction for a specific service and optionally one or
939 /// more specific methods. Requests are allowed if they
940 /// match any of these restrictions. If no restrictions are
941 /// specified, all targets are allowed.
942 pub api_targets: std::vec::Vec<crate::model::ApiTarget>,
943
944 /// The websites, IP addresses, Android apps, or iOS apps (the clients) that
945 /// are allowed to use the key. You can specify only one type of client
946 /// restrictions per key.
947 pub client_restrictions: std::option::Option<crate::model::restrictions::ClientRestrictions>,
948
949 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
950}
951
952impl Restrictions {
953 pub fn new() -> Self {
954 std::default::Default::default()
955 }
956
957 /// Sets the value of [api_targets][crate::model::Restrictions::api_targets].
958 ///
959 /// # Example
960 /// ```ignore,no_run
961 /// # use google_cloud_apikeys_v2::model::Restrictions;
962 /// use google_cloud_apikeys_v2::model::ApiTarget;
963 /// let x = Restrictions::new()
964 /// .set_api_targets([
965 /// ApiTarget::default()/* use setters */,
966 /// ApiTarget::default()/* use (different) setters */,
967 /// ]);
968 /// ```
969 pub fn set_api_targets<T, V>(mut self, v: T) -> Self
970 where
971 T: std::iter::IntoIterator<Item = V>,
972 V: std::convert::Into<crate::model::ApiTarget>,
973 {
974 use std::iter::Iterator;
975 self.api_targets = v.into_iter().map(|i| i.into()).collect();
976 self
977 }
978
979 /// Sets the value of [client_restrictions][crate::model::Restrictions::client_restrictions].
980 ///
981 /// Note that all the setters affecting `client_restrictions` are mutually
982 /// exclusive.
983 ///
984 /// # Example
985 /// ```ignore,no_run
986 /// # use google_cloud_apikeys_v2::model::Restrictions;
987 /// use google_cloud_apikeys_v2::model::BrowserKeyRestrictions;
988 /// let x = Restrictions::new().set_client_restrictions(Some(
989 /// google_cloud_apikeys_v2::model::restrictions::ClientRestrictions::BrowserKeyRestrictions(BrowserKeyRestrictions::default().into())));
990 /// ```
991 pub fn set_client_restrictions<
992 T: std::convert::Into<std::option::Option<crate::model::restrictions::ClientRestrictions>>,
993 >(
994 mut self,
995 v: T,
996 ) -> Self {
997 self.client_restrictions = v.into();
998 self
999 }
1000
1001 /// The value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1002 /// if it holds a `BrowserKeyRestrictions`, `None` if the field is not set or
1003 /// holds a different branch.
1004 pub fn browser_key_restrictions(
1005 &self,
1006 ) -> std::option::Option<&std::boxed::Box<crate::model::BrowserKeyRestrictions>> {
1007 #[allow(unreachable_patterns)]
1008 self.client_restrictions.as_ref().and_then(|v| match v {
1009 crate::model::restrictions::ClientRestrictions::BrowserKeyRestrictions(v) => {
1010 std::option::Option::Some(v)
1011 }
1012 _ => std::option::Option::None,
1013 })
1014 }
1015
1016 /// Sets the value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1017 /// to hold a `BrowserKeyRestrictions`.
1018 ///
1019 /// Note that all the setters affecting `client_restrictions` are
1020 /// mutually exclusive.
1021 ///
1022 /// # Example
1023 /// ```ignore,no_run
1024 /// # use google_cloud_apikeys_v2::model::Restrictions;
1025 /// use google_cloud_apikeys_v2::model::BrowserKeyRestrictions;
1026 /// let x = Restrictions::new().set_browser_key_restrictions(BrowserKeyRestrictions::default()/* use setters */);
1027 /// assert!(x.browser_key_restrictions().is_some());
1028 /// assert!(x.server_key_restrictions().is_none());
1029 /// assert!(x.android_key_restrictions().is_none());
1030 /// assert!(x.ios_key_restrictions().is_none());
1031 /// ```
1032 pub fn set_browser_key_restrictions<
1033 T: std::convert::Into<std::boxed::Box<crate::model::BrowserKeyRestrictions>>,
1034 >(
1035 mut self,
1036 v: T,
1037 ) -> Self {
1038 self.client_restrictions = std::option::Option::Some(
1039 crate::model::restrictions::ClientRestrictions::BrowserKeyRestrictions(v.into()),
1040 );
1041 self
1042 }
1043
1044 /// The value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1045 /// if it holds a `ServerKeyRestrictions`, `None` if the field is not set or
1046 /// holds a different branch.
1047 pub fn server_key_restrictions(
1048 &self,
1049 ) -> std::option::Option<&std::boxed::Box<crate::model::ServerKeyRestrictions>> {
1050 #[allow(unreachable_patterns)]
1051 self.client_restrictions.as_ref().and_then(|v| match v {
1052 crate::model::restrictions::ClientRestrictions::ServerKeyRestrictions(v) => {
1053 std::option::Option::Some(v)
1054 }
1055 _ => std::option::Option::None,
1056 })
1057 }
1058
1059 /// Sets the value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1060 /// to hold a `ServerKeyRestrictions`.
1061 ///
1062 /// Note that all the setters affecting `client_restrictions` are
1063 /// mutually exclusive.
1064 ///
1065 /// # Example
1066 /// ```ignore,no_run
1067 /// # use google_cloud_apikeys_v2::model::Restrictions;
1068 /// use google_cloud_apikeys_v2::model::ServerKeyRestrictions;
1069 /// let x = Restrictions::new().set_server_key_restrictions(ServerKeyRestrictions::default()/* use setters */);
1070 /// assert!(x.server_key_restrictions().is_some());
1071 /// assert!(x.browser_key_restrictions().is_none());
1072 /// assert!(x.android_key_restrictions().is_none());
1073 /// assert!(x.ios_key_restrictions().is_none());
1074 /// ```
1075 pub fn set_server_key_restrictions<
1076 T: std::convert::Into<std::boxed::Box<crate::model::ServerKeyRestrictions>>,
1077 >(
1078 mut self,
1079 v: T,
1080 ) -> Self {
1081 self.client_restrictions = std::option::Option::Some(
1082 crate::model::restrictions::ClientRestrictions::ServerKeyRestrictions(v.into()),
1083 );
1084 self
1085 }
1086
1087 /// The value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1088 /// if it holds a `AndroidKeyRestrictions`, `None` if the field is not set or
1089 /// holds a different branch.
1090 pub fn android_key_restrictions(
1091 &self,
1092 ) -> std::option::Option<&std::boxed::Box<crate::model::AndroidKeyRestrictions>> {
1093 #[allow(unreachable_patterns)]
1094 self.client_restrictions.as_ref().and_then(|v| match v {
1095 crate::model::restrictions::ClientRestrictions::AndroidKeyRestrictions(v) => {
1096 std::option::Option::Some(v)
1097 }
1098 _ => std::option::Option::None,
1099 })
1100 }
1101
1102 /// Sets the value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1103 /// to hold a `AndroidKeyRestrictions`.
1104 ///
1105 /// Note that all the setters affecting `client_restrictions` are
1106 /// mutually exclusive.
1107 ///
1108 /// # Example
1109 /// ```ignore,no_run
1110 /// # use google_cloud_apikeys_v2::model::Restrictions;
1111 /// use google_cloud_apikeys_v2::model::AndroidKeyRestrictions;
1112 /// let x = Restrictions::new().set_android_key_restrictions(AndroidKeyRestrictions::default()/* use setters */);
1113 /// assert!(x.android_key_restrictions().is_some());
1114 /// assert!(x.browser_key_restrictions().is_none());
1115 /// assert!(x.server_key_restrictions().is_none());
1116 /// assert!(x.ios_key_restrictions().is_none());
1117 /// ```
1118 pub fn set_android_key_restrictions<
1119 T: std::convert::Into<std::boxed::Box<crate::model::AndroidKeyRestrictions>>,
1120 >(
1121 mut self,
1122 v: T,
1123 ) -> Self {
1124 self.client_restrictions = std::option::Option::Some(
1125 crate::model::restrictions::ClientRestrictions::AndroidKeyRestrictions(v.into()),
1126 );
1127 self
1128 }
1129
1130 /// The value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1131 /// if it holds a `IosKeyRestrictions`, `None` if the field is not set or
1132 /// holds a different branch.
1133 pub fn ios_key_restrictions(
1134 &self,
1135 ) -> std::option::Option<&std::boxed::Box<crate::model::IosKeyRestrictions>> {
1136 #[allow(unreachable_patterns)]
1137 self.client_restrictions.as_ref().and_then(|v| match v {
1138 crate::model::restrictions::ClientRestrictions::IosKeyRestrictions(v) => {
1139 std::option::Option::Some(v)
1140 }
1141 _ => std::option::Option::None,
1142 })
1143 }
1144
1145 /// Sets the value of [client_restrictions][crate::model::Restrictions::client_restrictions]
1146 /// to hold a `IosKeyRestrictions`.
1147 ///
1148 /// Note that all the setters affecting `client_restrictions` are
1149 /// mutually exclusive.
1150 ///
1151 /// # Example
1152 /// ```ignore,no_run
1153 /// # use google_cloud_apikeys_v2::model::Restrictions;
1154 /// use google_cloud_apikeys_v2::model::IosKeyRestrictions;
1155 /// let x = Restrictions::new().set_ios_key_restrictions(IosKeyRestrictions::default()/* use setters */);
1156 /// assert!(x.ios_key_restrictions().is_some());
1157 /// assert!(x.browser_key_restrictions().is_none());
1158 /// assert!(x.server_key_restrictions().is_none());
1159 /// assert!(x.android_key_restrictions().is_none());
1160 /// ```
1161 pub fn set_ios_key_restrictions<
1162 T: std::convert::Into<std::boxed::Box<crate::model::IosKeyRestrictions>>,
1163 >(
1164 mut self,
1165 v: T,
1166 ) -> Self {
1167 self.client_restrictions = std::option::Option::Some(
1168 crate::model::restrictions::ClientRestrictions::IosKeyRestrictions(v.into()),
1169 );
1170 self
1171 }
1172}
1173
1174impl wkt::message::Message for Restrictions {
1175 fn typename() -> &'static str {
1176 "type.googleapis.com/google.api.apikeys.v2.Restrictions"
1177 }
1178}
1179
1180/// Defines additional types related to [Restrictions].
1181pub mod restrictions {
1182 #[allow(unused_imports)]
1183 use super::*;
1184
1185 /// The websites, IP addresses, Android apps, or iOS apps (the clients) that
1186 /// are allowed to use the key. You can specify only one type of client
1187 /// restrictions per key.
1188 #[derive(Clone, Debug, PartialEq)]
1189 #[non_exhaustive]
1190 pub enum ClientRestrictions {
1191 /// The HTTP referrers (websites) that are allowed to use the key.
1192 BrowserKeyRestrictions(std::boxed::Box<crate::model::BrowserKeyRestrictions>),
1193 /// The IP addresses of callers that are allowed to use the key.
1194 ServerKeyRestrictions(std::boxed::Box<crate::model::ServerKeyRestrictions>),
1195 /// The Android apps that are allowed to use the key.
1196 AndroidKeyRestrictions(std::boxed::Box<crate::model::AndroidKeyRestrictions>),
1197 /// The iOS apps that are allowed to use the key.
1198 IosKeyRestrictions(std::boxed::Box<crate::model::IosKeyRestrictions>),
1199 }
1200}
1201
1202/// The HTTP referrers (websites) that are allowed to use the key.
1203#[derive(Clone, Default, PartialEq)]
1204#[non_exhaustive]
1205pub struct BrowserKeyRestrictions {
1206 /// A list of regular expressions for the referrer URLs that are allowed
1207 /// to make API calls with this key.
1208 pub allowed_referrers: std::vec::Vec<std::string::String>,
1209
1210 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1211}
1212
1213impl BrowserKeyRestrictions {
1214 pub fn new() -> Self {
1215 std::default::Default::default()
1216 }
1217
1218 /// Sets the value of [allowed_referrers][crate::model::BrowserKeyRestrictions::allowed_referrers].
1219 ///
1220 /// # Example
1221 /// ```ignore,no_run
1222 /// # use google_cloud_apikeys_v2::model::BrowserKeyRestrictions;
1223 /// let x = BrowserKeyRestrictions::new().set_allowed_referrers(["a", "b", "c"]);
1224 /// ```
1225 pub fn set_allowed_referrers<T, V>(mut self, v: T) -> Self
1226 where
1227 T: std::iter::IntoIterator<Item = V>,
1228 V: std::convert::Into<std::string::String>,
1229 {
1230 use std::iter::Iterator;
1231 self.allowed_referrers = v.into_iter().map(|i| i.into()).collect();
1232 self
1233 }
1234}
1235
1236impl wkt::message::Message for BrowserKeyRestrictions {
1237 fn typename() -> &'static str {
1238 "type.googleapis.com/google.api.apikeys.v2.BrowserKeyRestrictions"
1239 }
1240}
1241
1242/// The IP addresses of callers that are allowed to use the key.
1243#[derive(Clone, Default, PartialEq)]
1244#[non_exhaustive]
1245pub struct ServerKeyRestrictions {
1246 /// A list of the caller IP addresses that are allowed to make API calls
1247 /// with this key.
1248 pub allowed_ips: std::vec::Vec<std::string::String>,
1249
1250 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1251}
1252
1253impl ServerKeyRestrictions {
1254 pub fn new() -> Self {
1255 std::default::Default::default()
1256 }
1257
1258 /// Sets the value of [allowed_ips][crate::model::ServerKeyRestrictions::allowed_ips].
1259 ///
1260 /// # Example
1261 /// ```ignore,no_run
1262 /// # use google_cloud_apikeys_v2::model::ServerKeyRestrictions;
1263 /// let x = ServerKeyRestrictions::new().set_allowed_ips(["a", "b", "c"]);
1264 /// ```
1265 pub fn set_allowed_ips<T, V>(mut self, v: T) -> Self
1266 where
1267 T: std::iter::IntoIterator<Item = V>,
1268 V: std::convert::Into<std::string::String>,
1269 {
1270 use std::iter::Iterator;
1271 self.allowed_ips = v.into_iter().map(|i| i.into()).collect();
1272 self
1273 }
1274}
1275
1276impl wkt::message::Message for ServerKeyRestrictions {
1277 fn typename() -> &'static str {
1278 "type.googleapis.com/google.api.apikeys.v2.ServerKeyRestrictions"
1279 }
1280}
1281
1282/// The Android apps that are allowed to use the key.
1283#[derive(Clone, Default, PartialEq)]
1284#[non_exhaustive]
1285pub struct AndroidKeyRestrictions {
1286 /// A list of Android applications that are allowed to make API calls with
1287 /// this key.
1288 pub allowed_applications: std::vec::Vec<crate::model::AndroidApplication>,
1289
1290 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1291}
1292
1293impl AndroidKeyRestrictions {
1294 pub fn new() -> Self {
1295 std::default::Default::default()
1296 }
1297
1298 /// Sets the value of [allowed_applications][crate::model::AndroidKeyRestrictions::allowed_applications].
1299 ///
1300 /// # Example
1301 /// ```ignore,no_run
1302 /// # use google_cloud_apikeys_v2::model::AndroidKeyRestrictions;
1303 /// use google_cloud_apikeys_v2::model::AndroidApplication;
1304 /// let x = AndroidKeyRestrictions::new()
1305 /// .set_allowed_applications([
1306 /// AndroidApplication::default()/* use setters */,
1307 /// AndroidApplication::default()/* use (different) setters */,
1308 /// ]);
1309 /// ```
1310 pub fn set_allowed_applications<T, V>(mut self, v: T) -> Self
1311 where
1312 T: std::iter::IntoIterator<Item = V>,
1313 V: std::convert::Into<crate::model::AndroidApplication>,
1314 {
1315 use std::iter::Iterator;
1316 self.allowed_applications = v.into_iter().map(|i| i.into()).collect();
1317 self
1318 }
1319}
1320
1321impl wkt::message::Message for AndroidKeyRestrictions {
1322 fn typename() -> &'static str {
1323 "type.googleapis.com/google.api.apikeys.v2.AndroidKeyRestrictions"
1324 }
1325}
1326
1327/// Identifier of an Android application for key use.
1328#[derive(Clone, Default, PartialEq)]
1329#[non_exhaustive]
1330pub struct AndroidApplication {
1331 /// The SHA1 fingerprint of the application. For example, both sha1 formats are
1332 /// acceptable : DA:39:A3:EE:5E:6B:4B:0D:32:55:BF:EF:95:60:18:90:AF:D8:07:09 or
1333 /// DA39A3EE5E6B4B0D3255BFEF95601890AFD80709.
1334 /// Output format is the latter.
1335 pub sha1_fingerprint: std::string::String,
1336
1337 /// The package name of the application.
1338 pub package_name: std::string::String,
1339
1340 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1341}
1342
1343impl AndroidApplication {
1344 pub fn new() -> Self {
1345 std::default::Default::default()
1346 }
1347
1348 /// Sets the value of [sha1_fingerprint][crate::model::AndroidApplication::sha1_fingerprint].
1349 ///
1350 /// # Example
1351 /// ```ignore,no_run
1352 /// # use google_cloud_apikeys_v2::model::AndroidApplication;
1353 /// let x = AndroidApplication::new().set_sha1_fingerprint("example");
1354 /// ```
1355 pub fn set_sha1_fingerprint<T: std::convert::Into<std::string::String>>(
1356 mut self,
1357 v: T,
1358 ) -> Self {
1359 self.sha1_fingerprint = v.into();
1360 self
1361 }
1362
1363 /// Sets the value of [package_name][crate::model::AndroidApplication::package_name].
1364 ///
1365 /// # Example
1366 /// ```ignore,no_run
1367 /// # use google_cloud_apikeys_v2::model::AndroidApplication;
1368 /// let x = AndroidApplication::new().set_package_name("example");
1369 /// ```
1370 pub fn set_package_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1371 self.package_name = v.into();
1372 self
1373 }
1374}
1375
1376impl wkt::message::Message for AndroidApplication {
1377 fn typename() -> &'static str {
1378 "type.googleapis.com/google.api.apikeys.v2.AndroidApplication"
1379 }
1380}
1381
1382/// The iOS apps that are allowed to use the key.
1383#[derive(Clone, Default, PartialEq)]
1384#[non_exhaustive]
1385pub struct IosKeyRestrictions {
1386 /// A list of bundle IDs that are allowed when making API calls with this key.
1387 pub allowed_bundle_ids: std::vec::Vec<std::string::String>,
1388
1389 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1390}
1391
1392impl IosKeyRestrictions {
1393 pub fn new() -> Self {
1394 std::default::Default::default()
1395 }
1396
1397 /// Sets the value of [allowed_bundle_ids][crate::model::IosKeyRestrictions::allowed_bundle_ids].
1398 ///
1399 /// # Example
1400 /// ```ignore,no_run
1401 /// # use google_cloud_apikeys_v2::model::IosKeyRestrictions;
1402 /// let x = IosKeyRestrictions::new().set_allowed_bundle_ids(["a", "b", "c"]);
1403 /// ```
1404 pub fn set_allowed_bundle_ids<T, V>(mut self, v: T) -> Self
1405 where
1406 T: std::iter::IntoIterator<Item = V>,
1407 V: std::convert::Into<std::string::String>,
1408 {
1409 use std::iter::Iterator;
1410 self.allowed_bundle_ids = v.into_iter().map(|i| i.into()).collect();
1411 self
1412 }
1413}
1414
1415impl wkt::message::Message for IosKeyRestrictions {
1416 fn typename() -> &'static str {
1417 "type.googleapis.com/google.api.apikeys.v2.IosKeyRestrictions"
1418 }
1419}
1420
1421/// A restriction for a specific service and optionally one or multiple
1422/// specific methods. Both fields are case insensitive.
1423#[derive(Clone, Default, PartialEq)]
1424#[non_exhaustive]
1425pub struct ApiTarget {
1426 /// The service for this restriction. It should be the canonical
1427 /// service name, for example: `translate.googleapis.com`.
1428 /// You can use [`gcloud services list`](/sdk/gcloud/reference/services/list)
1429 /// to get a list of services that are enabled in the project.
1430 pub service: std::string::String,
1431
1432 /// Optional. List of one or more methods that can be called.
1433 /// If empty, all methods for the service are allowed. A wildcard
1434 /// (*) can be used as the last symbol.
1435 /// Valid examples:
1436 /// `google.cloud.translate.v2.TranslateService.GetSupportedLanguage`
1437 /// `TranslateText`
1438 /// `Get*`
1439 /// `translate.googleapis.com.Get*`
1440 pub methods: std::vec::Vec<std::string::String>,
1441
1442 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1443}
1444
1445impl ApiTarget {
1446 pub fn new() -> Self {
1447 std::default::Default::default()
1448 }
1449
1450 /// Sets the value of [service][crate::model::ApiTarget::service].
1451 ///
1452 /// # Example
1453 /// ```ignore,no_run
1454 /// # use google_cloud_apikeys_v2::model::ApiTarget;
1455 /// let x = ApiTarget::new().set_service("example");
1456 /// ```
1457 pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1458 self.service = v.into();
1459 self
1460 }
1461
1462 /// Sets the value of [methods][crate::model::ApiTarget::methods].
1463 ///
1464 /// # Example
1465 /// ```ignore,no_run
1466 /// # use google_cloud_apikeys_v2::model::ApiTarget;
1467 /// let x = ApiTarget::new().set_methods(["a", "b", "c"]);
1468 /// ```
1469 pub fn set_methods<T, V>(mut self, v: T) -> Self
1470 where
1471 T: std::iter::IntoIterator<Item = V>,
1472 V: std::convert::Into<std::string::String>,
1473 {
1474 use std::iter::Iterator;
1475 self.methods = v.into_iter().map(|i| i.into()).collect();
1476 self
1477 }
1478}
1479
1480impl wkt::message::Message for ApiTarget {
1481 fn typename() -> &'static str {
1482 "type.googleapis.com/google.api.apikeys.v2.ApiTarget"
1483 }
1484}