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