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