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 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 the Check method.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct CheckRequest {
42 /// The service name as specified in its service configuration. For example,
43 /// `"pubsub.googleapis.com"`.
44 ///
45 /// See
46 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
47 /// for the definition of a service name.
48 pub service_name: std::string::String,
49
50 /// Specifies the version of the service configuration that should be used to
51 /// process the request. Must not be empty. Set this field to 'latest' to
52 /// specify using the latest configuration.
53 pub service_config_id: std::string::String,
54
55 /// Describes attributes about the operation being executed by the service.
56 pub attributes: std::option::Option<google_cloud_rpc_context::model::AttributeContext>,
57
58 /// Describes the resources and the policies applied to each resource.
59 pub resources: std::vec::Vec<crate::model::ResourceInfo>,
60
61 /// Optional. Contains a comma-separated list of flags.
62 pub flags: std::string::String,
63
64 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
65}
66
67impl CheckRequest {
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 pub fn new() -> Self {
208 std::default::Default::default()
209 }
210
211 /// Sets the value of [name][crate::model::ResourceInfo::name].
212 ///
213 /// # Example
214 /// ```ignore,no_run
215 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
216 /// let x = ResourceInfo::new().set_name("example");
217 /// ```
218 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
219 self.name = v.into();
220 self
221 }
222
223 /// Sets the value of [r#type][crate::model::ResourceInfo::type].
224 ///
225 /// # Example
226 /// ```ignore,no_run
227 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
228 /// let x = ResourceInfo::new().set_type("example");
229 /// ```
230 pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
231 self.r#type = v.into();
232 self
233 }
234
235 /// Sets the value of [permission][crate::model::ResourceInfo::permission].
236 ///
237 /// # Example
238 /// ```ignore,no_run
239 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
240 /// let x = ResourceInfo::new().set_permission("example");
241 /// ```
242 pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
243 self.permission = v.into();
244 self
245 }
246
247 /// Sets the value of [container][crate::model::ResourceInfo::container].
248 ///
249 /// # Example
250 /// ```ignore,no_run
251 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
252 /// let x = ResourceInfo::new().set_container("example");
253 /// ```
254 pub fn set_container<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
255 self.container = v.into();
256 self
257 }
258
259 /// Sets the value of [location][crate::model::ResourceInfo::location].
260 ///
261 /// # Example
262 /// ```ignore,no_run
263 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
264 /// let x = ResourceInfo::new().set_location("example");
265 /// ```
266 pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
267 self.location = v.into();
268 self
269 }
270}
271
272impl wkt::message::Message for ResourceInfo {
273 fn typename() -> &'static str {
274 "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfo"
275 }
276}
277
278/// Response message for the Check method.
279#[derive(Clone, Default, PartialEq)]
280#[non_exhaustive]
281pub struct CheckResponse {
282 /// Operation is allowed when this field is not set. Any non-'OK' status
283 /// indicates a denial; [google.rpc.Status.details][google.rpc.Status.details]
284 /// would contain additional details about the denial.
285 ///
286 /// [google.rpc.Status.details]: google_cloud_rpc::model::Status::details
287 pub status: std::option::Option<google_cloud_rpc::model::Status>,
288
289 /// Returns a set of request contexts generated from the `CheckRequest`.
290 pub headers: std::collections::HashMap<std::string::String, std::string::String>,
291
292 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
293}
294
295impl CheckResponse {
296 pub fn new() -> Self {
297 std::default::Default::default()
298 }
299
300 /// Sets the value of [status][crate::model::CheckResponse::status].
301 ///
302 /// # Example
303 /// ```ignore,no_run
304 /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
305 /// use google_cloud_rpc::model::Status;
306 /// let x = CheckResponse::new().set_status(Status::default()/* use setters */);
307 /// ```
308 pub fn set_status<T>(mut self, v: T) -> Self
309 where
310 T: std::convert::Into<google_cloud_rpc::model::Status>,
311 {
312 self.status = std::option::Option::Some(v.into());
313 self
314 }
315
316 /// Sets or clears the value of [status][crate::model::CheckResponse::status].
317 ///
318 /// # Example
319 /// ```ignore,no_run
320 /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
321 /// use google_cloud_rpc::model::Status;
322 /// let x = CheckResponse::new().set_or_clear_status(Some(Status::default()/* use setters */));
323 /// let x = CheckResponse::new().set_or_clear_status(None::<Status>);
324 /// ```
325 pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
326 where
327 T: std::convert::Into<google_cloud_rpc::model::Status>,
328 {
329 self.status = v.map(|x| x.into());
330 self
331 }
332
333 /// Sets the value of [headers][crate::model::CheckResponse::headers].
334 ///
335 /// # Example
336 /// ```ignore,no_run
337 /// # use google_cloud_api_servicecontrol_v2::model::CheckResponse;
338 /// let x = CheckResponse::new().set_headers([
339 /// ("key0", "abc"),
340 /// ("key1", "xyz"),
341 /// ]);
342 /// ```
343 pub fn set_headers<T, K, V>(mut self, v: T) -> Self
344 where
345 T: std::iter::IntoIterator<Item = (K, V)>,
346 K: std::convert::Into<std::string::String>,
347 V: std::convert::Into<std::string::String>,
348 {
349 use std::iter::Iterator;
350 self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
351 self
352 }
353}
354
355impl wkt::message::Message for CheckResponse {
356 fn typename() -> &'static str {
357 "type.googleapis.com/google.api.servicecontrol.v2.CheckResponse"
358 }
359}
360
361/// Request message for the Report method.
362#[derive(Clone, Default, PartialEq)]
363#[non_exhaustive]
364pub struct ReportRequest {
365 /// The service name as specified in its service configuration. For example,
366 /// `"pubsub.googleapis.com"`.
367 ///
368 /// See
369 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
370 /// for the definition of a service name.
371 pub service_name: std::string::String,
372
373 /// Specifies the version of the service configuration that should be used to
374 /// process the request. Must not be empty. Set this field to 'latest' to
375 /// specify using the latest configuration.
376 pub service_config_id: std::string::String,
377
378 /// Describes the list of operations to be reported. Each operation is
379 /// represented as an AttributeContext, and contains all attributes around an
380 /// API access.
381 pub operations: std::vec::Vec<google_cloud_rpc_context::model::AttributeContext>,
382
383 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
384}
385
386impl ReportRequest {
387 pub fn new() -> Self {
388 std::default::Default::default()
389 }
390
391 /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
392 ///
393 /// # Example
394 /// ```ignore,no_run
395 /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
396 /// let x = ReportRequest::new().set_service_name("example");
397 /// ```
398 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
399 self.service_name = v.into();
400 self
401 }
402
403 /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
404 ///
405 /// # Example
406 /// ```ignore,no_run
407 /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
408 /// let x = ReportRequest::new().set_service_config_id("example");
409 /// ```
410 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
411 mut self,
412 v: T,
413 ) -> Self {
414 self.service_config_id = v.into();
415 self
416 }
417
418 /// Sets the value of [operations][crate::model::ReportRequest::operations].
419 ///
420 /// # Example
421 /// ```ignore,no_run
422 /// # use google_cloud_api_servicecontrol_v2::model::ReportRequest;
423 /// use google_cloud_rpc_context::model::AttributeContext;
424 /// let x = ReportRequest::new()
425 /// .set_operations([
426 /// AttributeContext::default()/* use setters */,
427 /// AttributeContext::default()/* use (different) setters */,
428 /// ]);
429 /// ```
430 pub fn set_operations<T, V>(mut self, v: T) -> Self
431 where
432 T: std::iter::IntoIterator<Item = V>,
433 V: std::convert::Into<google_cloud_rpc_context::model::AttributeContext>,
434 {
435 use std::iter::Iterator;
436 self.operations = v.into_iter().map(|i| i.into()).collect();
437 self
438 }
439}
440
441impl wkt::message::Message for ReportRequest {
442 fn typename() -> &'static str {
443 "type.googleapis.com/google.api.servicecontrol.v2.ReportRequest"
444 }
445}
446
447/// Response message for the Report method.
448/// If the request contains any invalid data, the server returns an RPC error.
449#[derive(Clone, Default, PartialEq)]
450#[non_exhaustive]
451pub struct ReportResponse {
452 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
453}
454
455impl ReportResponse {
456 pub fn new() -> Self {
457 std::default::Default::default()
458 }
459}
460
461impl wkt::message::Message for ReportResponse {
462 fn typename() -> &'static str {
463 "type.googleapis.com/google.api.servicecontrol.v2.ReportResponse"
464 }
465}
466
467/// Message containing resource details in a batch mode.
468#[derive(Clone, Default, PartialEq)]
469#[non_exhaustive]
470pub struct ResourceInfoList {
471 /// The resource details.
472 pub resources: std::vec::Vec<crate::model::ResourceInfo>,
473
474 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
475}
476
477impl ResourceInfoList {
478 pub fn new() -> Self {
479 std::default::Default::default()
480 }
481
482 /// Sets the value of [resources][crate::model::ResourceInfoList::resources].
483 ///
484 /// # Example
485 /// ```ignore,no_run
486 /// # use google_cloud_api_servicecontrol_v2::model::ResourceInfoList;
487 /// use google_cloud_api_servicecontrol_v2::model::ResourceInfo;
488 /// let x = ResourceInfoList::new()
489 /// .set_resources([
490 /// ResourceInfo::default()/* use setters */,
491 /// ResourceInfo::default()/* use (different) setters */,
492 /// ]);
493 /// ```
494 pub fn set_resources<T, V>(mut self, v: T) -> Self
495 where
496 T: std::iter::IntoIterator<Item = V>,
497 V: std::convert::Into<crate::model::ResourceInfo>,
498 {
499 use std::iter::Iterator;
500 self.resources = v.into_iter().map(|i| i.into()).collect();
501 self
502 }
503}
504
505impl wkt::message::Message for ResourceInfoList {
506 fn typename() -> &'static str {
507 "type.googleapis.com/google.api.servicecontrol.v2.ResourceInfoList"
508 }
509}