google_cloud_api_servicecontrol_v1/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 api;
21extern crate async_trait;
22extern crate bytes;
23extern crate gax;
24extern crate lazy_static;
25extern crate logging_type;
26extern crate reqwest;
27extern crate rpc;
28extern crate serde;
29extern crate serde_json;
30extern crate serde_with;
31extern crate std;
32extern crate tracing;
33extern crate wkt;
34
35/// Defines the errors to be returned in
36/// [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors].
37///
38/// [google.api.servicecontrol.v1.CheckResponse.check_errors]: crate::model::CheckResponse::check_errors
39#[serde_with::serde_as]
40#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
41#[serde(default, rename_all = "camelCase")]
42#[non_exhaustive]
43pub struct CheckError {
44 /// The error code.
45 pub code: crate::model::check_error::Code,
46
47 /// Subject to whom this error applies. See the specific code enum for more
48 /// details on this field. For example:
49 ///
50 /// - "project:\<project-id or project-number\>"
51 /// - "folder:\<folder-id\>"
52 /// - "organization:\<organization-id\>"
53 #[serde(skip_serializing_if = "std::string::String::is_empty")]
54 pub subject: std::string::String,
55
56 /// Free-form text providing details on the error cause of the error.
57 #[serde(skip_serializing_if = "std::string::String::is_empty")]
58 pub detail: std::string::String,
59
60 /// Contains public information about the check error. If available,
61 /// `status.code` will be non zero and client can propagate it out as public
62 /// error.
63 #[serde(skip_serializing_if = "std::option::Option::is_none")]
64 pub status: std::option::Option<rpc::model::Status>,
65}
66
67impl CheckError {
68 pub fn new() -> Self {
69 std::default::Default::default()
70 }
71
72 /// Sets the value of [code][crate::model::CheckError::code].
73 pub fn set_code<T: std::convert::Into<crate::model::check_error::Code>>(
74 mut self,
75 v: T,
76 ) -> Self {
77 self.code = v.into();
78 self
79 }
80
81 /// Sets the value of [subject][crate::model::CheckError::subject].
82 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
83 self.subject = v.into();
84 self
85 }
86
87 /// Sets the value of [detail][crate::model::CheckError::detail].
88 pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
89 self.detail = v.into();
90 self
91 }
92
93 /// Sets the value of [status][crate::model::CheckError::status].
94 pub fn set_status<T: std::convert::Into<std::option::Option<rpc::model::Status>>>(
95 mut self,
96 v: T,
97 ) -> Self {
98 self.status = v.into();
99 self
100 }
101}
102
103impl wkt::message::Message for CheckError {
104 fn typename() -> &'static str {
105 "type.googleapis.com/google.api.servicecontrol.v1.CheckError"
106 }
107}
108
109/// Defines additional types related to CheckError
110pub mod check_error {
111 #[allow(unused_imports)]
112 use super::*;
113
114 /// Error codes for Check responses.
115 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
116 pub struct Code(std::borrow::Cow<'static, str>);
117
118 impl Code {
119 /// Creates a new Code instance.
120 pub const fn new(v: &'static str) -> Self {
121 Self(std::borrow::Cow::Borrowed(v))
122 }
123
124 /// Gets the enum value.
125 pub fn value(&self) -> &str {
126 &self.0
127 }
128 }
129
130 /// Useful constants to work with [Code](Code)
131 pub mod code {
132 use super::Code;
133
134 /// This is never used in `CheckResponse`.
135 pub const ERROR_CODE_UNSPECIFIED: Code = Code::new("ERROR_CODE_UNSPECIFIED");
136
137 /// The consumer's project id, network container, or resource container was
138 /// not found. Same as [google.rpc.Code.NOT_FOUND][google.rpc.Code.NOT_FOUND].
139 pub const NOT_FOUND: Code = Code::new("NOT_FOUND");
140
141 /// The consumer doesn't have access to the specified resource.
142 /// Same as [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
143 pub const PERMISSION_DENIED: Code = Code::new("PERMISSION_DENIED");
144
145 /// Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
146 pub const RESOURCE_EXHAUSTED: Code = Code::new("RESOURCE_EXHAUSTED");
147
148 /// The consumer hasn't activated the service.
149 pub const SERVICE_NOT_ACTIVATED: Code = Code::new("SERVICE_NOT_ACTIVATED");
150
151 /// The consumer cannot access the service because billing is disabled.
152 pub const BILLING_DISABLED: Code = Code::new("BILLING_DISABLED");
153
154 /// The consumer's project has been marked as deleted (soft deletion).
155 pub const PROJECT_DELETED: Code = Code::new("PROJECT_DELETED");
156
157 /// The consumer's project number or id does not represent a valid project.
158 pub const PROJECT_INVALID: Code = Code::new("PROJECT_INVALID");
159
160 /// The input consumer info does not represent a valid consumer folder or
161 /// organization.
162 pub const CONSUMER_INVALID: Code = Code::new("CONSUMER_INVALID");
163
164 /// The IP address of the consumer is invalid for the specific consumer
165 /// project.
166 pub const IP_ADDRESS_BLOCKED: Code = Code::new("IP_ADDRESS_BLOCKED");
167
168 /// The referer address of the consumer request is invalid for the specific
169 /// consumer project.
170 pub const REFERER_BLOCKED: Code = Code::new("REFERER_BLOCKED");
171
172 /// The client application of the consumer request is invalid for the
173 /// specific consumer project.
174 pub const CLIENT_APP_BLOCKED: Code = Code::new("CLIENT_APP_BLOCKED");
175
176 /// The API targeted by this request is invalid for the specified consumer
177 /// project.
178 pub const API_TARGET_BLOCKED: Code = Code::new("API_TARGET_BLOCKED");
179
180 /// The consumer's API key is invalid.
181 pub const API_KEY_INVALID: Code = Code::new("API_KEY_INVALID");
182
183 /// The consumer's API Key has expired.
184 pub const API_KEY_EXPIRED: Code = Code::new("API_KEY_EXPIRED");
185
186 /// The consumer's API Key was not found in config record.
187 pub const API_KEY_NOT_FOUND: Code = Code::new("API_KEY_NOT_FOUND");
188
189 /// The credential in the request can not be verified.
190 pub const INVALID_CREDENTIAL: Code = Code::new("INVALID_CREDENTIAL");
191
192 /// The backend server for looking up project id/number is unavailable.
193 pub const NAMESPACE_LOOKUP_UNAVAILABLE: Code = Code::new("NAMESPACE_LOOKUP_UNAVAILABLE");
194
195 /// The backend server for checking service status is unavailable.
196 pub const SERVICE_STATUS_UNAVAILABLE: Code = Code::new("SERVICE_STATUS_UNAVAILABLE");
197
198 /// The backend server for checking billing status is unavailable.
199 pub const BILLING_STATUS_UNAVAILABLE: Code = Code::new("BILLING_STATUS_UNAVAILABLE");
200
201 /// Cloud Resource Manager backend server is unavailable.
202 pub const CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE: Code =
203 Code::new("CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE");
204 }
205
206 impl std::convert::From<std::string::String> for Code {
207 fn from(value: std::string::String) -> Self {
208 Self(std::borrow::Cow::Owned(value))
209 }
210 }
211}
212
213/// Distribution represents a frequency distribution of double-valued sample
214/// points. It contains the size of the population of sample points plus
215/// additional optional information:
216///
217/// * the arithmetic mean of the samples
218/// * the minimum and maximum of the samples
219/// * the sum-squared-deviation of the samples, used to compute variance
220/// * a histogram of the values of the sample points
221#[serde_with::serde_as]
222#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
223#[serde(default, rename_all = "camelCase")]
224#[non_exhaustive]
225pub struct Distribution {
226 /// The total number of samples in the distribution. Must be >= 0.
227 #[serde_as(as = "serde_with::DisplayFromStr")]
228 pub count: i64,
229
230 /// The arithmetic mean of the samples in the distribution. If `count` is
231 /// zero then this field must be zero.
232 pub mean: f64,
233
234 /// The minimum of the population of values. Ignored if `count` is zero.
235 pub minimum: f64,
236
237 /// The maximum of the population of values. Ignored if `count` is zero.
238 pub maximum: f64,
239
240 /// The sum of squared deviations from the mean:
241 /// Sum[i=1..count]((x_i - mean)^2)
242 /// where each x_i is a sample values. If `count` is zero then this field
243 /// must be zero, otherwise validation of the request fails.
244 pub sum_of_squared_deviation: f64,
245
246 /// The number of samples in each histogram bucket. `bucket_counts` are
247 /// optional. If present, they must sum to the `count` value.
248 ///
249 /// The buckets are defined below in `bucket_option`. There are N buckets.
250 /// `bucket_counts[0]` is the number of samples in the underflow bucket.
251 /// `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
252 /// in each of the finite buckets. And `bucket_counts[N] is the number
253 /// of samples in the overflow bucket. See the comments of `bucket_option`
254 /// below for more details.
255 ///
256 /// Any suffix of trailing zeros may be omitted.
257 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
258 #[serde_as(as = "std::vec::Vec<serde_with::DisplayFromStr>")]
259 pub bucket_counts: std::vec::Vec<i64>,
260
261 /// Example points. Must be in increasing order of `value` field.
262 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
263 pub exemplars: std::vec::Vec<api::model::distribution::Exemplar>,
264
265 /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
266 /// must be both set, or both unset.
267 ///
268 /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
269 /// There must be at least two buckets (a single-bucket histogram gives
270 /// no information that isn't already provided by `count`).
271 ///
272 /// The first bucket is the underflow bucket which has a lower bound
273 /// of -inf. The last bucket is the overflow bucket which has an
274 /// upper bound of +inf. All other buckets (if any) are called "finite"
275 /// buckets because they have finite lower and upper bounds. As described
276 /// below, there are three ways to define the finite buckets.
277 ///
278 /// (1) Buckets with constant width.
279 /// (2) Buckets with exponentially growing widths.
280 /// (3) Buckets with arbitrary user-provided widths.
281 ///
282 /// In all cases, the buckets cover the entire real number line (-inf,
283 /// +inf). Bucket upper bounds are exclusive and lower bounds are
284 /// inclusive. The upper bound of the underflow bucket is equal to the
285 /// lower bound of the smallest finite bucket; the lower bound of the
286 /// overflow bucket is equal to the upper bound of the largest finite
287 /// bucket.
288 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
289 pub bucket_option: std::option::Option<crate::model::distribution::BucketOption>,
290}
291
292impl Distribution {
293 pub fn new() -> Self {
294 std::default::Default::default()
295 }
296
297 /// Sets the value of [count][crate::model::Distribution::count].
298 pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
299 self.count = v.into();
300 self
301 }
302
303 /// Sets the value of [mean][crate::model::Distribution::mean].
304 pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
305 self.mean = v.into();
306 self
307 }
308
309 /// Sets the value of [minimum][crate::model::Distribution::minimum].
310 pub fn set_minimum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
311 self.minimum = v.into();
312 self
313 }
314
315 /// Sets the value of [maximum][crate::model::Distribution::maximum].
316 pub fn set_maximum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
317 self.maximum = v.into();
318 self
319 }
320
321 /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
322 pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
323 self.sum_of_squared_deviation = v.into();
324 self
325 }
326
327 /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
328 pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
329 where
330 T: std::iter::IntoIterator<Item = V>,
331 V: std::convert::Into<i64>,
332 {
333 use std::iter::Iterator;
334 self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
335 self
336 }
337
338 /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
339 pub fn set_exemplars<T, V>(mut self, v: T) -> Self
340 where
341 T: std::iter::IntoIterator<Item = V>,
342 V: std::convert::Into<api::model::distribution::Exemplar>,
343 {
344 use std::iter::Iterator;
345 self.exemplars = v.into_iter().map(|i| i.into()).collect();
346 self
347 }
348
349 /// Sets the value of `bucket_option`.
350 pub fn set_bucket_option<
351 T: std::convert::Into<std::option::Option<crate::model::distribution::BucketOption>>,
352 >(
353 mut self,
354 v: T,
355 ) -> Self {
356 self.bucket_option = v.into();
357 self
358 }
359
360 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
361 /// if it holds a `LinearBuckets`, `None` if the field is not set or
362 /// holds a different branch.
363 pub fn get_linear_buckets(
364 &self,
365 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::LinearBuckets>> {
366 #[allow(unreachable_patterns)]
367 self.bucket_option.as_ref().and_then(|v| match v {
368 crate::model::distribution::BucketOption::LinearBuckets(v) => {
369 std::option::Option::Some(v)
370 }
371 _ => std::option::Option::None,
372 })
373 }
374
375 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
376 /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
377 /// holds a different branch.
378 pub fn get_exponential_buckets(
379 &self,
380 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExponentialBuckets>> {
381 #[allow(unreachable_patterns)]
382 self.bucket_option.as_ref().and_then(|v| match v {
383 crate::model::distribution::BucketOption::ExponentialBuckets(v) => {
384 std::option::Option::Some(v)
385 }
386 _ => std::option::Option::None,
387 })
388 }
389
390 /// The value of [bucket_option][crate::model::Distribution::bucket_option]
391 /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
392 /// holds a different branch.
393 pub fn get_explicit_buckets(
394 &self,
395 ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExplicitBuckets>> {
396 #[allow(unreachable_patterns)]
397 self.bucket_option.as_ref().and_then(|v| match v {
398 crate::model::distribution::BucketOption::ExplicitBuckets(v) => {
399 std::option::Option::Some(v)
400 }
401 _ => std::option::Option::None,
402 })
403 }
404
405 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
406 /// to hold a `LinearBuckets`.
407 ///
408 /// Note that all the setters affecting `bucket_option` are
409 /// mutually exclusive.
410 pub fn set_linear_buckets<
411 T: std::convert::Into<std::boxed::Box<crate::model::distribution::LinearBuckets>>,
412 >(
413 mut self,
414 v: T,
415 ) -> Self {
416 self.bucket_option = std::option::Option::Some(
417 crate::model::distribution::BucketOption::LinearBuckets(v.into()),
418 );
419 self
420 }
421
422 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
423 /// to hold a `ExponentialBuckets`.
424 ///
425 /// Note that all the setters affecting `bucket_option` are
426 /// mutually exclusive.
427 pub fn set_exponential_buckets<
428 T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExponentialBuckets>>,
429 >(
430 mut self,
431 v: T,
432 ) -> Self {
433 self.bucket_option = std::option::Option::Some(
434 crate::model::distribution::BucketOption::ExponentialBuckets(v.into()),
435 );
436 self
437 }
438
439 /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
440 /// to hold a `ExplicitBuckets`.
441 ///
442 /// Note that all the setters affecting `bucket_option` are
443 /// mutually exclusive.
444 pub fn set_explicit_buckets<
445 T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExplicitBuckets>>,
446 >(
447 mut self,
448 v: T,
449 ) -> Self {
450 self.bucket_option = std::option::Option::Some(
451 crate::model::distribution::BucketOption::ExplicitBuckets(v.into()),
452 );
453 self
454 }
455}
456
457impl wkt::message::Message for Distribution {
458 fn typename() -> &'static str {
459 "type.googleapis.com/google.api.servicecontrol.v1.Distribution"
460 }
461}
462
463/// Defines additional types related to Distribution
464pub mod distribution {
465 #[allow(unused_imports)]
466 use super::*;
467
468 /// Describing buckets with constant width.
469 #[serde_with::serde_as]
470 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
471 #[serde(default, rename_all = "camelCase")]
472 #[non_exhaustive]
473 pub struct LinearBuckets {
474 /// The number of finite buckets. With the underflow and overflow buckets,
475 /// the total number of buckets is `num_finite_buckets` + 2.
476 /// See comments on `bucket_options` for details.
477 pub num_finite_buckets: i32,
478
479 /// The i'th linear bucket covers the interval
480 /// [offset + (i-1) * width, offset + i * width)
481 /// where i ranges from 1 to num_finite_buckets, inclusive.
482 /// Must be strictly positive.
483 pub width: f64,
484
485 /// The i'th linear bucket covers the interval
486 /// [offset + (i-1) * width, offset + i * width)
487 /// where i ranges from 1 to num_finite_buckets, inclusive.
488 pub offset: f64,
489 }
490
491 impl LinearBuckets {
492 pub fn new() -> Self {
493 std::default::Default::default()
494 }
495
496 /// Sets the value of [num_finite_buckets][crate::model::distribution::LinearBuckets::num_finite_buckets].
497 pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
498 self.num_finite_buckets = v.into();
499 self
500 }
501
502 /// Sets the value of [width][crate::model::distribution::LinearBuckets::width].
503 pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
504 self.width = v.into();
505 self
506 }
507
508 /// Sets the value of [offset][crate::model::distribution::LinearBuckets::offset].
509 pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
510 self.offset = v.into();
511 self
512 }
513 }
514
515 impl wkt::message::Message for LinearBuckets {
516 fn typename() -> &'static str {
517 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.LinearBuckets"
518 }
519 }
520
521 /// Describing buckets with exponentially growing width.
522 #[serde_with::serde_as]
523 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
524 #[serde(default, rename_all = "camelCase")]
525 #[non_exhaustive]
526 pub struct ExponentialBuckets {
527 /// The number of finite buckets. With the underflow and overflow buckets,
528 /// the total number of buckets is `num_finite_buckets` + 2.
529 /// See comments on `bucket_options` for details.
530 pub num_finite_buckets: i32,
531
532 /// The i'th exponential bucket covers the interval
533 /// [scale * growth_factor^(i-1), scale * growth_factor^i)
534 /// where i ranges from 1 to num_finite_buckets inclusive.
535 /// Must be larger than 1.0.
536 pub growth_factor: f64,
537
538 /// The i'th exponential bucket covers the interval
539 /// [scale * growth_factor^(i-1), scale * growth_factor^i)
540 /// where i ranges from 1 to num_finite_buckets inclusive.
541 /// Must be > 0.
542 pub scale: f64,
543 }
544
545 impl ExponentialBuckets {
546 pub fn new() -> Self {
547 std::default::Default::default()
548 }
549
550 /// Sets the value of [num_finite_buckets][crate::model::distribution::ExponentialBuckets::num_finite_buckets].
551 pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
552 self.num_finite_buckets = v.into();
553 self
554 }
555
556 /// Sets the value of [growth_factor][crate::model::distribution::ExponentialBuckets::growth_factor].
557 pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
558 self.growth_factor = v.into();
559 self
560 }
561
562 /// Sets the value of [scale][crate::model::distribution::ExponentialBuckets::scale].
563 pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
564 self.scale = v.into();
565 self
566 }
567 }
568
569 impl wkt::message::Message for ExponentialBuckets {
570 fn typename() -> &'static str {
571 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExponentialBuckets"
572 }
573 }
574
575 /// Describing buckets with arbitrary user-provided width.
576 #[serde_with::serde_as]
577 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
578 #[serde(default, rename_all = "camelCase")]
579 #[non_exhaustive]
580 pub struct ExplicitBuckets {
581 /// 'bound' is a list of strictly increasing boundaries between
582 /// buckets. Note that a list of length N-1 defines N buckets because
583 /// of fenceposting. See comments on `bucket_options` for details.
584 ///
585 /// The i'th finite bucket covers the interval
586 /// [bound[i-1], bound[i])
587 /// where i ranges from 1 to bound_size() - 1. Note that there are no
588 /// finite buckets at all if 'bound' only contains a single element; in
589 /// that special case the single bound defines the boundary between the
590 /// underflow and overflow buckets.
591 ///
592 /// bucket number lower bound upper bound
593 /// i == 0 (underflow) -inf bound[i]
594 /// 0 < i < bound_size() bound[i-1] bound[i]
595 /// i == bound_size() (overflow) bound[i-1] +inf
596 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
597 pub bounds: std::vec::Vec<f64>,
598 }
599
600 impl ExplicitBuckets {
601 pub fn new() -> Self {
602 std::default::Default::default()
603 }
604
605 /// Sets the value of [bounds][crate::model::distribution::ExplicitBuckets::bounds].
606 pub fn set_bounds<T, V>(mut self, v: T) -> Self
607 where
608 T: std::iter::IntoIterator<Item = V>,
609 V: std::convert::Into<f64>,
610 {
611 use std::iter::Iterator;
612 self.bounds = v.into_iter().map(|i| i.into()).collect();
613 self
614 }
615 }
616
617 impl wkt::message::Message for ExplicitBuckets {
618 fn typename() -> &'static str {
619 "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExplicitBuckets"
620 }
621 }
622
623 /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
624 /// must be both set, or both unset.
625 ///
626 /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
627 /// There must be at least two buckets (a single-bucket histogram gives
628 /// no information that isn't already provided by `count`).
629 ///
630 /// The first bucket is the underflow bucket which has a lower bound
631 /// of -inf. The last bucket is the overflow bucket which has an
632 /// upper bound of +inf. All other buckets (if any) are called "finite"
633 /// buckets because they have finite lower and upper bounds. As described
634 /// below, there are three ways to define the finite buckets.
635 ///
636 /// (1) Buckets with constant width.
637 /// (2) Buckets with exponentially growing widths.
638 /// (3) Buckets with arbitrary user-provided widths.
639 ///
640 /// In all cases, the buckets cover the entire real number line (-inf,
641 /// +inf). Bucket upper bounds are exclusive and lower bounds are
642 /// inclusive. The upper bound of the underflow bucket is equal to the
643 /// lower bound of the smallest finite bucket; the lower bound of the
644 /// overflow bucket is equal to the upper bound of the largest finite
645 /// bucket.
646 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
647 #[serde(rename_all = "camelCase")]
648 #[non_exhaustive]
649 pub enum BucketOption {
650 /// Buckets with constant width.
651 LinearBuckets(std::boxed::Box<crate::model::distribution::LinearBuckets>),
652 /// Buckets with exponentially growing width.
653 ExponentialBuckets(std::boxed::Box<crate::model::distribution::ExponentialBuckets>),
654 /// Buckets with arbitrary user-provided width.
655 ExplicitBuckets(std::boxed::Box<crate::model::distribution::ExplicitBuckets>),
656 }
657}
658
659/// A common proto for logging HTTP requests. Only contains semantics
660/// defined by the HTTP specification. Product-specific logging
661/// information MUST be defined in a separate message.
662#[serde_with::serde_as]
663#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
664#[serde(default, rename_all = "camelCase")]
665#[non_exhaustive]
666pub struct HttpRequest {
667 /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
668 #[serde(skip_serializing_if = "std::string::String::is_empty")]
669 pub request_method: std::string::String,
670
671 /// The scheme (http, https), the host name, the path, and the query
672 /// portion of the URL that was requested.
673 /// Example: ``http://example.com/some/info?color=red``.
674 #[serde(skip_serializing_if = "std::string::String::is_empty")]
675 pub request_url: std::string::String,
676
677 /// The size of the HTTP request message in bytes, including the request
678 /// headers and the request body.
679 #[serde_as(as = "serde_with::DisplayFromStr")]
680 pub request_size: i64,
681
682 /// The response code indicating the status of the response.
683 /// Examples: 200, 404.
684 pub status: i32,
685
686 /// The size of the HTTP response message sent back to the client, in bytes,
687 /// including the response headers and the response body.
688 #[serde_as(as = "serde_with::DisplayFromStr")]
689 pub response_size: i64,
690
691 /// The user agent sent by the client. Example:
692 /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
693 /// CLR 1.0.3705)"`.
694 #[serde(skip_serializing_if = "std::string::String::is_empty")]
695 pub user_agent: std::string::String,
696
697 /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
698 /// request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
699 #[serde(skip_serializing_if = "std::string::String::is_empty")]
700 pub remote_ip: std::string::String,
701
702 /// The IP address (IPv4 or IPv6) of the origin server that the request was
703 /// sent to.
704 #[serde(skip_serializing_if = "std::string::String::is_empty")]
705 pub server_ip: std::string::String,
706
707 /// The referer URL of the request, as defined in
708 /// [HTTP/1.1 Header Field
709 /// Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
710 #[serde(skip_serializing_if = "std::string::String::is_empty")]
711 pub referer: std::string::String,
712
713 /// The request processing latency on the server, from the time the request was
714 /// received until the response was sent.
715 #[serde(skip_serializing_if = "std::option::Option::is_none")]
716 pub latency: std::option::Option<wkt::Duration>,
717
718 /// Whether or not a cache lookup was attempted.
719 pub cache_lookup: bool,
720
721 /// Whether or not an entity was served from cache
722 /// (with or without validation).
723 pub cache_hit: bool,
724
725 /// Whether or not the response was validated with the origin server before
726 /// being served from cache. This field is only meaningful if `cache_hit` is
727 /// True.
728 pub cache_validated_with_origin_server: bool,
729
730 /// The number of HTTP response bytes inserted into cache. Set only when a
731 /// cache fill was attempted.
732 #[serde_as(as = "serde_with::DisplayFromStr")]
733 pub cache_fill_bytes: i64,
734
735 /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
736 #[serde(skip_serializing_if = "std::string::String::is_empty")]
737 pub protocol: std::string::String,
738}
739
740impl HttpRequest {
741 pub fn new() -> Self {
742 std::default::Default::default()
743 }
744
745 /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
746 pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
747 self.request_method = v.into();
748 self
749 }
750
751 /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
752 pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
753 self.request_url = v.into();
754 self
755 }
756
757 /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
758 pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
759 self.request_size = v.into();
760 self
761 }
762
763 /// Sets the value of [status][crate::model::HttpRequest::status].
764 pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
765 self.status = v.into();
766 self
767 }
768
769 /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
770 pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
771 self.response_size = v.into();
772 self
773 }
774
775 /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
776 pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
777 self.user_agent = v.into();
778 self
779 }
780
781 /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
782 pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
783 self.remote_ip = v.into();
784 self
785 }
786
787 /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
788 pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
789 self.server_ip = v.into();
790 self
791 }
792
793 /// Sets the value of [referer][crate::model::HttpRequest::referer].
794 pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
795 self.referer = v.into();
796 self
797 }
798
799 /// Sets the value of [latency][crate::model::HttpRequest::latency].
800 pub fn set_latency<T: std::convert::Into<std::option::Option<wkt::Duration>>>(
801 mut self,
802 v: T,
803 ) -> Self {
804 self.latency = v.into();
805 self
806 }
807
808 /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
809 pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
810 self.cache_lookup = v.into();
811 self
812 }
813
814 /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
815 pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
816 self.cache_hit = v.into();
817 self
818 }
819
820 /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
821 pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
822 mut self,
823 v: T,
824 ) -> Self {
825 self.cache_validated_with_origin_server = v.into();
826 self
827 }
828
829 /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
830 pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
831 self.cache_fill_bytes = v.into();
832 self
833 }
834
835 /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
836 pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
837 self.protocol = v.into();
838 self
839 }
840}
841
842impl wkt::message::Message for HttpRequest {
843 fn typename() -> &'static str {
844 "type.googleapis.com/google.api.servicecontrol.v1.HttpRequest"
845 }
846}
847
848/// An individual log entry.
849#[serde_with::serde_as]
850#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
851#[serde(default, rename_all = "camelCase")]
852#[non_exhaustive]
853pub struct LogEntry {
854 /// Required. The log to which this log entry belongs. Examples: `"syslog"`,
855 /// `"book_log"`.
856 #[serde(skip_serializing_if = "std::string::String::is_empty")]
857 pub name: std::string::String,
858
859 /// The time the event described by the log entry occurred. If
860 /// omitted, defaults to operation start time.
861 #[serde(skip_serializing_if = "std::option::Option::is_none")]
862 pub timestamp: std::option::Option<wkt::Timestamp>,
863
864 /// The severity of the log entry. The default value is
865 /// `LogSeverity.DEFAULT`.
866 pub severity: logging_type::model::LogSeverity,
867
868 /// Optional. Information about the HTTP request associated with this
869 /// log entry, if applicable.
870 #[serde(skip_serializing_if = "std::option::Option::is_none")]
871 pub http_request: std::option::Option<crate::model::HttpRequest>,
872
873 /// Optional. Resource name of the trace associated with the log entry, if any.
874 /// If this field contains a relative resource name, you can assume the name is
875 /// relative to `//tracing.googleapis.com`. Example:
876 /// `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824`
877 #[serde(skip_serializing_if = "std::string::String::is_empty")]
878 pub trace: std::string::String,
879
880 /// A unique ID for the log entry used for deduplication. If omitted,
881 /// the implementation will generate one based on operation_id.
882 #[serde(skip_serializing_if = "std::string::String::is_empty")]
883 pub insert_id: std::string::String,
884
885 /// A set of user-defined (key, value) data that provides additional
886 /// information about the log entry.
887 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
888 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
889
890 /// Optional. Information about an operation associated with the log entry, if
891 /// applicable.
892 #[serde(skip_serializing_if = "std::option::Option::is_none")]
893 pub operation: std::option::Option<crate::model::LogEntryOperation>,
894
895 /// Optional. Source code location information associated with the log entry,
896 /// if any.
897 #[serde(skip_serializing_if = "std::option::Option::is_none")]
898 pub source_location: std::option::Option<crate::model::LogEntrySourceLocation>,
899
900 /// The log entry payload, which can be one of multiple types.
901 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
902 pub payload: std::option::Option<crate::model::log_entry::Payload>,
903}
904
905impl LogEntry {
906 pub fn new() -> Self {
907 std::default::Default::default()
908 }
909
910 /// Sets the value of [name][crate::model::LogEntry::name].
911 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
912 self.name = v.into();
913 self
914 }
915
916 /// Sets the value of [timestamp][crate::model::LogEntry::timestamp].
917 pub fn set_timestamp<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
918 mut self,
919 v: T,
920 ) -> Self {
921 self.timestamp = v.into();
922 self
923 }
924
925 /// Sets the value of [severity][crate::model::LogEntry::severity].
926 pub fn set_severity<T: std::convert::Into<logging_type::model::LogSeverity>>(
927 mut self,
928 v: T,
929 ) -> Self {
930 self.severity = v.into();
931 self
932 }
933
934 /// Sets the value of [http_request][crate::model::LogEntry::http_request].
935 pub fn set_http_request<
936 T: std::convert::Into<std::option::Option<crate::model::HttpRequest>>,
937 >(
938 mut self,
939 v: T,
940 ) -> Self {
941 self.http_request = v.into();
942 self
943 }
944
945 /// Sets the value of [trace][crate::model::LogEntry::trace].
946 pub fn set_trace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
947 self.trace = v.into();
948 self
949 }
950
951 /// Sets the value of [insert_id][crate::model::LogEntry::insert_id].
952 pub fn set_insert_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
953 self.insert_id = v.into();
954 self
955 }
956
957 /// Sets the value of [operation][crate::model::LogEntry::operation].
958 pub fn set_operation<
959 T: std::convert::Into<std::option::Option<crate::model::LogEntryOperation>>,
960 >(
961 mut self,
962 v: T,
963 ) -> Self {
964 self.operation = v.into();
965 self
966 }
967
968 /// Sets the value of [source_location][crate::model::LogEntry::source_location].
969 pub fn set_source_location<
970 T: std::convert::Into<std::option::Option<crate::model::LogEntrySourceLocation>>,
971 >(
972 mut self,
973 v: T,
974 ) -> Self {
975 self.source_location = v.into();
976 self
977 }
978
979 /// Sets the value of [labels][crate::model::LogEntry::labels].
980 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
981 where
982 T: std::iter::IntoIterator<Item = (K, V)>,
983 K: std::convert::Into<std::string::String>,
984 V: std::convert::Into<std::string::String>,
985 {
986 use std::iter::Iterator;
987 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
988 self
989 }
990
991 /// Sets the value of `payload`.
992 pub fn set_payload<
993 T: std::convert::Into<std::option::Option<crate::model::log_entry::Payload>>,
994 >(
995 mut self,
996 v: T,
997 ) -> Self {
998 self.payload = v.into();
999 self
1000 }
1001
1002 /// The value of [payload][crate::model::LogEntry::payload]
1003 /// if it holds a `ProtoPayload`, `None` if the field is not set or
1004 /// holds a different branch.
1005 pub fn get_proto_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Any>> {
1006 #[allow(unreachable_patterns)]
1007 self.payload.as_ref().and_then(|v| match v {
1008 crate::model::log_entry::Payload::ProtoPayload(v) => std::option::Option::Some(v),
1009 _ => std::option::Option::None,
1010 })
1011 }
1012
1013 /// The value of [payload][crate::model::LogEntry::payload]
1014 /// if it holds a `TextPayload`, `None` if the field is not set or
1015 /// holds a different branch.
1016 pub fn get_text_payload(&self) -> std::option::Option<&std::string::String> {
1017 #[allow(unreachable_patterns)]
1018 self.payload.as_ref().and_then(|v| match v {
1019 crate::model::log_entry::Payload::TextPayload(v) => std::option::Option::Some(v),
1020 _ => std::option::Option::None,
1021 })
1022 }
1023
1024 /// The value of [payload][crate::model::LogEntry::payload]
1025 /// if it holds a `StructPayload`, `None` if the field is not set or
1026 /// holds a different branch.
1027 pub fn get_struct_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Struct>> {
1028 #[allow(unreachable_patterns)]
1029 self.payload.as_ref().and_then(|v| match v {
1030 crate::model::log_entry::Payload::StructPayload(v) => std::option::Option::Some(v),
1031 _ => std::option::Option::None,
1032 })
1033 }
1034
1035 /// Sets the value of [payload][crate::model::LogEntry::payload]
1036 /// to hold a `ProtoPayload`.
1037 ///
1038 /// Note that all the setters affecting `payload` are
1039 /// mutually exclusive.
1040 pub fn set_proto_payload<T: std::convert::Into<std::boxed::Box<wkt::Any>>>(
1041 mut self,
1042 v: T,
1043 ) -> Self {
1044 self.payload =
1045 std::option::Option::Some(crate::model::log_entry::Payload::ProtoPayload(v.into()));
1046 self
1047 }
1048
1049 /// Sets the value of [payload][crate::model::LogEntry::payload]
1050 /// to hold a `TextPayload`.
1051 ///
1052 /// Note that all the setters affecting `payload` are
1053 /// mutually exclusive.
1054 pub fn set_text_payload<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1055 self.payload =
1056 std::option::Option::Some(crate::model::log_entry::Payload::TextPayload(v.into()));
1057 self
1058 }
1059
1060 /// Sets the value of [payload][crate::model::LogEntry::payload]
1061 /// to hold a `StructPayload`.
1062 ///
1063 /// Note that all the setters affecting `payload` are
1064 /// mutually exclusive.
1065 pub fn set_struct_payload<T: std::convert::Into<std::boxed::Box<wkt::Struct>>>(
1066 mut self,
1067 v: T,
1068 ) -> Self {
1069 self.payload =
1070 std::option::Option::Some(crate::model::log_entry::Payload::StructPayload(v.into()));
1071 self
1072 }
1073}
1074
1075impl wkt::message::Message for LogEntry {
1076 fn typename() -> &'static str {
1077 "type.googleapis.com/google.api.servicecontrol.v1.LogEntry"
1078 }
1079}
1080
1081/// Defines additional types related to LogEntry
1082pub mod log_entry {
1083 #[allow(unused_imports)]
1084 use super::*;
1085
1086 /// The log entry payload, which can be one of multiple types.
1087 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
1088 #[serde(rename_all = "camelCase")]
1089 #[non_exhaustive]
1090 pub enum Payload {
1091 /// The log entry payload, represented as a protocol buffer that is
1092 /// expressed as a JSON object. The only accepted type currently is
1093 /// [AuditLog][google.cloud.audit.AuditLog].
1094 ProtoPayload(std::boxed::Box<wkt::Any>),
1095 /// The log entry payload, represented as a Unicode string (UTF-8).
1096 TextPayload(std::string::String),
1097 /// The log entry payload, represented as a structure that
1098 /// is expressed as a JSON object.
1099 StructPayload(std::boxed::Box<wkt::Struct>),
1100 }
1101}
1102
1103/// Additional information about a potentially long-running operation with which
1104/// a log entry is associated.
1105#[serde_with::serde_as]
1106#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1107#[serde(default, rename_all = "camelCase")]
1108#[non_exhaustive]
1109pub struct LogEntryOperation {
1110 /// Optional. An arbitrary operation identifier. Log entries with the
1111 /// same identifier are assumed to be part of the same operation.
1112 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1113 pub id: std::string::String,
1114
1115 /// Optional. An arbitrary producer identifier. The combination of
1116 /// `id` and `producer` must be globally unique. Examples for `producer`:
1117 /// `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`.
1118 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1119 pub producer: std::string::String,
1120
1121 /// Optional. Set this to True if this is the first log entry in the operation.
1122 pub first: bool,
1123
1124 /// Optional. Set this to True if this is the last log entry in the operation.
1125 pub last: bool,
1126}
1127
1128impl LogEntryOperation {
1129 pub fn new() -> Self {
1130 std::default::Default::default()
1131 }
1132
1133 /// Sets the value of [id][crate::model::LogEntryOperation::id].
1134 pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1135 self.id = v.into();
1136 self
1137 }
1138
1139 /// Sets the value of [producer][crate::model::LogEntryOperation::producer].
1140 pub fn set_producer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1141 self.producer = v.into();
1142 self
1143 }
1144
1145 /// Sets the value of [first][crate::model::LogEntryOperation::first].
1146 pub fn set_first<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1147 self.first = v.into();
1148 self
1149 }
1150
1151 /// Sets the value of [last][crate::model::LogEntryOperation::last].
1152 pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1153 self.last = v.into();
1154 self
1155 }
1156}
1157
1158impl wkt::message::Message for LogEntryOperation {
1159 fn typename() -> &'static str {
1160 "type.googleapis.com/google.api.servicecontrol.v1.LogEntryOperation"
1161 }
1162}
1163
1164/// Additional information about the source code location that produced the log
1165/// entry.
1166#[serde_with::serde_as]
1167#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1168#[serde(default, rename_all = "camelCase")]
1169#[non_exhaustive]
1170pub struct LogEntrySourceLocation {
1171 /// Optional. Source file name. Depending on the runtime environment, this
1172 /// might be a simple name or a fully-qualified name.
1173 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1174 pub file: std::string::String,
1175
1176 /// Optional. Line within the source file. 1-based; 0 indicates no line number
1177 /// available.
1178 #[serde_as(as = "serde_with::DisplayFromStr")]
1179 pub line: i64,
1180
1181 /// Optional. Human-readable name of the function or method being invoked, with
1182 /// optional context such as the class or package name. This information may be
1183 /// used in contexts such as the logs viewer, where a file and line number are
1184 /// less meaningful. The format can vary by language. For example:
1185 /// `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function`
1186 /// (Python).
1187 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1188 pub function: std::string::String,
1189}
1190
1191impl LogEntrySourceLocation {
1192 pub fn new() -> Self {
1193 std::default::Default::default()
1194 }
1195
1196 /// Sets the value of [file][crate::model::LogEntrySourceLocation::file].
1197 pub fn set_file<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1198 self.file = v.into();
1199 self
1200 }
1201
1202 /// Sets the value of [line][crate::model::LogEntrySourceLocation::line].
1203 pub fn set_line<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1204 self.line = v.into();
1205 self
1206 }
1207
1208 /// Sets the value of [function][crate::model::LogEntrySourceLocation::function].
1209 pub fn set_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1210 self.function = v.into();
1211 self
1212 }
1213}
1214
1215impl wkt::message::Message for LogEntrySourceLocation {
1216 fn typename() -> &'static str {
1217 "type.googleapis.com/google.api.servicecontrol.v1.LogEntrySourceLocation"
1218 }
1219}
1220
1221/// Represents a single metric value.
1222#[serde_with::serde_as]
1223#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1224#[serde(default, rename_all = "camelCase")]
1225#[non_exhaustive]
1226pub struct MetricValue {
1227 /// The labels describing the metric value.
1228 /// See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for
1229 /// the overriding relationship.
1230 /// Note that this map must not contain monitored resource labels.
1231 ///
1232 /// [google.api.servicecontrol.v1.Operation.labels]: crate::model::Operation::labels
1233 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
1234 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1235
1236 /// The start of the time period over which this metric value's measurement
1237 /// applies. The time period has different semantics for different metric
1238 /// types (cumulative, delta, and gauge). See the metric definition
1239 /// documentation in the service configuration for details. If not specified,
1240 /// [google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time] will be used.
1241 ///
1242 /// [google.api.servicecontrol.v1.Operation.start_time]: crate::model::Operation::start_time
1243 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1244 pub start_time: std::option::Option<wkt::Timestamp>,
1245
1246 /// The end of the time period over which this metric value's measurement
1247 /// applies. If not specified,
1248 /// [google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time] will be used.
1249 ///
1250 /// [google.api.servicecontrol.v1.Operation.end_time]: crate::model::Operation::end_time
1251 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1252 pub end_time: std::option::Option<wkt::Timestamp>,
1253
1254 /// The value. The type of value used in the request must
1255 /// agree with the metric definition in the service configuration, otherwise
1256 /// the MetricValue is rejected.
1257 #[serde(flatten, skip_serializing_if = "std::option::Option::is_none")]
1258 pub value: std::option::Option<crate::model::metric_value::Value>,
1259}
1260
1261impl MetricValue {
1262 pub fn new() -> Self {
1263 std::default::Default::default()
1264 }
1265
1266 /// Sets the value of [start_time][crate::model::MetricValue::start_time].
1267 pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1268 mut self,
1269 v: T,
1270 ) -> Self {
1271 self.start_time = v.into();
1272 self
1273 }
1274
1275 /// Sets the value of [end_time][crate::model::MetricValue::end_time].
1276 pub fn set_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1277 mut self,
1278 v: T,
1279 ) -> Self {
1280 self.end_time = v.into();
1281 self
1282 }
1283
1284 /// Sets the value of [labels][crate::model::MetricValue::labels].
1285 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1286 where
1287 T: std::iter::IntoIterator<Item = (K, V)>,
1288 K: std::convert::Into<std::string::String>,
1289 V: std::convert::Into<std::string::String>,
1290 {
1291 use std::iter::Iterator;
1292 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1293 self
1294 }
1295
1296 /// Sets the value of `value`.
1297 pub fn set_value<
1298 T: std::convert::Into<std::option::Option<crate::model::metric_value::Value>>,
1299 >(
1300 mut self,
1301 v: T,
1302 ) -> Self {
1303 self.value = v.into();
1304 self
1305 }
1306
1307 /// The value of [value][crate::model::MetricValue::value]
1308 /// if it holds a `BoolValue`, `None` if the field is not set or
1309 /// holds a different branch.
1310 pub fn get_bool_value(&self) -> std::option::Option<&bool> {
1311 #[allow(unreachable_patterns)]
1312 self.value.as_ref().and_then(|v| match v {
1313 crate::model::metric_value::Value::BoolValue(v) => std::option::Option::Some(v),
1314 _ => std::option::Option::None,
1315 })
1316 }
1317
1318 /// The value of [value][crate::model::MetricValue::value]
1319 /// if it holds a `Int64Value`, `None` if the field is not set or
1320 /// holds a different branch.
1321 pub fn get_int64_value(&self) -> std::option::Option<&i64> {
1322 #[allow(unreachable_patterns)]
1323 self.value.as_ref().and_then(|v| match v {
1324 crate::model::metric_value::Value::Int64Value(v) => std::option::Option::Some(v),
1325 _ => std::option::Option::None,
1326 })
1327 }
1328
1329 /// The value of [value][crate::model::MetricValue::value]
1330 /// if it holds a `DoubleValue`, `None` if the field is not set or
1331 /// holds a different branch.
1332 pub fn get_double_value(&self) -> std::option::Option<&f64> {
1333 #[allow(unreachable_patterns)]
1334 self.value.as_ref().and_then(|v| match v {
1335 crate::model::metric_value::Value::DoubleValue(v) => std::option::Option::Some(v),
1336 _ => std::option::Option::None,
1337 })
1338 }
1339
1340 /// The value of [value][crate::model::MetricValue::value]
1341 /// if it holds a `StringValue`, `None` if the field is not set or
1342 /// holds a different branch.
1343 pub fn get_string_value(&self) -> std::option::Option<&std::string::String> {
1344 #[allow(unreachable_patterns)]
1345 self.value.as_ref().and_then(|v| match v {
1346 crate::model::metric_value::Value::StringValue(v) => std::option::Option::Some(v),
1347 _ => std::option::Option::None,
1348 })
1349 }
1350
1351 /// The value of [value][crate::model::MetricValue::value]
1352 /// if it holds a `DistributionValue`, `None` if the field is not set or
1353 /// holds a different branch.
1354 pub fn get_distribution_value(
1355 &self,
1356 ) -> std::option::Option<&std::boxed::Box<crate::model::Distribution>> {
1357 #[allow(unreachable_patterns)]
1358 self.value.as_ref().and_then(|v| match v {
1359 crate::model::metric_value::Value::DistributionValue(v) => std::option::Option::Some(v),
1360 _ => std::option::Option::None,
1361 })
1362 }
1363
1364 /// Sets the value of [value][crate::model::MetricValue::value]
1365 /// to hold a `BoolValue`.
1366 ///
1367 /// Note that all the setters affecting `value` are
1368 /// mutually exclusive.
1369 pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1370 self.value =
1371 std::option::Option::Some(crate::model::metric_value::Value::BoolValue(v.into()));
1372 self
1373 }
1374
1375 /// Sets the value of [value][crate::model::MetricValue::value]
1376 /// to hold a `Int64Value`.
1377 ///
1378 /// Note that all the setters affecting `value` are
1379 /// mutually exclusive.
1380 pub fn set_int64_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1381 self.value =
1382 std::option::Option::Some(crate::model::metric_value::Value::Int64Value(v.into()));
1383 self
1384 }
1385
1386 /// Sets the value of [value][crate::model::MetricValue::value]
1387 /// to hold a `DoubleValue`.
1388 ///
1389 /// Note that all the setters affecting `value` are
1390 /// mutually exclusive.
1391 pub fn set_double_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1392 self.value =
1393 std::option::Option::Some(crate::model::metric_value::Value::DoubleValue(v.into()));
1394 self
1395 }
1396
1397 /// Sets the value of [value][crate::model::MetricValue::value]
1398 /// to hold a `StringValue`.
1399 ///
1400 /// Note that all the setters affecting `value` are
1401 /// mutually exclusive.
1402 pub fn set_string_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1403 self.value =
1404 std::option::Option::Some(crate::model::metric_value::Value::StringValue(v.into()));
1405 self
1406 }
1407
1408 /// Sets the value of [value][crate::model::MetricValue::value]
1409 /// to hold a `DistributionValue`.
1410 ///
1411 /// Note that all the setters affecting `value` are
1412 /// mutually exclusive.
1413 pub fn set_distribution_value<
1414 T: std::convert::Into<std::boxed::Box<crate::model::Distribution>>,
1415 >(
1416 mut self,
1417 v: T,
1418 ) -> Self {
1419 self.value = std::option::Option::Some(
1420 crate::model::metric_value::Value::DistributionValue(v.into()),
1421 );
1422 self
1423 }
1424}
1425
1426impl wkt::message::Message for MetricValue {
1427 fn typename() -> &'static str {
1428 "type.googleapis.com/google.api.servicecontrol.v1.MetricValue"
1429 }
1430}
1431
1432/// Defines additional types related to MetricValue
1433pub mod metric_value {
1434 #[allow(unused_imports)]
1435 use super::*;
1436
1437 /// The value. The type of value used in the request must
1438 /// agree with the metric definition in the service configuration, otherwise
1439 /// the MetricValue is rejected.
1440 #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
1441 #[serde(rename_all = "camelCase")]
1442 #[non_exhaustive]
1443 pub enum Value {
1444 /// A boolean value.
1445 BoolValue(bool),
1446 /// A signed 64-bit integer value.
1447 Int64Value(i64),
1448 /// A double precision floating point value.
1449 DoubleValue(f64),
1450 /// A text string value.
1451 StringValue(std::string::String),
1452 /// A distribution value.
1453 DistributionValue(std::boxed::Box<crate::model::Distribution>),
1454 }
1455}
1456
1457/// Represents a set of metric values in the same metric.
1458/// Each metric value in the set should have a unique combination of start time,
1459/// end time, and label values.
1460#[serde_with::serde_as]
1461#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1462#[serde(default, rename_all = "camelCase")]
1463#[non_exhaustive]
1464pub struct MetricValueSet {
1465 /// The metric name defined in the service configuration.
1466 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1467 pub metric_name: std::string::String,
1468
1469 /// The values in this metric.
1470 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1471 pub metric_values: std::vec::Vec<crate::model::MetricValue>,
1472}
1473
1474impl MetricValueSet {
1475 pub fn new() -> Self {
1476 std::default::Default::default()
1477 }
1478
1479 /// Sets the value of [metric_name][crate::model::MetricValueSet::metric_name].
1480 pub fn set_metric_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1481 self.metric_name = v.into();
1482 self
1483 }
1484
1485 /// Sets the value of [metric_values][crate::model::MetricValueSet::metric_values].
1486 pub fn set_metric_values<T, V>(mut self, v: T) -> Self
1487 where
1488 T: std::iter::IntoIterator<Item = V>,
1489 V: std::convert::Into<crate::model::MetricValue>,
1490 {
1491 use std::iter::Iterator;
1492 self.metric_values = v.into_iter().map(|i| i.into()).collect();
1493 self
1494 }
1495}
1496
1497impl wkt::message::Message for MetricValueSet {
1498 fn typename() -> &'static str {
1499 "type.googleapis.com/google.api.servicecontrol.v1.MetricValueSet"
1500 }
1501}
1502
1503/// Represents information regarding an operation.
1504#[serde_with::serde_as]
1505#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1506#[serde(default, rename_all = "camelCase")]
1507#[non_exhaustive]
1508pub struct Operation {
1509 /// Identity of the operation. This must be unique within the scope of the
1510 /// service that generated the operation. If the service calls
1511 /// Check() and Report() on the same operation, the two calls should carry
1512 /// the same id.
1513 ///
1514 /// UUID version 4 is recommended, though not required.
1515 /// In scenarios where an operation is computed from existing information
1516 /// and an idempotent id is desirable for deduplication purpose, UUID version 5
1517 /// is recommended. See RFC 4122 for details.
1518 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1519 pub operation_id: std::string::String,
1520
1521 /// Fully qualified name of the operation. Reserved for future use.
1522 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1523 pub operation_name: std::string::String,
1524
1525 /// Identity of the consumer who is using the service.
1526 /// This field should be filled in for the operations initiated by a
1527 /// consumer, but not for service-initiated operations that are
1528 /// not related to a specific consumer.
1529 ///
1530 /// - This can be in one of the following formats:
1531 /// - project:PROJECT_ID,
1532 /// - project`_`number:PROJECT_NUMBER,
1533 /// - projects/PROJECT_ID or PROJECT_NUMBER,
1534 /// - folders/FOLDER_NUMBER,
1535 /// - organizations/ORGANIZATION_NUMBER,
1536 /// - api`_`key:API_KEY.
1537 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1538 pub consumer_id: std::string::String,
1539
1540 /// Required. Start time of the operation.
1541 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1542 pub start_time: std::option::Option<wkt::Timestamp>,
1543
1544 /// End time of the operation.
1545 /// Required when the operation is used in
1546 /// [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report],
1547 /// but optional when the operation is used in
1548 /// [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check].
1549 ///
1550 /// [google.api.servicecontrol.v1.ServiceController.Check]: crate::client::ServiceController::check
1551 /// [google.api.servicecontrol.v1.ServiceController.Report]: crate::client::ServiceController::report
1552 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1553 pub end_time: std::option::Option<wkt::Timestamp>,
1554
1555 /// Labels describing the operation. Only the following labels are allowed:
1556 ///
1557 /// - Labels describing monitored resources as defined in
1558 /// the service configuration.
1559 /// - Default labels of metric values. When specified, labels defined in the
1560 /// metric value override these default.
1561 /// - The following labels defined by Google Cloud Platform:
1562 /// - `cloud.googleapis.com/location` describing the location where the
1563 /// operation happened,
1564 /// - `servicecontrol.googleapis.com/user_agent` describing the user agent
1565 /// of the API request,
1566 /// - `servicecontrol.googleapis.com/service_agent` describing the service
1567 /// used to handle the API request (e.g. ESP),
1568 /// - `servicecontrol.googleapis.com/platform` describing the platform
1569 /// where the API is served, such as App Engine, Compute Engine, or
1570 /// Kubernetes Engine.
1571 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
1572 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1573
1574 /// Represents information about this operation. Each MetricValueSet
1575 /// corresponds to a metric defined in the service configuration.
1576 /// The data type used in the MetricValueSet must agree with
1577 /// the data type specified in the metric definition.
1578 ///
1579 /// Within a single operation, it is not allowed to have more than one
1580 /// MetricValue instances that have the same metric names and identical
1581 /// label value combinations. If a request has such duplicated MetricValue
1582 /// instances, the entire request is rejected with
1583 /// an invalid argument error.
1584 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1585 pub metric_value_sets: std::vec::Vec<crate::model::MetricValueSet>,
1586
1587 /// Represents information to be logged.
1588 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1589 pub log_entries: std::vec::Vec<crate::model::LogEntry>,
1590
1591 /// DO NOT USE. This is an experimental field.
1592 pub importance: crate::model::operation::Importance,
1593
1594 /// Unimplemented.
1595 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1596 pub extensions: std::vec::Vec<wkt::Any>,
1597}
1598
1599impl Operation {
1600 pub fn new() -> Self {
1601 std::default::Default::default()
1602 }
1603
1604 /// Sets the value of [operation_id][crate::model::Operation::operation_id].
1605 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1606 self.operation_id = v.into();
1607 self
1608 }
1609
1610 /// Sets the value of [operation_name][crate::model::Operation::operation_name].
1611 pub fn set_operation_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1612 self.operation_name = v.into();
1613 self
1614 }
1615
1616 /// Sets the value of [consumer_id][crate::model::Operation::consumer_id].
1617 pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1618 self.consumer_id = v.into();
1619 self
1620 }
1621
1622 /// Sets the value of [start_time][crate::model::Operation::start_time].
1623 pub fn set_start_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1624 mut self,
1625 v: T,
1626 ) -> Self {
1627 self.start_time = v.into();
1628 self
1629 }
1630
1631 /// Sets the value of [end_time][crate::model::Operation::end_time].
1632 pub fn set_end_time<T: std::convert::Into<std::option::Option<wkt::Timestamp>>>(
1633 mut self,
1634 v: T,
1635 ) -> Self {
1636 self.end_time = v.into();
1637 self
1638 }
1639
1640 /// Sets the value of [importance][crate::model::Operation::importance].
1641 pub fn set_importance<T: std::convert::Into<crate::model::operation::Importance>>(
1642 mut self,
1643 v: T,
1644 ) -> Self {
1645 self.importance = v.into();
1646 self
1647 }
1648
1649 /// Sets the value of [metric_value_sets][crate::model::Operation::metric_value_sets].
1650 pub fn set_metric_value_sets<T, V>(mut self, v: T) -> Self
1651 where
1652 T: std::iter::IntoIterator<Item = V>,
1653 V: std::convert::Into<crate::model::MetricValueSet>,
1654 {
1655 use std::iter::Iterator;
1656 self.metric_value_sets = v.into_iter().map(|i| i.into()).collect();
1657 self
1658 }
1659
1660 /// Sets the value of [log_entries][crate::model::Operation::log_entries].
1661 pub fn set_log_entries<T, V>(mut self, v: T) -> Self
1662 where
1663 T: std::iter::IntoIterator<Item = V>,
1664 V: std::convert::Into<crate::model::LogEntry>,
1665 {
1666 use std::iter::Iterator;
1667 self.log_entries = v.into_iter().map(|i| i.into()).collect();
1668 self
1669 }
1670
1671 /// Sets the value of [extensions][crate::model::Operation::extensions].
1672 pub fn set_extensions<T, V>(mut self, v: T) -> Self
1673 where
1674 T: std::iter::IntoIterator<Item = V>,
1675 V: std::convert::Into<wkt::Any>,
1676 {
1677 use std::iter::Iterator;
1678 self.extensions = v.into_iter().map(|i| i.into()).collect();
1679 self
1680 }
1681
1682 /// Sets the value of [labels][crate::model::Operation::labels].
1683 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1684 where
1685 T: std::iter::IntoIterator<Item = (K, V)>,
1686 K: std::convert::Into<std::string::String>,
1687 V: std::convert::Into<std::string::String>,
1688 {
1689 use std::iter::Iterator;
1690 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1691 self
1692 }
1693}
1694
1695impl wkt::message::Message for Operation {
1696 fn typename() -> &'static str {
1697 "type.googleapis.com/google.api.servicecontrol.v1.Operation"
1698 }
1699}
1700
1701/// Defines additional types related to Operation
1702pub mod operation {
1703 #[allow(unused_imports)]
1704 use super::*;
1705
1706 /// Defines the importance of the data contained in the operation.
1707 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1708 pub struct Importance(std::borrow::Cow<'static, str>);
1709
1710 impl Importance {
1711 /// Creates a new Importance instance.
1712 pub const fn new(v: &'static str) -> Self {
1713 Self(std::borrow::Cow::Borrowed(v))
1714 }
1715
1716 /// Gets the enum value.
1717 pub fn value(&self) -> &str {
1718 &self.0
1719 }
1720 }
1721
1722 /// Useful constants to work with [Importance](Importance)
1723 pub mod importance {
1724 use super::Importance;
1725
1726 /// Allows data caching, batching, and aggregation. It provides
1727 /// higher performance with higher data loss risk.
1728 pub const LOW: Importance = Importance::new("LOW");
1729
1730 /// Disables data aggregation to minimize data loss. It is for operations
1731 /// that contains significant monetary value or audit trail. This feature
1732 /// only applies to the client libraries.
1733 pub const HIGH: Importance = Importance::new("HIGH");
1734 }
1735
1736 impl std::convert::From<std::string::String> for Importance {
1737 fn from(value: std::string::String) -> Self {
1738 Self(std::borrow::Cow::Owned(value))
1739 }
1740 }
1741}
1742
1743/// Request message for the AllocateQuota method.
1744#[serde_with::serde_as]
1745#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1746#[serde(default, rename_all = "camelCase")]
1747#[non_exhaustive]
1748pub struct AllocateQuotaRequest {
1749 /// Name of the service as specified in the service configuration. For example,
1750 /// `"pubsub.googleapis.com"`.
1751 ///
1752 /// See [google.api.Service][google.api.Service] for the definition of a service name.
1753 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1754 pub service_name: std::string::String,
1755
1756 /// Operation that describes the quota allocation.
1757 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1758 pub allocate_operation: std::option::Option<crate::model::QuotaOperation>,
1759
1760 /// Specifies which version of service configuration should be used to process
1761 /// the request. If unspecified or no matching version can be found, the latest
1762 /// one will be used.
1763 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1764 pub service_config_id: std::string::String,
1765}
1766
1767impl AllocateQuotaRequest {
1768 pub fn new() -> Self {
1769 std::default::Default::default()
1770 }
1771
1772 /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
1773 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1774 self.service_name = v.into();
1775 self
1776 }
1777
1778 /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
1779 pub fn set_allocate_operation<
1780 T: std::convert::Into<std::option::Option<crate::model::QuotaOperation>>,
1781 >(
1782 mut self,
1783 v: T,
1784 ) -> Self {
1785 self.allocate_operation = v.into();
1786 self
1787 }
1788
1789 /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
1790 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
1791 mut self,
1792 v: T,
1793 ) -> Self {
1794 self.service_config_id = v.into();
1795 self
1796 }
1797}
1798
1799impl wkt::message::Message for AllocateQuotaRequest {
1800 fn typename() -> &'static str {
1801 "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaRequest"
1802 }
1803}
1804
1805/// Represents information regarding a quota operation.
1806#[serde_with::serde_as]
1807#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1808#[serde(default, rename_all = "camelCase")]
1809#[non_exhaustive]
1810pub struct QuotaOperation {
1811 /// Identity of the operation. This is expected to be unique within the scope
1812 /// of the service that generated the operation, and guarantees idempotency in
1813 /// case of retries.
1814 ///
1815 /// In order to ensure best performance and latency in the Quota backends,
1816 /// operation_ids are optimally associated with time, so that related
1817 /// operations can be accessed fast in storage. For this reason, the
1818 /// recommended token for services that intend to operate at a high QPS is
1819 /// Unix time in nanos + UUID
1820 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1821 pub operation_id: std::string::String,
1822
1823 /// Fully qualified name of the API method for which this quota operation is
1824 /// requested. This name is used for matching quota rules or metric rules and
1825 /// billing status rules defined in service configuration.
1826 ///
1827 /// This field should not be set if any of the following is true:
1828 /// (1) the quota operation is performed on non-API resources.
1829 /// (2) quota_metrics is set because the caller is doing quota override.
1830 ///
1831 /// Example of an RPC method name:
1832 /// google.example.library.v1.LibraryService.CreateShelf
1833 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1834 pub method_name: std::string::String,
1835
1836 /// Identity of the consumer for whom this quota operation is being performed.
1837 ///
1838 /// This can be in one of the following formats:
1839 /// project:<project_id>,
1840 /// project_number:<project_number>,
1841 /// api_key:<api_key>.
1842 #[serde(skip_serializing_if = "std::string::String::is_empty")]
1843 pub consumer_id: std::string::String,
1844
1845 /// Labels describing the operation.
1846 #[serde(skip_serializing_if = "std::collections::HashMap::is_empty")]
1847 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
1848
1849 /// Represents information about this operation. Each MetricValueSet
1850 /// corresponds to a metric defined in the service configuration.
1851 /// The data type used in the MetricValueSet must agree with
1852 /// the data type specified in the metric definition.
1853 ///
1854 /// Within a single operation, it is not allowed to have more than one
1855 /// MetricValue instances that have the same metric names and identical
1856 /// label value combinations. If a request has such duplicated MetricValue
1857 /// instances, the entire request is rejected with
1858 /// an invalid argument error.
1859 ///
1860 /// This field is mutually exclusive with method_name.
1861 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
1862 pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
1863
1864 /// Quota mode for this operation.
1865 pub quota_mode: crate::model::quota_operation::QuotaMode,
1866}
1867
1868impl QuotaOperation {
1869 pub fn new() -> Self {
1870 std::default::Default::default()
1871 }
1872
1873 /// Sets the value of [operation_id][crate::model::QuotaOperation::operation_id].
1874 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1875 self.operation_id = v.into();
1876 self
1877 }
1878
1879 /// Sets the value of [method_name][crate::model::QuotaOperation::method_name].
1880 pub fn set_method_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1881 self.method_name = v.into();
1882 self
1883 }
1884
1885 /// Sets the value of [consumer_id][crate::model::QuotaOperation::consumer_id].
1886 pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1887 self.consumer_id = v.into();
1888 self
1889 }
1890
1891 /// Sets the value of [quota_mode][crate::model::QuotaOperation::quota_mode].
1892 pub fn set_quota_mode<T: std::convert::Into<crate::model::quota_operation::QuotaMode>>(
1893 mut self,
1894 v: T,
1895 ) -> Self {
1896 self.quota_mode = v.into();
1897 self
1898 }
1899
1900 /// Sets the value of [quota_metrics][crate::model::QuotaOperation::quota_metrics].
1901 pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
1902 where
1903 T: std::iter::IntoIterator<Item = V>,
1904 V: std::convert::Into<crate::model::MetricValueSet>,
1905 {
1906 use std::iter::Iterator;
1907 self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
1908 self
1909 }
1910
1911 /// Sets the value of [labels][crate::model::QuotaOperation::labels].
1912 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
1913 where
1914 T: std::iter::IntoIterator<Item = (K, V)>,
1915 K: std::convert::Into<std::string::String>,
1916 V: std::convert::Into<std::string::String>,
1917 {
1918 use std::iter::Iterator;
1919 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1920 self
1921 }
1922}
1923
1924impl wkt::message::Message for QuotaOperation {
1925 fn typename() -> &'static str {
1926 "type.googleapis.com/google.api.servicecontrol.v1.QuotaOperation"
1927 }
1928}
1929
1930/// Defines additional types related to QuotaOperation
1931pub mod quota_operation {
1932 #[allow(unused_imports)]
1933 use super::*;
1934
1935 /// Supported quota modes.
1936 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
1937 pub struct QuotaMode(std::borrow::Cow<'static, str>);
1938
1939 impl QuotaMode {
1940 /// Creates a new QuotaMode instance.
1941 pub const fn new(v: &'static str) -> Self {
1942 Self(std::borrow::Cow::Borrowed(v))
1943 }
1944
1945 /// Gets the enum value.
1946 pub fn value(&self) -> &str {
1947 &self.0
1948 }
1949 }
1950
1951 /// Useful constants to work with [QuotaMode](QuotaMode)
1952 pub mod quota_mode {
1953 use super::QuotaMode;
1954
1955 /// Guard against implicit default. Must not be used.
1956 pub const UNSPECIFIED: QuotaMode = QuotaMode::new("UNSPECIFIED");
1957
1958 /// For AllocateQuota request, allocates quota for the amount specified in
1959 /// the service configuration or specified using the quota metrics. If the
1960 /// amount is higher than the available quota, allocation error will be
1961 /// returned and no quota will be allocated.
1962 /// If multiple quotas are part of the request, and one fails, none of the
1963 /// quotas are allocated or released.
1964 pub const NORMAL: QuotaMode = QuotaMode::new("NORMAL");
1965
1966 /// The operation allocates quota for the amount specified in the service
1967 /// configuration or specified using the quota metrics. If the amount is
1968 /// higher than the available quota, request does not fail but all available
1969 /// quota will be allocated.
1970 /// For rate quota, BEST_EFFORT will continue to deduct from other groups
1971 /// even if one does not have enough quota. For allocation, it will find the
1972 /// minimum available amount across all groups and deduct that amount from
1973 /// all the affected groups.
1974 pub const BEST_EFFORT: QuotaMode = QuotaMode::new("BEST_EFFORT");
1975
1976 /// For AllocateQuota request, only checks if there is enough quota
1977 /// available and does not change the available quota. No lock is placed on
1978 /// the available quota either.
1979 pub const CHECK_ONLY: QuotaMode = QuotaMode::new("CHECK_ONLY");
1980
1981 /// Unimplemented. When used in AllocateQuotaRequest, this returns the
1982 /// effective quota limit(s) in the response, and no quota check will be
1983 /// performed. Not supported for other requests, and even for
1984 /// AllocateQuotaRequest, this is currently supported only for allowlisted
1985 /// services.
1986 pub const QUERY_ONLY: QuotaMode = QuotaMode::new("QUERY_ONLY");
1987
1988 /// The operation allocates quota for the amount specified in the service
1989 /// configuration or specified using the quota metrics. If the requested
1990 /// amount is higher than the available quota, request does not fail and
1991 /// remaining quota would become negative (going over the limit).
1992 /// Not supported for Rate Quota.
1993 pub const ADJUST_ONLY: QuotaMode = QuotaMode::new("ADJUST_ONLY");
1994 }
1995
1996 impl std::convert::From<std::string::String> for QuotaMode {
1997 fn from(value: std::string::String) -> Self {
1998 Self(std::borrow::Cow::Owned(value))
1999 }
2000 }
2001}
2002
2003/// Response message for the AllocateQuota method.
2004#[serde_with::serde_as]
2005#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2006#[serde(default, rename_all = "camelCase")]
2007#[non_exhaustive]
2008pub struct AllocateQuotaResponse {
2009 /// The same operation_id value used in the AllocateQuotaRequest. Used for
2010 /// logging and diagnostics purposes.
2011 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2012 pub operation_id: std::string::String,
2013
2014 /// Indicates the decision of the allocate.
2015 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2016 pub allocate_errors: std::vec::Vec<crate::model::QuotaError>,
2017
2018 /// Quota metrics to indicate the result of allocation. Depending on the
2019 /// request, one or more of the following metrics will be included:
2020 ///
2021 /// . Per quota group or per quota metric incremental usage will be specified
2022 /// using the following delta metric :
2023 /// "serviceruntime.googleapis.com/api/consumer/quota_used_count"
2024 ///
2025 /// . The quota limit reached condition will be specified using the following
2026 /// boolean metric :
2027 /// "serviceruntime.googleapis.com/quota/exceeded"
2028 ///
2029 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2030 pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
2031
2032 /// ID of the actual config used to process the request.
2033 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2034 pub service_config_id: std::string::String,
2035}
2036
2037impl AllocateQuotaResponse {
2038 pub fn new() -> Self {
2039 std::default::Default::default()
2040 }
2041
2042 /// Sets the value of [operation_id][crate::model::AllocateQuotaResponse::operation_id].
2043 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2044 self.operation_id = v.into();
2045 self
2046 }
2047
2048 /// Sets the value of [service_config_id][crate::model::AllocateQuotaResponse::service_config_id].
2049 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2050 mut self,
2051 v: T,
2052 ) -> Self {
2053 self.service_config_id = v.into();
2054 self
2055 }
2056
2057 /// Sets the value of [allocate_errors][crate::model::AllocateQuotaResponse::allocate_errors].
2058 pub fn set_allocate_errors<T, V>(mut self, v: T) -> Self
2059 where
2060 T: std::iter::IntoIterator<Item = V>,
2061 V: std::convert::Into<crate::model::QuotaError>,
2062 {
2063 use std::iter::Iterator;
2064 self.allocate_errors = v.into_iter().map(|i| i.into()).collect();
2065 self
2066 }
2067
2068 /// Sets the value of [quota_metrics][crate::model::AllocateQuotaResponse::quota_metrics].
2069 pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
2070 where
2071 T: std::iter::IntoIterator<Item = V>,
2072 V: std::convert::Into<crate::model::MetricValueSet>,
2073 {
2074 use std::iter::Iterator;
2075 self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
2076 self
2077 }
2078}
2079
2080impl wkt::message::Message for AllocateQuotaResponse {
2081 fn typename() -> &'static str {
2082 "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaResponse"
2083 }
2084}
2085
2086/// Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation].
2087///
2088/// [google.api.servicecontrol.v1.QuotaOperation]: crate::model::QuotaOperation
2089#[serde_with::serde_as]
2090#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2091#[serde(default, rename_all = "camelCase")]
2092#[non_exhaustive]
2093pub struct QuotaError {
2094 /// Error code.
2095 pub code: crate::model::quota_error::Code,
2096
2097 /// Subject to whom this error applies. See the specific enum for more details
2098 /// on this field. For example, "clientip:\<ip address of client\>" or
2099 /// "project:\<Google developer project id\>".
2100 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2101 pub subject: std::string::String,
2102
2103 /// Free-form text that provides details on the cause of the error.
2104 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2105 pub description: std::string::String,
2106
2107 /// Contains additional information about the quota error.
2108 /// If available, `status.code` will be non zero.
2109 #[serde(skip_serializing_if = "std::option::Option::is_none")]
2110 pub status: std::option::Option<rpc::model::Status>,
2111}
2112
2113impl QuotaError {
2114 pub fn new() -> Self {
2115 std::default::Default::default()
2116 }
2117
2118 /// Sets the value of [code][crate::model::QuotaError::code].
2119 pub fn set_code<T: std::convert::Into<crate::model::quota_error::Code>>(
2120 mut self,
2121 v: T,
2122 ) -> Self {
2123 self.code = v.into();
2124 self
2125 }
2126
2127 /// Sets the value of [subject][crate::model::QuotaError::subject].
2128 pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2129 self.subject = v.into();
2130 self
2131 }
2132
2133 /// Sets the value of [description][crate::model::QuotaError::description].
2134 pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2135 self.description = v.into();
2136 self
2137 }
2138
2139 /// Sets the value of [status][crate::model::QuotaError::status].
2140 pub fn set_status<T: std::convert::Into<std::option::Option<rpc::model::Status>>>(
2141 mut self,
2142 v: T,
2143 ) -> Self {
2144 self.status = v.into();
2145 self
2146 }
2147}
2148
2149impl wkt::message::Message for QuotaError {
2150 fn typename() -> &'static str {
2151 "type.googleapis.com/google.api.servicecontrol.v1.QuotaError"
2152 }
2153}
2154
2155/// Defines additional types related to QuotaError
2156pub mod quota_error {
2157 #[allow(unused_imports)]
2158 use super::*;
2159
2160 /// Error codes related to project config validations are deprecated since the
2161 /// quota controller methods do not perform these validations. Instead services
2162 /// have to call the Check method, without quota_properties field, to perform
2163 /// these validations before calling the quota controller methods. These
2164 /// methods check only for project deletion to be wipe out compliant.
2165 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2166 pub struct Code(std::borrow::Cow<'static, str>);
2167
2168 impl Code {
2169 /// Creates a new Code instance.
2170 pub const fn new(v: &'static str) -> Self {
2171 Self(std::borrow::Cow::Borrowed(v))
2172 }
2173
2174 /// Gets the enum value.
2175 pub fn value(&self) -> &str {
2176 &self.0
2177 }
2178 }
2179
2180 /// Useful constants to work with [Code](Code)
2181 pub mod code {
2182 use super::Code;
2183
2184 /// This is never used.
2185 pub const UNSPECIFIED: Code = Code::new("UNSPECIFIED");
2186
2187 /// Quota allocation failed.
2188 /// Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
2189 pub const RESOURCE_EXHAUSTED: Code = Code::new("RESOURCE_EXHAUSTED");
2190
2191 /// Consumer cannot access the service because the service requires active
2192 /// billing.
2193 pub const BILLING_NOT_ACTIVE: Code = Code::new("BILLING_NOT_ACTIVE");
2194
2195 /// Consumer's project has been marked as deleted (soft deletion).
2196 pub const PROJECT_DELETED: Code = Code::new("PROJECT_DELETED");
2197
2198 /// Specified API key is invalid.
2199 pub const API_KEY_INVALID: Code = Code::new("API_KEY_INVALID");
2200
2201 /// Specified API Key has expired.
2202 pub const API_KEY_EXPIRED: Code = Code::new("API_KEY_EXPIRED");
2203 }
2204
2205 impl std::convert::From<std::string::String> for Code {
2206 fn from(value: std::string::String) -> Self {
2207 Self(std::borrow::Cow::Owned(value))
2208 }
2209 }
2210}
2211
2212/// Request message for the Check method.
2213#[serde_with::serde_as]
2214#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2215#[serde(default, rename_all = "camelCase")]
2216#[non_exhaustive]
2217pub struct CheckRequest {
2218 /// The service name as specified in its service configuration. For example,
2219 /// `"pubsub.googleapis.com"`.
2220 ///
2221 /// See
2222 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
2223 /// for the definition of a service name.
2224 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2225 pub service_name: std::string::String,
2226
2227 /// The operation to be checked.
2228 #[serde(skip_serializing_if = "std::option::Option::is_none")]
2229 pub operation: std::option::Option<crate::model::Operation>,
2230
2231 /// Specifies which version of service configuration should be used to process
2232 /// the request.
2233 ///
2234 /// If unspecified or no matching version can be found, the
2235 /// latest one will be used.
2236 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2237 pub service_config_id: std::string::String,
2238}
2239
2240impl CheckRequest {
2241 pub fn new() -> Self {
2242 std::default::Default::default()
2243 }
2244
2245 /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
2246 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2247 self.service_name = v.into();
2248 self
2249 }
2250
2251 /// Sets the value of [operation][crate::model::CheckRequest::operation].
2252 pub fn set_operation<T: std::convert::Into<std::option::Option<crate::model::Operation>>>(
2253 mut self,
2254 v: T,
2255 ) -> Self {
2256 self.operation = v.into();
2257 self
2258 }
2259
2260 /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
2261 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2262 mut self,
2263 v: T,
2264 ) -> Self {
2265 self.service_config_id = v.into();
2266 self
2267 }
2268}
2269
2270impl wkt::message::Message for CheckRequest {
2271 fn typename() -> &'static str {
2272 "type.googleapis.com/google.api.servicecontrol.v1.CheckRequest"
2273 }
2274}
2275
2276/// Response message for the Check method.
2277#[serde_with::serde_as]
2278#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2279#[serde(default, rename_all = "camelCase")]
2280#[non_exhaustive]
2281pub struct CheckResponse {
2282 /// The same operation_id value used in the
2283 /// [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging
2284 /// and diagnostics purposes.
2285 ///
2286 /// [google.api.servicecontrol.v1.CheckRequest]: crate::model::CheckRequest
2287 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2288 pub operation_id: std::string::String,
2289
2290 /// Indicate the decision of the check.
2291 ///
2292 /// If no check errors are present, the service should process the operation.
2293 /// Otherwise the service should use the list of errors to determine the
2294 /// appropriate action.
2295 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2296 pub check_errors: std::vec::Vec<crate::model::CheckError>,
2297
2298 /// The actual config id used to process the request.
2299 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2300 pub service_config_id: std::string::String,
2301
2302 /// The current service rollout id used to process the request.
2303 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2304 pub service_rollout_id: std::string::String,
2305
2306 /// Feedback data returned from the server during processing a Check request.
2307 #[serde(skip_serializing_if = "std::option::Option::is_none")]
2308 pub check_info: std::option::Option<crate::model::check_response::CheckInfo>,
2309}
2310
2311impl CheckResponse {
2312 pub fn new() -> Self {
2313 std::default::Default::default()
2314 }
2315
2316 /// Sets the value of [operation_id][crate::model::CheckResponse::operation_id].
2317 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2318 self.operation_id = v.into();
2319 self
2320 }
2321
2322 /// Sets the value of [service_config_id][crate::model::CheckResponse::service_config_id].
2323 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2324 mut self,
2325 v: T,
2326 ) -> Self {
2327 self.service_config_id = v.into();
2328 self
2329 }
2330
2331 /// Sets the value of [service_rollout_id][crate::model::CheckResponse::service_rollout_id].
2332 pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
2333 mut self,
2334 v: T,
2335 ) -> Self {
2336 self.service_rollout_id = v.into();
2337 self
2338 }
2339
2340 /// Sets the value of [check_info][crate::model::CheckResponse::check_info].
2341 pub fn set_check_info<
2342 T: std::convert::Into<std::option::Option<crate::model::check_response::CheckInfo>>,
2343 >(
2344 mut self,
2345 v: T,
2346 ) -> Self {
2347 self.check_info = v.into();
2348 self
2349 }
2350
2351 /// Sets the value of [check_errors][crate::model::CheckResponse::check_errors].
2352 pub fn set_check_errors<T, V>(mut self, v: T) -> Self
2353 where
2354 T: std::iter::IntoIterator<Item = V>,
2355 V: std::convert::Into<crate::model::CheckError>,
2356 {
2357 use std::iter::Iterator;
2358 self.check_errors = v.into_iter().map(|i| i.into()).collect();
2359 self
2360 }
2361}
2362
2363impl wkt::message::Message for CheckResponse {
2364 fn typename() -> &'static str {
2365 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse"
2366 }
2367}
2368
2369/// Defines additional types related to CheckResponse
2370pub mod check_response {
2371 #[allow(unused_imports)]
2372 use super::*;
2373
2374 /// Contains additional information about the check operation.
2375 #[serde_with::serde_as]
2376 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2377 #[serde(default, rename_all = "camelCase")]
2378 #[non_exhaustive]
2379 pub struct CheckInfo {
2380 /// A list of fields and label keys that are ignored by the server.
2381 /// The client doesn't need to send them for following requests to improve
2382 /// performance and allow better aggregation.
2383 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2384 pub unused_arguments: std::vec::Vec<std::string::String>,
2385
2386 /// Consumer info of this check.
2387 #[serde(skip_serializing_if = "std::option::Option::is_none")]
2388 pub consumer_info: std::option::Option<crate::model::check_response::ConsumerInfo>,
2389
2390 /// The unique id of the api key in the format of "apikey:\<UID\>".
2391 /// This field will be populated when the consumer passed to Service Control
2392 /// is an API key and all the API key related validations are successful.
2393 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2394 pub api_key_uid: std::string::String,
2395 }
2396
2397 impl CheckInfo {
2398 pub fn new() -> Self {
2399 std::default::Default::default()
2400 }
2401
2402 /// Sets the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
2403 pub fn set_consumer_info<
2404 T: std::convert::Into<std::option::Option<crate::model::check_response::ConsumerInfo>>,
2405 >(
2406 mut self,
2407 v: T,
2408 ) -> Self {
2409 self.consumer_info = v.into();
2410 self
2411 }
2412
2413 /// Sets the value of [api_key_uid][crate::model::check_response::CheckInfo::api_key_uid].
2414 pub fn set_api_key_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2415 self.api_key_uid = v.into();
2416 self
2417 }
2418
2419 /// Sets the value of [unused_arguments][crate::model::check_response::CheckInfo::unused_arguments].
2420 pub fn set_unused_arguments<T, V>(mut self, v: T) -> Self
2421 where
2422 T: std::iter::IntoIterator<Item = V>,
2423 V: std::convert::Into<std::string::String>,
2424 {
2425 use std::iter::Iterator;
2426 self.unused_arguments = v.into_iter().map(|i| i.into()).collect();
2427 self
2428 }
2429 }
2430
2431 impl wkt::message::Message for CheckInfo {
2432 fn typename() -> &'static str {
2433 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.CheckInfo"
2434 }
2435 }
2436
2437 /// `ConsumerInfo` provides information about the consumer.
2438 #[serde_with::serde_as]
2439 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2440 #[serde(default, rename_all = "camelCase")]
2441 #[non_exhaustive]
2442 pub struct ConsumerInfo {
2443 /// The Google cloud project number, e.g. 1234567890. A value of 0 indicates
2444 /// no project number is found.
2445 ///
2446 /// NOTE: This field is deprecated after we support flexible consumer
2447 /// id. New code should not depend on this field anymore.
2448 #[serde_as(as = "serde_with::DisplayFromStr")]
2449 pub project_number: i64,
2450
2451 /// The type of the consumer which should have been defined in
2452 /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
2453 #[serde(rename = "type")]
2454 pub r#type: crate::model::check_response::consumer_info::ConsumerType,
2455
2456 /// The consumer identity number, can be Google cloud project number, folder
2457 /// number or organization number e.g. 1234567890. A value of 0 indicates no
2458 /// consumer number is found.
2459 #[serde_as(as = "serde_with::DisplayFromStr")]
2460 pub consumer_number: i64,
2461 }
2462
2463 impl ConsumerInfo {
2464 pub fn new() -> Self {
2465 std::default::Default::default()
2466 }
2467
2468 /// Sets the value of [project_number][crate::model::check_response::ConsumerInfo::project_number].
2469 pub fn set_project_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2470 self.project_number = v.into();
2471 self
2472 }
2473
2474 /// Sets the value of [r#type][crate::model::check_response::ConsumerInfo::type].
2475 pub fn set_type<
2476 T: std::convert::Into<crate::model::check_response::consumer_info::ConsumerType>,
2477 >(
2478 mut self,
2479 v: T,
2480 ) -> Self {
2481 self.r#type = v.into();
2482 self
2483 }
2484
2485 /// Sets the value of [consumer_number][crate::model::check_response::ConsumerInfo::consumer_number].
2486 pub fn set_consumer_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2487 self.consumer_number = v.into();
2488 self
2489 }
2490 }
2491
2492 impl wkt::message::Message for ConsumerInfo {
2493 fn typename() -> &'static str {
2494 "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.ConsumerInfo"
2495 }
2496 }
2497
2498 /// Defines additional types related to ConsumerInfo
2499 pub mod consumer_info {
2500 #[allow(unused_imports)]
2501 use super::*;
2502
2503 /// The type of the consumer as defined in
2504 /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
2505 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2506 pub struct ConsumerType(std::borrow::Cow<'static, str>);
2507
2508 impl ConsumerType {
2509 /// Creates a new ConsumerType instance.
2510 pub const fn new(v: &'static str) -> Self {
2511 Self(std::borrow::Cow::Borrowed(v))
2512 }
2513
2514 /// Gets the enum value.
2515 pub fn value(&self) -> &str {
2516 &self.0
2517 }
2518 }
2519
2520 /// Useful constants to work with [ConsumerType](ConsumerType)
2521 pub mod consumer_type {
2522 use super::ConsumerType;
2523
2524 /// This is never used.
2525 pub const CONSUMER_TYPE_UNSPECIFIED: ConsumerType =
2526 ConsumerType::new("CONSUMER_TYPE_UNSPECIFIED");
2527
2528 /// The consumer is a Google Cloud Project.
2529 pub const PROJECT: ConsumerType = ConsumerType::new("PROJECT");
2530
2531 /// The consumer is a Google Cloud Folder.
2532 pub const FOLDER: ConsumerType = ConsumerType::new("FOLDER");
2533
2534 /// The consumer is a Google Cloud Organization.
2535 pub const ORGANIZATION: ConsumerType = ConsumerType::new("ORGANIZATION");
2536
2537 /// Service-specific resource container which is defined by the service
2538 /// producer to offer their users the ability to manage service control
2539 /// functionalities at a finer level of granularity than the PROJECT.
2540 pub const SERVICE_SPECIFIC: ConsumerType = ConsumerType::new("SERVICE_SPECIFIC");
2541 }
2542
2543 impl std::convert::From<std::string::String> for ConsumerType {
2544 fn from(value: std::string::String) -> Self {
2545 Self(std::borrow::Cow::Owned(value))
2546 }
2547 }
2548 }
2549}
2550
2551/// Request message for the Report method.
2552#[serde_with::serde_as]
2553#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2554#[serde(default, rename_all = "camelCase")]
2555#[non_exhaustive]
2556pub struct ReportRequest {
2557 /// The service name as specified in its service configuration. For example,
2558 /// `"pubsub.googleapis.com"`.
2559 ///
2560 /// See
2561 /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
2562 /// for the definition of a service name.
2563 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2564 pub service_name: std::string::String,
2565
2566 /// Operations to be reported.
2567 ///
2568 /// Typically the service should report one operation per request.
2569 /// Putting multiple operations into a single request is allowed, but should
2570 /// be used only when multiple operations are natually available at the time
2571 /// of the report.
2572 ///
2573 /// There is no limit on the number of operations in the same ReportRequest,
2574 /// however the ReportRequest size should be no larger than 1MB. See
2575 /// [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors]
2576 /// for partial failure behavior.
2577 ///
2578 /// [google.api.servicecontrol.v1.ReportResponse.report_errors]: crate::model::ReportResponse::report_errors
2579 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2580 pub operations: std::vec::Vec<crate::model::Operation>,
2581
2582 /// Specifies which version of service config should be used to process the
2583 /// request.
2584 ///
2585 /// If unspecified or no matching version can be found, the
2586 /// latest one will be used.
2587 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2588 pub service_config_id: std::string::String,
2589}
2590
2591impl ReportRequest {
2592 pub fn new() -> Self {
2593 std::default::Default::default()
2594 }
2595
2596 /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
2597 pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2598 self.service_name = v.into();
2599 self
2600 }
2601
2602 /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
2603 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2604 mut self,
2605 v: T,
2606 ) -> Self {
2607 self.service_config_id = v.into();
2608 self
2609 }
2610
2611 /// Sets the value of [operations][crate::model::ReportRequest::operations].
2612 pub fn set_operations<T, V>(mut self, v: T) -> Self
2613 where
2614 T: std::iter::IntoIterator<Item = V>,
2615 V: std::convert::Into<crate::model::Operation>,
2616 {
2617 use std::iter::Iterator;
2618 self.operations = v.into_iter().map(|i| i.into()).collect();
2619 self
2620 }
2621}
2622
2623impl wkt::message::Message for ReportRequest {
2624 fn typename() -> &'static str {
2625 "type.googleapis.com/google.api.servicecontrol.v1.ReportRequest"
2626 }
2627}
2628
2629/// Response message for the Report method.
2630#[serde_with::serde_as]
2631#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2632#[serde(default, rename_all = "camelCase")]
2633#[non_exhaustive]
2634pub struct ReportResponse {
2635 /// Partial failures, one for each `Operation` in the request that failed
2636 /// processing. There are three possible combinations of the RPC status:
2637 ///
2638 /// . The combination of a successful RPC status and an empty `report_errors`
2639 /// list indicates a complete success where all `Operations` in the
2640 /// request are processed successfully.
2641 /// . The combination of a successful RPC status and a non-empty
2642 /// `report_errors` list indicates a partial success where some
2643 /// `Operations` in the request succeeded. Each
2644 /// `Operation` that failed processing has a corresponding item
2645 /// in this list.
2646 /// . A failed RPC status indicates a general non-deterministic failure.
2647 /// When this happens, it's impossible to know which of the
2648 /// 'Operations' in the request succeeded or failed.
2649 #[serde(skip_serializing_if = "std::vec::Vec::is_empty")]
2650 pub report_errors: std::vec::Vec<crate::model::report_response::ReportError>,
2651
2652 /// The actual config id used to process the request.
2653 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2654 pub service_config_id: std::string::String,
2655
2656 /// The current service rollout id used to process the request.
2657 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2658 pub service_rollout_id: std::string::String,
2659}
2660
2661impl ReportResponse {
2662 pub fn new() -> Self {
2663 std::default::Default::default()
2664 }
2665
2666 /// Sets the value of [service_config_id][crate::model::ReportResponse::service_config_id].
2667 pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
2668 mut self,
2669 v: T,
2670 ) -> Self {
2671 self.service_config_id = v.into();
2672 self
2673 }
2674
2675 /// Sets the value of [service_rollout_id][crate::model::ReportResponse::service_rollout_id].
2676 pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
2677 mut self,
2678 v: T,
2679 ) -> Self {
2680 self.service_rollout_id = v.into();
2681 self
2682 }
2683
2684 /// Sets the value of [report_errors][crate::model::ReportResponse::report_errors].
2685 pub fn set_report_errors<T, V>(mut self, v: T) -> Self
2686 where
2687 T: std::iter::IntoIterator<Item = V>,
2688 V: std::convert::Into<crate::model::report_response::ReportError>,
2689 {
2690 use std::iter::Iterator;
2691 self.report_errors = v.into_iter().map(|i| i.into()).collect();
2692 self
2693 }
2694}
2695
2696impl wkt::message::Message for ReportResponse {
2697 fn typename() -> &'static str {
2698 "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse"
2699 }
2700}
2701
2702/// Defines additional types related to ReportResponse
2703pub mod report_response {
2704 #[allow(unused_imports)]
2705 use super::*;
2706
2707 /// Represents the processing error of one
2708 /// [Operation][google.api.servicecontrol.v1.Operation] in the request.
2709 ///
2710 /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
2711 #[serde_with::serde_as]
2712 #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2713 #[serde(default, rename_all = "camelCase")]
2714 #[non_exhaustive]
2715 pub struct ReportError {
2716 /// The
2717 /// [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id]
2718 /// value from the request.
2719 ///
2720 /// [google.api.servicecontrol.v1.Operation.operation_id]: crate::model::Operation::operation_id
2721 #[serde(skip_serializing_if = "std::string::String::is_empty")]
2722 pub operation_id: std::string::String,
2723
2724 /// Details of the error when processing the
2725 /// [Operation][google.api.servicecontrol.v1.Operation].
2726 ///
2727 /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
2728 #[serde(skip_serializing_if = "std::option::Option::is_none")]
2729 pub status: std::option::Option<rpc::model::Status>,
2730 }
2731
2732 impl ReportError {
2733 pub fn new() -> Self {
2734 std::default::Default::default()
2735 }
2736
2737 /// Sets the value of [operation_id][crate::model::report_response::ReportError::operation_id].
2738 pub fn set_operation_id<T: std::convert::Into<std::string::String>>(
2739 mut self,
2740 v: T,
2741 ) -> Self {
2742 self.operation_id = v.into();
2743 self
2744 }
2745
2746 /// Sets the value of [status][crate::model::report_response::ReportError::status].
2747 pub fn set_status<T: std::convert::Into<std::option::Option<rpc::model::Status>>>(
2748 mut self,
2749 v: T,
2750 ) -> Self {
2751 self.status = v.into();
2752 self
2753 }
2754 }
2755
2756 impl wkt::message::Message for ReportError {
2757 fn typename() -> &'static str {
2758 "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse.ReportError"
2759 }
2760 }
2761}