google_cloud_api_servicecontrol_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 gax;
23extern crate gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate rpc;
27extern crate rpc_context;
28extern crate serde;
29extern crate serde_json;
30extern crate serde_with;
31extern crate std;
32extern crate tracing;
33extern crate wkt;
34
35mod debug;
36mod deserialize;
37mod serialize;
38
39/// Request message for the Check method.
40#[derive(Clone, Default, PartialEq)]
41#[non_exhaustive]
42pub struct CheckRequest {
43    /// The service name as specified in its service configuration. For example,
44    /// `"pubsub.googleapis.com"`.
45    ///
46    /// See
47    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
48    /// for the definition of a service name.
49    pub service_name: std::string::String,
50
51    /// Specifies the version of the service configuration that should be used to
52    /// process the request. Must not be empty. Set this field to 'latest' to
53    /// specify using the latest configuration.
54    pub service_config_id: std::string::String,
55
56    /// Describes attributes about the operation being executed by the service.
57    pub attributes: std::option::Option<rpc_context::model::AttributeContext>,
58
59    /// Describes the resources and the policies applied to each resource.
60    pub resources: std::vec::Vec<crate::model::ResourceInfo>,
61
62    /// Optional. Contains a comma-separated list of flags.
63    pub flags: std::string::String,
64
65    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
66}
67
68impl CheckRequest {
69    pub fn new() -> Self {
70        std::default::Default::default()
71    }
72
73    /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
74    ///
75    /// # Example
76    /// ```ignore,no_run
77    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
78    /// let x = CheckRequest::new().set_service_name("example");
79    /// ```
80    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
81        self.service_name = v.into();
82        self
83    }
84
85    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
86    ///
87    /// # Example
88    /// ```ignore,no_run
89    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
90    /// let x = CheckRequest::new().set_service_config_id("example");
91    /// ```
92    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
93        mut self,
94        v: T,
95    ) -> Self {
96        self.service_config_id = v.into();
97        self
98    }
99
100    /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
101    ///
102    /// # Example
103    /// ```ignore,no_run
104    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
105    /// use rpc_context::model::AttributeContext;
106    /// let x = CheckRequest::new().set_attributes(AttributeContext::default()/* use setters */);
107    /// ```
108    pub fn set_attributes<T>(mut self, v: T) -> Self
109    where
110        T: std::convert::Into<rpc_context::model::AttributeContext>,
111    {
112        self.attributes = std::option::Option::Some(v.into());
113        self
114    }
115
116    /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
117    ///
118    /// # Example
119    /// ```ignore,no_run
120    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
121    /// use rpc_context::model::AttributeContext;
122    /// let x = CheckRequest::new().set_or_clear_attributes(Some(AttributeContext::default()/* use setters */));
123    /// let x = CheckRequest::new().set_or_clear_attributes(None::<AttributeContext>);
124    /// ```
125    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
126    where
127        T: std::convert::Into<rpc_context::model::AttributeContext>,
128    {
129        self.attributes = v.map(|x| x.into());
130        self
131    }
132
133    /// Sets the value of [resources][crate::model::CheckRequest::resources].
134    ///
135    /// # Example
136    /// ```ignore,no_run
137    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
138    /// use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
139    /// let x = CheckRequest::new()
140    ///     .set_resources([
141    ///         ResourceInfo::default()/* use setters */,
142    ///         ResourceInfo::default()/* use (different) setters */,
143    ///     ]);
144    /// ```
145    pub fn set_resources<T, V>(mut self, v: T) -> Self
146    where
147        T: std::iter::IntoIterator<Item = V>,
148        V: std::convert::Into<crate::model::ResourceInfo>,
149    {
150        use std::iter::Iterator;
151        self.resources = v.into_iter().map(|i| i.into()).collect();
152        self
153    }
154
155    /// Sets the value of [flags][crate::model::CheckRequest::flags].
156    ///
157    /// # Example
158    /// ```ignore,no_run
159    /// # use google_cloud_api_servicecontrol_v2::model::CheckRequest;
160    /// let x = CheckRequest::new().set_flags("example");
161    /// ```
162    pub fn set_flags<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
163        self.flags = v.into();
164        self
165    }
166}
167
168impl wkt::message::Message for CheckRequest {
169    fn typename() -> &'static str {
170        "type.googleapis.com/google.api.servicecontrol.v2.CheckRequest"
171    }
172}
173
174/// Describes a resource referenced in the request.
175#[derive(Clone, Default, PartialEq)]
176#[non_exhaustive]
177pub struct ResourceInfo {
178    /// The name of the resource referenced in the request.
179    pub name: std::string::String,
180
181    /// The resource type in the format of "{service}/{kind}".
182    pub r#type: std::string::String,
183
184    /// The resource permission needed for this request.
185    /// The format must be "{service}/{plural}.{verb}".
186    pub permission: std::string::String,
187
188    /// Optional. The identifier of the container of this resource. For Google
189    /// Cloud APIs, the resource container must be one of the following formats:
190    /// - `projects/<project-id or project-number>`
191    ///
192    /// - `folders/<folder-number>`
193    /// - `organizations/<organization-number>`
194    ///
195    /// Required for the policy enforcement on the container level (e.g. VPCSC,
196    /// Location Policy check, Org Policy check).
197    pub container: std::string::String,
198
199    /// Optional. The location of the resource, it must be a valid zone, region or
200    /// multiregion, for example: "europe-west4", "northamerica-northeast1-a".
201    /// Required for location policy check.
202    pub location: std::string::String,
203
204    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
205}
206
207impl ResourceInfo {
208    pub fn new() -> Self {
209        std::default::Default::default()
210    }
211
212    /// Sets the value of [name][crate::model::ResourceInfo::name].
213    ///
214    /// # Example
215    /// ```ignore,no_run
216    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
217    /// let x = ResourceInfo::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 [r#type][crate::model::ResourceInfo::type].
225    ///
226    /// # Example
227    /// ```ignore,no_run
228    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
229    /// let x = ResourceInfo::new().set_type("example");
230    /// ```
231    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
232        self.r#type = v.into();
233        self
234    }
235
236    /// Sets the value of [permission][crate::model::ResourceInfo::permission].
237    ///
238    /// # Example
239    /// ```ignore,no_run
240    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
241    /// let x = ResourceInfo::new().set_permission("example");
242    /// ```
243    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
244        self.permission = v.into();
245        self
246    }
247
248    /// Sets the value of [container][crate::model::ResourceInfo::container].
249    ///
250    /// # Example
251    /// ```ignore,no_run
252    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
253    /// let x = ResourceInfo::new().set_container("example");
254    /// ```
255    pub fn set_container<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
256        self.container = v.into();
257        self
258    }
259
260    /// Sets the value of [location][crate::model::ResourceInfo::location].
261    ///
262    /// # Example
263    /// ```ignore,no_run
264    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
265    /// let x = ResourceInfo::new().set_location("example");
266    /// ```
267    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
268        self.location = v.into();
269        self
270    }
271}
272
273impl wkt::message::Message for ResourceInfo {
274    fn typename() -> &'static str {
275        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfo"
276    }
277}
278
279/// Response message for the Check method.
280#[derive(Clone, Default, PartialEq)]
281#[non_exhaustive]
282pub struct CheckResponse {
283    /// Operation is allowed when this field is not set. Any non-'OK' status
284    /// indicates a denial; [google.rpc.Status.details][google.rpc.Status.details]
285    /// would contain additional details about the denial.
286    ///
287    /// [google.rpc.Status.details]: rpc::model::Status::details
288    pub status: std::option::Option<rpc::model::Status>,
289
290    /// Returns a set of request contexts generated from the `CheckRequest`.
291    pub headers: std::collections::HashMap<std::string::String, std::string::String>,
292
293    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
294}
295
296impl CheckResponse {
297    pub fn new() -> Self {
298        std::default::Default::default()
299    }
300
301    /// Sets the value of [status][crate::model::CheckResponse::status].
302    ///
303    /// # Example
304    /// ```ignore,no_run
305    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
306    /// use rpc::model::Status;
307    /// let x = CheckResponse::new().set_status(Status::default()/* use setters */);
308    /// ```
309    pub fn set_status<T>(mut self, v: T) -> Self
310    where
311        T: std::convert::Into<rpc::model::Status>,
312    {
313        self.status = std::option::Option::Some(v.into());
314        self
315    }
316
317    /// Sets or clears the value of [status][crate::model::CheckResponse::status].
318    ///
319    /// # Example
320    /// ```ignore,no_run
321    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
322    /// use rpc::model::Status;
323    /// let x = CheckResponse::new().set_or_clear_status(Some(Status::default()/* use setters */));
324    /// let x = CheckResponse::new().set_or_clear_status(None::<Status>);
325    /// ```
326    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
327    where
328        T: std::convert::Into<rpc::model::Status>,
329    {
330        self.status = v.map(|x| x.into());
331        self
332    }
333
334    /// Sets the value of [headers][crate::model::CheckResponse::headers].
335    ///
336    /// # Example
337    /// ```ignore,no_run
338    /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
339    /// let x = CheckResponse::new().set_headers([
340    ///     ("key0", "abc"),
341    ///     ("key1", "xyz"),
342    /// ]);
343    /// ```
344    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
345    where
346        T: std::iter::IntoIterator<Item = (K, V)>,
347        K: std::convert::Into<std::string::String>,
348        V: std::convert::Into<std::string::String>,
349    {
350        use std::iter::Iterator;
351        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
352        self
353    }
354}
355
356impl wkt::message::Message for CheckResponse {
357    fn typename() -> &'static str {
358        "type.googleapis.com/google.api.servicecontrol.v2.CheckResponse"
359    }
360}
361
362/// Request message for the Report method.
363#[derive(Clone, Default, PartialEq)]
364#[non_exhaustive]
365pub struct ReportRequest {
366    /// The service name as specified in its service configuration. For example,
367    /// `"pubsub.googleapis.com"`.
368    ///
369    /// See
370    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
371    /// for the definition of a service name.
372    pub service_name: std::string::String,
373
374    /// Specifies the version of the service configuration that should be used to
375    /// process the request. Must not be empty. Set this field to 'latest' to
376    /// specify using the latest configuration.
377    pub service_config_id: std::string::String,
378
379    /// Describes the list of operations to be reported. Each operation is
380    /// represented as an AttributeContext, and contains all attributes around an
381    /// API access.
382    pub operations: std::vec::Vec<rpc_context::model::AttributeContext>,
383
384    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
385}
386
387impl ReportRequest {
388    pub fn new() -> Self {
389        std::default::Default::default()
390    }
391
392    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
393    ///
394    /// # Example
395    /// ```ignore,no_run
396    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
397    /// let x = ReportRequest::new().set_service_name("example");
398    /// ```
399    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
400        self.service_name = v.into();
401        self
402    }
403
404    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
405    ///
406    /// # Example
407    /// ```ignore,no_run
408    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
409    /// let x = ReportRequest::new().set_service_config_id("example");
410    /// ```
411    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
412        mut self,
413        v: T,
414    ) -> Self {
415        self.service_config_id = v.into();
416        self
417    }
418
419    /// Sets the value of [operations][crate::model::ReportRequest::operations].
420    ///
421    /// # Example
422    /// ```ignore,no_run
423    /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
424    /// use rpc_context::model::AttributeContext;
425    /// let x = ReportRequest::new()
426    ///     .set_operations([
427    ///         AttributeContext::default()/* use setters */,
428    ///         AttributeContext::default()/* use (different) setters */,
429    ///     ]);
430    /// ```
431    pub fn set_operations<T, V>(mut self, v: T) -> Self
432    where
433        T: std::iter::IntoIterator<Item = V>,
434        V: std::convert::Into<rpc_context::model::AttributeContext>,
435    {
436        use std::iter::Iterator;
437        self.operations = v.into_iter().map(|i| i.into()).collect();
438        self
439    }
440}
441
442impl wkt::message::Message for ReportRequest {
443    fn typename() -> &'static str {
444        "type.googleapis.com/google.api.servicecontrol.v2.ReportRequest"
445    }
446}
447
448/// Response message for the Report method.
449/// If the request contains any invalid data, the server returns an RPC error.
450#[derive(Clone, Default, PartialEq)]
451#[non_exhaustive]
452pub struct ReportResponse {
453    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
454}
455
456impl ReportResponse {
457    pub fn new() -> Self {
458        std::default::Default::default()
459    }
460}
461
462impl wkt::message::Message for ReportResponse {
463    fn typename() -> &'static str {
464        "type.googleapis.com/google.api.servicecontrol.v2.ReportResponse"
465    }
466}
467
468/// Message containing resource details in a batch mode.
469#[derive(Clone, Default, PartialEq)]
470#[non_exhaustive]
471pub struct ResourceInfoList {
472    /// The resource details.
473    pub resources: std::vec::Vec<crate::model::ResourceInfo>,
474
475    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
476}
477
478impl ResourceInfoList {
479    pub fn new() -> Self {
480        std::default::Default::default()
481    }
482
483    /// Sets the value of [resources][crate::model::ResourceInfoList::resources].
484    ///
485    /// # Example
486    /// ```ignore,no_run
487    /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfoList;
488    /// use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
489    /// let x = ResourceInfoList::new()
490    ///     .set_resources([
491    ///         ResourceInfo::default()/* use setters */,
492    ///         ResourceInfo::default()/* use (different) setters */,
493    ///     ]);
494    /// ```
495    pub fn set_resources<T, V>(mut self, v: T) -> Self
496    where
497        T: std::iter::IntoIterator<Item = V>,
498        V: std::convert::Into<crate::model::ResourceInfo>,
499    {
500        use std::iter::Iterator;
501        self.resources = v.into_iter().map(|i| i.into()).collect();
502        self
503    }
504}
505
506impl wkt::message::Message for ResourceInfoList {
507    fn typename() -> &'static str {
508        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfoList"
509    }
510}