Skip to main content

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