Skip to main content

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