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    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
75        self.service_name = v.into();
76        self
77    }
78
79    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
80    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
81        mut self,
82        v: T,
83    ) -> Self {
84        self.service_config_id = v.into();
85        self
86    }
87
88    /// Sets the value of [attributes][crate::model::CheckRequest::attributes].
89    pub fn set_attributes<T>(mut self, v: T) -> Self
90    where
91        T: std::convert::Into<rpc_context::model::AttributeContext>,
92    {
93        self.attributes = std::option::Option::Some(v.into());
94        self
95    }
96
97    /// Sets or clears the value of [attributes][crate::model::CheckRequest::attributes].
98    pub fn set_or_clear_attributes<T>(mut self, v: std::option::Option<T>) -> Self
99    where
100        T: std::convert::Into<rpc_context::model::AttributeContext>,
101    {
102        self.attributes = v.map(|x| x.into());
103        self
104    }
105
106    /// Sets the value of [resources][crate::model::CheckRequest::resources].
107    pub fn set_resources<T, V>(mut self, v: T) -> Self
108    where
109        T: std::iter::IntoIterator<Item = V>,
110        V: std::convert::Into<crate::model::ResourceInfo>,
111    {
112        use std::iter::Iterator;
113        self.resources = v.into_iter().map(|i| i.into()).collect();
114        self
115    }
116
117    /// Sets the value of [flags][crate::model::CheckRequest::flags].
118    pub fn set_flags<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
119        self.flags = v.into();
120        self
121    }
122}
123
124impl wkt::message::Message for CheckRequest {
125    fn typename() -> &'static str {
126        "type.googleapis.com/google.api.servicecontrol.v2.CheckRequest"
127    }
128}
129
130/// Describes a resource referenced in the request.
131#[derive(Clone, Default, PartialEq)]
132#[non_exhaustive]
133pub struct ResourceInfo {
134    /// The name of the resource referenced in the request.
135    pub name: std::string::String,
136
137    /// The resource type in the format of "{service}/{kind}".
138    pub r#type: std::string::String,
139
140    /// The resource permission needed for this request.
141    /// The format must be "{service}/{plural}.{verb}".
142    pub permission: std::string::String,
143
144    /// Optional. The identifier of the container of this resource. For Google
145    /// Cloud APIs, the resource container must be one of the following formats:
146    /// - `projects/<project-id or project-number>`
147    ///
148    /// - `folders/<folder-number>`
149    /// - `organizations/<organization-number>`
150    ///
151    /// Required for the policy enforcement on the container level (e.g. VPCSC,
152    /// Location Policy check, Org Policy check).
153    pub container: std::string::String,
154
155    /// Optional. The location of the resource, it must be a valid zone, region or
156    /// multiregion, for example: "europe-west4", "northamerica-northeast1-a".
157    /// Required for location policy check.
158    pub location: std::string::String,
159
160    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
161}
162
163impl ResourceInfo {
164    pub fn new() -> Self {
165        std::default::Default::default()
166    }
167
168    /// Sets the value of [name][crate::model::ResourceInfo::name].
169    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
170        self.name = v.into();
171        self
172    }
173
174    /// Sets the value of [r#type][crate::model::ResourceInfo::type].
175    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
176        self.r#type = v.into();
177        self
178    }
179
180    /// Sets the value of [permission][crate::model::ResourceInfo::permission].
181    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
182        self.permission = v.into();
183        self
184    }
185
186    /// Sets the value of [container][crate::model::ResourceInfo::container].
187    pub fn set_container<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
188        self.container = v.into();
189        self
190    }
191
192    /// Sets the value of [location][crate::model::ResourceInfo::location].
193    pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
194        self.location = v.into();
195        self
196    }
197}
198
199impl wkt::message::Message for ResourceInfo {
200    fn typename() -> &'static str {
201        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfo"
202    }
203}
204
205/// Response message for the Check method.
206#[derive(Clone, Default, PartialEq)]
207#[non_exhaustive]
208pub struct CheckResponse {
209    /// Operation is allowed when this field is not set. Any non-'OK' status
210    /// indicates a denial; [google.rpc.Status.details][google.rpc.Status.details]
211    /// would contain additional details about the denial.
212    ///
213    /// [google.rpc.Status.details]: rpc::model::Status::details
214    pub status: std::option::Option<rpc::model::Status>,
215
216    /// Returns a set of request contexts generated from the `CheckRequest`.
217    pub headers: std::collections::HashMap<std::string::String, std::string::String>,
218
219    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
220}
221
222impl CheckResponse {
223    pub fn new() -> Self {
224        std::default::Default::default()
225    }
226
227    /// Sets the value of [status][crate::model::CheckResponse::status].
228    pub fn set_status<T>(mut self, v: T) -> Self
229    where
230        T: std::convert::Into<rpc::model::Status>,
231    {
232        self.status = std::option::Option::Some(v.into());
233        self
234    }
235
236    /// Sets or clears the value of [status][crate::model::CheckResponse::status].
237    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
238    where
239        T: std::convert::Into<rpc::model::Status>,
240    {
241        self.status = v.map(|x| x.into());
242        self
243    }
244
245    /// Sets the value of [headers][crate::model::CheckResponse::headers].
246    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
247    where
248        T: std::iter::IntoIterator<Item = (K, V)>,
249        K: std::convert::Into<std::string::String>,
250        V: std::convert::Into<std::string::String>,
251    {
252        use std::iter::Iterator;
253        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
254        self
255    }
256}
257
258impl wkt::message::Message for CheckResponse {
259    fn typename() -> &'static str {
260        "type.googleapis.com/google.api.servicecontrol.v2.CheckResponse"
261    }
262}
263
264/// Request message for the Report method.
265#[derive(Clone, Default, PartialEq)]
266#[non_exhaustive]
267pub struct ReportRequest {
268    /// The service name as specified in its service configuration. For example,
269    /// `"pubsub.googleapis.com"`.
270    ///
271    /// See
272    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
273    /// for the definition of a service name.
274    pub service_name: std::string::String,
275
276    /// Specifies the version of the service configuration that should be used to
277    /// process the request. Must not be empty. Set this field to 'latest' to
278    /// specify using the latest configuration.
279    pub service_config_id: std::string::String,
280
281    /// Describes the list of operations to be reported. Each operation is
282    /// represented as an AttributeContext, and contains all attributes around an
283    /// API access.
284    pub operations: std::vec::Vec<rpc_context::model::AttributeContext>,
285
286    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
287}
288
289impl ReportRequest {
290    pub fn new() -> Self {
291        std::default::Default::default()
292    }
293
294    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
295    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
296        self.service_name = v.into();
297        self
298    }
299
300    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
301    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
302        mut self,
303        v: T,
304    ) -> Self {
305        self.service_config_id = v.into();
306        self
307    }
308
309    /// Sets the value of [operations][crate::model::ReportRequest::operations].
310    pub fn set_operations<T, V>(mut self, v: T) -> Self
311    where
312        T: std::iter::IntoIterator<Item = V>,
313        V: std::convert::Into<rpc_context::model::AttributeContext>,
314    {
315        use std::iter::Iterator;
316        self.operations = v.into_iter().map(|i| i.into()).collect();
317        self
318    }
319}
320
321impl wkt::message::Message for ReportRequest {
322    fn typename() -> &'static str {
323        "type.googleapis.com/google.api.servicecontrol.v2.ReportRequest"
324    }
325}
326
327/// Response message for the Report method.
328/// If the request contains any invalid data, the server returns an RPC error.
329#[derive(Clone, Default, PartialEq)]
330#[non_exhaustive]
331pub struct ReportResponse {
332    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
333}
334
335impl ReportResponse {
336    pub fn new() -> Self {
337        std::default::Default::default()
338    }
339}
340
341impl wkt::message::Message for ReportResponse {
342    fn typename() -> &'static str {
343        "type.googleapis.com/google.api.servicecontrol.v2.ReportResponse"
344    }
345}
346
347/// Message containing resource details in a batch mode.
348#[derive(Clone, Default, PartialEq)]
349#[non_exhaustive]
350pub struct ResourceInfoList {
351    /// The resource details.
352    pub resources: std::vec::Vec<crate::model::ResourceInfo>,
353
354    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
355}
356
357impl ResourceInfoList {
358    pub fn new() -> Self {
359        std::default::Default::default()
360    }
361
362    /// Sets the value of [resources][crate::model::ResourceInfoList::resources].
363    pub fn set_resources<T, V>(mut self, v: T) -> Self
364    where
365        T: std::iter::IntoIterator<Item = V>,
366        V: std::convert::Into<crate::model::ResourceInfo>,
367    {
368        use std::iter::Iterator;
369        self.resources = v.into_iter().map(|i| i.into()).collect();
370        self
371    }
372}
373
374impl wkt::message::Message for ResourceInfoList {
375    fn typename() -> &'static str {
376        "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfoList"
377    }
378}