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