google_cloud_api_servicecontrol_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate api;
21extern crate async_trait;
22extern crate bytes;
23extern crate gax;
24extern crate gaxi;
25extern crate lazy_static;
26extern crate logging_type;
27extern crate reqwest;
28extern crate rpc;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36/// Defines the errors to be returned in
37/// [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors].
38///
39/// [google.api.servicecontrol.v1.CheckResponse.check_errors]: crate::model::CheckResponse::check_errors
40#[derive(Clone, Debug, Default, PartialEq)]
41#[non_exhaustive]
42pub struct CheckError {
43    /// The error code.
44    pub code: crate::model::check_error::Code,
45
46    /// Subject to whom this error applies. See the specific code enum for more
47    /// details on this field. For example:
48    ///
49    /// - "project:\<project-id or project-number\>"
50    /// - "folder:\<folder-id\>"
51    /// - "organization:\<organization-id\>"
52    pub subject: std::string::String,
53
54    /// Free-form text providing details on the error cause of the error.
55    pub detail: std::string::String,
56
57    /// Contains public information about the check error. If available,
58    /// `status.code` will be non zero and client can propagate it out as public
59    /// error.
60    pub status: std::option::Option<rpc::model::Status>,
61
62    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
63}
64
65impl CheckError {
66    pub fn new() -> Self {
67        std::default::Default::default()
68    }
69
70    /// Sets the value of [code][crate::model::CheckError::code].
71    pub fn set_code<T: std::convert::Into<crate::model::check_error::Code>>(
72        mut self,
73        v: T,
74    ) -> Self {
75        self.code = v.into();
76        self
77    }
78
79    /// Sets the value of [subject][crate::model::CheckError::subject].
80    pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
81        self.subject = v.into();
82        self
83    }
84
85    /// Sets the value of [detail][crate::model::CheckError::detail].
86    pub fn set_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
87        self.detail = v.into();
88        self
89    }
90
91    /// Sets the value of [status][crate::model::CheckError::status].
92    pub fn set_status<T>(mut self, v: T) -> Self
93    where
94        T: std::convert::Into<rpc::model::Status>,
95    {
96        self.status = std::option::Option::Some(v.into());
97        self
98    }
99
100    /// Sets or clears the value of [status][crate::model::CheckError::status].
101    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
102    where
103        T: std::convert::Into<rpc::model::Status>,
104    {
105        self.status = v.map(|x| x.into());
106        self
107    }
108}
109
110impl wkt::message::Message for CheckError {
111    fn typename() -> &'static str {
112        "type.googleapis.com/google.api.servicecontrol.v1.CheckError"
113    }
114}
115
116#[doc(hidden)]
117impl<'de> serde::de::Deserialize<'de> for CheckError {
118    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
119    where
120        D: serde::Deserializer<'de>,
121    {
122        #[allow(non_camel_case_types)]
123        #[doc(hidden)]
124        #[derive(PartialEq, Eq, Hash)]
125        enum __FieldTag {
126            __code,
127            __subject,
128            __detail,
129            __status,
130            Unknown(std::string::String),
131        }
132        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
133            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
134            where
135                D: serde::Deserializer<'de>,
136            {
137                struct Visitor;
138                impl<'de> serde::de::Visitor<'de> for Visitor {
139                    type Value = __FieldTag;
140                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
141                        formatter.write_str("a field name for CheckError")
142                    }
143                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
144                    where
145                        E: serde::de::Error,
146                    {
147                        use std::result::Result::Ok;
148                        use std::string::ToString;
149                        match value {
150                            "code" => Ok(__FieldTag::__code),
151                            "subject" => Ok(__FieldTag::__subject),
152                            "detail" => Ok(__FieldTag::__detail),
153                            "status" => Ok(__FieldTag::__status),
154                            _ => Ok(__FieldTag::Unknown(value.to_string())),
155                        }
156                    }
157                }
158                deserializer.deserialize_identifier(Visitor)
159            }
160        }
161        struct Visitor;
162        impl<'de> serde::de::Visitor<'de> for Visitor {
163            type Value = CheckError;
164            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
165                formatter.write_str("struct CheckError")
166            }
167            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
168            where
169                A: serde::de::MapAccess<'de>,
170            {
171                #[allow(unused_imports)]
172                use serde::de::Error;
173                use std::option::Option::Some;
174                let mut fields = std::collections::HashSet::new();
175                let mut result = Self::Value::new();
176                while let Some(tag) = map.next_key::<__FieldTag>()? {
177                    #[allow(clippy::match_single_binding)]
178                    match tag {
179                        __FieldTag::__code => {
180                            if !fields.insert(__FieldTag::__code) {
181                                return std::result::Result::Err(A::Error::duplicate_field(
182                                    "multiple values for code",
183                                ));
184                            }
185                            result.code = map
186                                .next_value::<std::option::Option<crate::model::check_error::Code>>(
187                                )?
188                                .unwrap_or_default();
189                        }
190                        __FieldTag::__subject => {
191                            if !fields.insert(__FieldTag::__subject) {
192                                return std::result::Result::Err(A::Error::duplicate_field(
193                                    "multiple values for subject",
194                                ));
195                            }
196                            result.subject = map
197                                .next_value::<std::option::Option<std::string::String>>()?
198                                .unwrap_or_default();
199                        }
200                        __FieldTag::__detail => {
201                            if !fields.insert(__FieldTag::__detail) {
202                                return std::result::Result::Err(A::Error::duplicate_field(
203                                    "multiple values for detail",
204                                ));
205                            }
206                            result.detail = map
207                                .next_value::<std::option::Option<std::string::String>>()?
208                                .unwrap_or_default();
209                        }
210                        __FieldTag::__status => {
211                            if !fields.insert(__FieldTag::__status) {
212                                return std::result::Result::Err(A::Error::duplicate_field(
213                                    "multiple values for status",
214                                ));
215                            }
216                            result.status =
217                                map.next_value::<std::option::Option<rpc::model::Status>>()?;
218                        }
219                        __FieldTag::Unknown(key) => {
220                            let value = map.next_value::<serde_json::Value>()?;
221                            result._unknown_fields.insert(key, value);
222                        }
223                    }
224                }
225                std::result::Result::Ok(result)
226            }
227        }
228        deserializer.deserialize_any(Visitor)
229    }
230}
231
232#[doc(hidden)]
233impl serde::ser::Serialize for CheckError {
234    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
235    where
236        S: serde::ser::Serializer,
237    {
238        use serde::ser::SerializeMap;
239        #[allow(unused_imports)]
240        use std::option::Option::Some;
241        let mut state = serializer.serialize_map(std::option::Option::None)?;
242        if !wkt::internal::is_default(&self.code) {
243            state.serialize_entry("code", &self.code)?;
244        }
245        if !self.subject.is_empty() {
246            state.serialize_entry("subject", &self.subject)?;
247        }
248        if !self.detail.is_empty() {
249            state.serialize_entry("detail", &self.detail)?;
250        }
251        if self.status.is_some() {
252            state.serialize_entry("status", &self.status)?;
253        }
254        if !self._unknown_fields.is_empty() {
255            for (key, value) in self._unknown_fields.iter() {
256                state.serialize_entry(key, &value)?;
257            }
258        }
259        state.end()
260    }
261}
262
263/// Defines additional types related to [CheckError].
264pub mod check_error {
265    #[allow(unused_imports)]
266    use super::*;
267
268    /// Error codes for Check responses.
269    ///
270    /// # Working with unknown values
271    ///
272    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
273    /// additional enum variants at any time. Adding new variants is not considered
274    /// a breaking change. Applications should write their code in anticipation of:
275    ///
276    /// - New values appearing in future releases of the client library, **and**
277    /// - New values received dynamically, without application changes.
278    ///
279    /// Please consult the [Working with enums] section in the user guide for some
280    /// guidelines.
281    ///
282    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
283    #[derive(Clone, Debug, PartialEq)]
284    #[non_exhaustive]
285    pub enum Code {
286        /// This is never used in `CheckResponse`.
287        ErrorCodeUnspecified,
288        /// The consumer's project id, network container, or resource container was
289        /// not found. Same as [google.rpc.Code.NOT_FOUND][google.rpc.Code.NOT_FOUND].
290        NotFound,
291        /// The consumer doesn't have access to the specified resource.
292        /// Same as [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
293        PermissionDenied,
294        /// Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
295        ResourceExhausted,
296        /// The consumer hasn't activated the service.
297        ServiceNotActivated,
298        /// The consumer cannot access the service because billing is disabled.
299        BillingDisabled,
300        /// The consumer's project has been marked as deleted (soft deletion).
301        ProjectDeleted,
302        /// The consumer's project number or id does not represent a valid project.
303        ProjectInvalid,
304        /// The input consumer info does not represent a valid consumer folder or
305        /// organization.
306        ConsumerInvalid,
307        /// The IP address of the consumer is invalid for the specific consumer
308        /// project.
309        IpAddressBlocked,
310        /// The referer address of the consumer request is invalid for the specific
311        /// consumer project.
312        RefererBlocked,
313        /// The client application of the consumer request is invalid for the
314        /// specific consumer project.
315        ClientAppBlocked,
316        /// The API targeted by this request is invalid for the specified consumer
317        /// project.
318        ApiTargetBlocked,
319        /// The consumer's API key is invalid.
320        ApiKeyInvalid,
321        /// The consumer's API Key has expired.
322        ApiKeyExpired,
323        /// The consumer's API Key was not found in config record.
324        ApiKeyNotFound,
325        /// The credential in the request can not be verified.
326        InvalidCredential,
327        /// The backend server for looking up project id/number is unavailable.
328        NamespaceLookupUnavailable,
329        /// The backend server for checking service status is unavailable.
330        ServiceStatusUnavailable,
331        /// The backend server for checking billing status is unavailable.
332        BillingStatusUnavailable,
333        /// Cloud Resource Manager backend server is unavailable.
334        CloudResourceManagerBackendUnavailable,
335        /// If set, the enum was initialized with an unknown value.
336        ///
337        /// Applications can examine the value using [Code::value] or
338        /// [Code::name].
339        UnknownValue(code::UnknownValue),
340    }
341
342    #[doc(hidden)]
343    pub mod code {
344        #[allow(unused_imports)]
345        use super::*;
346        #[derive(Clone, Debug, PartialEq)]
347        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
348    }
349
350    impl Code {
351        /// Gets the enum value.
352        ///
353        /// Returns `None` if the enum contains an unknown value deserialized from
354        /// the string representation of enums.
355        pub fn value(&self) -> std::option::Option<i32> {
356            match self {
357                Self::ErrorCodeUnspecified => std::option::Option::Some(0),
358                Self::NotFound => std::option::Option::Some(5),
359                Self::PermissionDenied => std::option::Option::Some(7),
360                Self::ResourceExhausted => std::option::Option::Some(8),
361                Self::ServiceNotActivated => std::option::Option::Some(104),
362                Self::BillingDisabled => std::option::Option::Some(107),
363                Self::ProjectDeleted => std::option::Option::Some(108),
364                Self::ProjectInvalid => std::option::Option::Some(114),
365                Self::ConsumerInvalid => std::option::Option::Some(125),
366                Self::IpAddressBlocked => std::option::Option::Some(109),
367                Self::RefererBlocked => std::option::Option::Some(110),
368                Self::ClientAppBlocked => std::option::Option::Some(111),
369                Self::ApiTargetBlocked => std::option::Option::Some(122),
370                Self::ApiKeyInvalid => std::option::Option::Some(105),
371                Self::ApiKeyExpired => std::option::Option::Some(112),
372                Self::ApiKeyNotFound => std::option::Option::Some(113),
373                Self::InvalidCredential => std::option::Option::Some(123),
374                Self::NamespaceLookupUnavailable => std::option::Option::Some(300),
375                Self::ServiceStatusUnavailable => std::option::Option::Some(301),
376                Self::BillingStatusUnavailable => std::option::Option::Some(302),
377                Self::CloudResourceManagerBackendUnavailable => std::option::Option::Some(305),
378                Self::UnknownValue(u) => u.0.value(),
379            }
380        }
381
382        /// Gets the enum value as a string.
383        ///
384        /// Returns `None` if the enum contains an unknown value deserialized from
385        /// the integer representation of enums.
386        pub fn name(&self) -> std::option::Option<&str> {
387            match self {
388                Self::ErrorCodeUnspecified => std::option::Option::Some("ERROR_CODE_UNSPECIFIED"),
389                Self::NotFound => std::option::Option::Some("NOT_FOUND"),
390                Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
391                Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
392                Self::ServiceNotActivated => std::option::Option::Some("SERVICE_NOT_ACTIVATED"),
393                Self::BillingDisabled => std::option::Option::Some("BILLING_DISABLED"),
394                Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
395                Self::ProjectInvalid => std::option::Option::Some("PROJECT_INVALID"),
396                Self::ConsumerInvalid => std::option::Option::Some("CONSUMER_INVALID"),
397                Self::IpAddressBlocked => std::option::Option::Some("IP_ADDRESS_BLOCKED"),
398                Self::RefererBlocked => std::option::Option::Some("REFERER_BLOCKED"),
399                Self::ClientAppBlocked => std::option::Option::Some("CLIENT_APP_BLOCKED"),
400                Self::ApiTargetBlocked => std::option::Option::Some("API_TARGET_BLOCKED"),
401                Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
402                Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
403                Self::ApiKeyNotFound => std::option::Option::Some("API_KEY_NOT_FOUND"),
404                Self::InvalidCredential => std::option::Option::Some("INVALID_CREDENTIAL"),
405                Self::NamespaceLookupUnavailable => {
406                    std::option::Option::Some("NAMESPACE_LOOKUP_UNAVAILABLE")
407                }
408                Self::ServiceStatusUnavailable => {
409                    std::option::Option::Some("SERVICE_STATUS_UNAVAILABLE")
410                }
411                Self::BillingStatusUnavailable => {
412                    std::option::Option::Some("BILLING_STATUS_UNAVAILABLE")
413                }
414                Self::CloudResourceManagerBackendUnavailable => {
415                    std::option::Option::Some("CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE")
416                }
417                Self::UnknownValue(u) => u.0.name(),
418            }
419        }
420    }
421
422    impl std::default::Default for Code {
423        fn default() -> Self {
424            use std::convert::From;
425            Self::from(0)
426        }
427    }
428
429    impl std::fmt::Display for Code {
430        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
431            wkt::internal::display_enum(f, self.name(), self.value())
432        }
433    }
434
435    impl std::convert::From<i32> for Code {
436        fn from(value: i32) -> Self {
437            match value {
438                0 => Self::ErrorCodeUnspecified,
439                5 => Self::NotFound,
440                7 => Self::PermissionDenied,
441                8 => Self::ResourceExhausted,
442                104 => Self::ServiceNotActivated,
443                105 => Self::ApiKeyInvalid,
444                107 => Self::BillingDisabled,
445                108 => Self::ProjectDeleted,
446                109 => Self::IpAddressBlocked,
447                110 => Self::RefererBlocked,
448                111 => Self::ClientAppBlocked,
449                112 => Self::ApiKeyExpired,
450                113 => Self::ApiKeyNotFound,
451                114 => Self::ProjectInvalid,
452                122 => Self::ApiTargetBlocked,
453                123 => Self::InvalidCredential,
454                125 => Self::ConsumerInvalid,
455                300 => Self::NamespaceLookupUnavailable,
456                301 => Self::ServiceStatusUnavailable,
457                302 => Self::BillingStatusUnavailable,
458                305 => Self::CloudResourceManagerBackendUnavailable,
459                _ => Self::UnknownValue(code::UnknownValue(
460                    wkt::internal::UnknownEnumValue::Integer(value),
461                )),
462            }
463        }
464    }
465
466    impl std::convert::From<&str> for Code {
467        fn from(value: &str) -> Self {
468            use std::string::ToString;
469            match value {
470                "ERROR_CODE_UNSPECIFIED" => Self::ErrorCodeUnspecified,
471                "NOT_FOUND" => Self::NotFound,
472                "PERMISSION_DENIED" => Self::PermissionDenied,
473                "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
474                "SERVICE_NOT_ACTIVATED" => Self::ServiceNotActivated,
475                "BILLING_DISABLED" => Self::BillingDisabled,
476                "PROJECT_DELETED" => Self::ProjectDeleted,
477                "PROJECT_INVALID" => Self::ProjectInvalid,
478                "CONSUMER_INVALID" => Self::ConsumerInvalid,
479                "IP_ADDRESS_BLOCKED" => Self::IpAddressBlocked,
480                "REFERER_BLOCKED" => Self::RefererBlocked,
481                "CLIENT_APP_BLOCKED" => Self::ClientAppBlocked,
482                "API_TARGET_BLOCKED" => Self::ApiTargetBlocked,
483                "API_KEY_INVALID" => Self::ApiKeyInvalid,
484                "API_KEY_EXPIRED" => Self::ApiKeyExpired,
485                "API_KEY_NOT_FOUND" => Self::ApiKeyNotFound,
486                "INVALID_CREDENTIAL" => Self::InvalidCredential,
487                "NAMESPACE_LOOKUP_UNAVAILABLE" => Self::NamespaceLookupUnavailable,
488                "SERVICE_STATUS_UNAVAILABLE" => Self::ServiceStatusUnavailable,
489                "BILLING_STATUS_UNAVAILABLE" => Self::BillingStatusUnavailable,
490                "CLOUD_RESOURCE_MANAGER_BACKEND_UNAVAILABLE" => {
491                    Self::CloudResourceManagerBackendUnavailable
492                }
493                _ => Self::UnknownValue(code::UnknownValue(
494                    wkt::internal::UnknownEnumValue::String(value.to_string()),
495                )),
496            }
497        }
498    }
499
500    impl serde::ser::Serialize for Code {
501        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
502        where
503            S: serde::Serializer,
504        {
505            match self {
506                Self::ErrorCodeUnspecified => serializer.serialize_i32(0),
507                Self::NotFound => serializer.serialize_i32(5),
508                Self::PermissionDenied => serializer.serialize_i32(7),
509                Self::ResourceExhausted => serializer.serialize_i32(8),
510                Self::ServiceNotActivated => serializer.serialize_i32(104),
511                Self::BillingDisabled => serializer.serialize_i32(107),
512                Self::ProjectDeleted => serializer.serialize_i32(108),
513                Self::ProjectInvalid => serializer.serialize_i32(114),
514                Self::ConsumerInvalid => serializer.serialize_i32(125),
515                Self::IpAddressBlocked => serializer.serialize_i32(109),
516                Self::RefererBlocked => serializer.serialize_i32(110),
517                Self::ClientAppBlocked => serializer.serialize_i32(111),
518                Self::ApiTargetBlocked => serializer.serialize_i32(122),
519                Self::ApiKeyInvalid => serializer.serialize_i32(105),
520                Self::ApiKeyExpired => serializer.serialize_i32(112),
521                Self::ApiKeyNotFound => serializer.serialize_i32(113),
522                Self::InvalidCredential => serializer.serialize_i32(123),
523                Self::NamespaceLookupUnavailable => serializer.serialize_i32(300),
524                Self::ServiceStatusUnavailable => serializer.serialize_i32(301),
525                Self::BillingStatusUnavailable => serializer.serialize_i32(302),
526                Self::CloudResourceManagerBackendUnavailable => serializer.serialize_i32(305),
527                Self::UnknownValue(u) => u.0.serialize(serializer),
528            }
529        }
530    }
531
532    impl<'de> serde::de::Deserialize<'de> for Code {
533        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
534        where
535            D: serde::Deserializer<'de>,
536        {
537            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
538                ".google.api.servicecontrol.v1.CheckError.Code",
539            ))
540        }
541    }
542}
543
544/// Distribution represents a frequency distribution of double-valued sample
545/// points. It contains the size of the population of sample points plus
546/// additional optional information:
547///
548/// * the arithmetic mean of the samples
549/// * the minimum and maximum of the samples
550/// * the sum-squared-deviation of the samples, used to compute variance
551/// * a histogram of the values of the sample points
552#[derive(Clone, Debug, Default, PartialEq)]
553#[non_exhaustive]
554pub struct Distribution {
555    /// The total number of samples in the distribution. Must be >= 0.
556    pub count: i64,
557
558    /// The arithmetic mean of the samples in the distribution. If `count` is
559    /// zero then this field must be zero.
560    pub mean: f64,
561
562    /// The minimum of the population of values. Ignored if `count` is zero.
563    pub minimum: f64,
564
565    /// The maximum of the population of values. Ignored if `count` is zero.
566    pub maximum: f64,
567
568    /// The sum of squared deviations from the mean:
569    /// Sum[i=1..count]((x_i - mean)^2)
570    /// where each x_i is a sample values. If `count` is zero then this field
571    /// must be zero, otherwise validation of the request fails.
572    pub sum_of_squared_deviation: f64,
573
574    /// The number of samples in each histogram bucket. `bucket_counts` are
575    /// optional. If present, they must sum to the `count` value.
576    ///
577    /// The buckets are defined below in `bucket_option`. There are N buckets.
578    /// `bucket_counts[0]` is the number of samples in the underflow bucket.
579    /// `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples
580    /// in each of the finite buckets. And `bucket_counts[N] is the number
581    /// of samples in the overflow bucket. See the comments of `bucket_option`
582    /// below for more details.
583    ///
584    /// Any suffix of trailing zeros may be omitted.
585    pub bucket_counts: std::vec::Vec<i64>,
586
587    /// Example points. Must be in increasing order of `value` field.
588    pub exemplars: std::vec::Vec<api::model::distribution::Exemplar>,
589
590    /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
591    /// must be both set, or both unset.
592    ///
593    /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
594    /// There must be at least two buckets (a single-bucket histogram gives
595    /// no information that isn't already provided by `count`).
596    ///
597    /// The first bucket is the underflow bucket which has a lower bound
598    /// of -inf. The last bucket is the overflow bucket which has an
599    /// upper bound of +inf. All other buckets (if any) are called "finite"
600    /// buckets because they have finite lower and upper bounds. As described
601    /// below, there are three ways to define the finite buckets.
602    ///
603    /// (1) Buckets with constant width.
604    /// (2) Buckets with exponentially growing widths.
605    /// (3) Buckets with arbitrary user-provided widths.
606    ///
607    /// In all cases, the buckets cover the entire real number line (-inf,
608    /// +inf). Bucket upper bounds are exclusive and lower bounds are
609    /// inclusive. The upper bound of the underflow bucket is equal to the
610    /// lower bound of the smallest finite bucket; the lower bound of the
611    /// overflow bucket is equal to the upper bound of the largest finite
612    /// bucket.
613    pub bucket_option: std::option::Option<crate::model::distribution::BucketOption>,
614
615    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
616}
617
618impl Distribution {
619    pub fn new() -> Self {
620        std::default::Default::default()
621    }
622
623    /// Sets the value of [count][crate::model::Distribution::count].
624    pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
625        self.count = v.into();
626        self
627    }
628
629    /// Sets the value of [mean][crate::model::Distribution::mean].
630    pub fn set_mean<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
631        self.mean = v.into();
632        self
633    }
634
635    /// Sets the value of [minimum][crate::model::Distribution::minimum].
636    pub fn set_minimum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
637        self.minimum = v.into();
638        self
639    }
640
641    /// Sets the value of [maximum][crate::model::Distribution::maximum].
642    pub fn set_maximum<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
643        self.maximum = v.into();
644        self
645    }
646
647    /// Sets the value of [sum_of_squared_deviation][crate::model::Distribution::sum_of_squared_deviation].
648    pub fn set_sum_of_squared_deviation<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
649        self.sum_of_squared_deviation = v.into();
650        self
651    }
652
653    /// Sets the value of [bucket_counts][crate::model::Distribution::bucket_counts].
654    pub fn set_bucket_counts<T, V>(mut self, v: T) -> Self
655    where
656        T: std::iter::IntoIterator<Item = V>,
657        V: std::convert::Into<i64>,
658    {
659        use std::iter::Iterator;
660        self.bucket_counts = v.into_iter().map(|i| i.into()).collect();
661        self
662    }
663
664    /// Sets the value of [exemplars][crate::model::Distribution::exemplars].
665    pub fn set_exemplars<T, V>(mut self, v: T) -> Self
666    where
667        T: std::iter::IntoIterator<Item = V>,
668        V: std::convert::Into<api::model::distribution::Exemplar>,
669    {
670        use std::iter::Iterator;
671        self.exemplars = v.into_iter().map(|i| i.into()).collect();
672        self
673    }
674
675    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option].
676    ///
677    /// Note that all the setters affecting `bucket_option` are mutually
678    /// exclusive.
679    pub fn set_bucket_option<
680        T: std::convert::Into<std::option::Option<crate::model::distribution::BucketOption>>,
681    >(
682        mut self,
683        v: T,
684    ) -> Self {
685        self.bucket_option = v.into();
686        self
687    }
688
689    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
690    /// if it holds a `LinearBuckets`, `None` if the field is not set or
691    /// holds a different branch.
692    pub fn linear_buckets(
693        &self,
694    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::LinearBuckets>> {
695        #[allow(unreachable_patterns)]
696        self.bucket_option.as_ref().and_then(|v| match v {
697            crate::model::distribution::BucketOption::LinearBuckets(v) => {
698                std::option::Option::Some(v)
699            }
700            _ => std::option::Option::None,
701        })
702    }
703
704    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
705    /// to hold a `LinearBuckets`.
706    ///
707    /// Note that all the setters affecting `bucket_option` are
708    /// mutually exclusive.
709    pub fn set_linear_buckets<
710        T: std::convert::Into<std::boxed::Box<crate::model::distribution::LinearBuckets>>,
711    >(
712        mut self,
713        v: T,
714    ) -> Self {
715        self.bucket_option = std::option::Option::Some(
716            crate::model::distribution::BucketOption::LinearBuckets(v.into()),
717        );
718        self
719    }
720
721    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
722    /// if it holds a `ExponentialBuckets`, `None` if the field is not set or
723    /// holds a different branch.
724    pub fn exponential_buckets(
725        &self,
726    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExponentialBuckets>> {
727        #[allow(unreachable_patterns)]
728        self.bucket_option.as_ref().and_then(|v| match v {
729            crate::model::distribution::BucketOption::ExponentialBuckets(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 `ExponentialBuckets`.
738    ///
739    /// Note that all the setters affecting `bucket_option` are
740    /// mutually exclusive.
741    pub fn set_exponential_buckets<
742        T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExponentialBuckets>>,
743    >(
744        mut self,
745        v: T,
746    ) -> Self {
747        self.bucket_option = std::option::Option::Some(
748            crate::model::distribution::BucketOption::ExponentialBuckets(v.into()),
749        );
750        self
751    }
752
753    /// The value of [bucket_option][crate::model::Distribution::bucket_option]
754    /// if it holds a `ExplicitBuckets`, `None` if the field is not set or
755    /// holds a different branch.
756    pub fn explicit_buckets(
757        &self,
758    ) -> std::option::Option<&std::boxed::Box<crate::model::distribution::ExplicitBuckets>> {
759        #[allow(unreachable_patterns)]
760        self.bucket_option.as_ref().and_then(|v| match v {
761            crate::model::distribution::BucketOption::ExplicitBuckets(v) => {
762                std::option::Option::Some(v)
763            }
764            _ => std::option::Option::None,
765        })
766    }
767
768    /// Sets the value of [bucket_option][crate::model::Distribution::bucket_option]
769    /// to hold a `ExplicitBuckets`.
770    ///
771    /// Note that all the setters affecting `bucket_option` are
772    /// mutually exclusive.
773    pub fn set_explicit_buckets<
774        T: std::convert::Into<std::boxed::Box<crate::model::distribution::ExplicitBuckets>>,
775    >(
776        mut self,
777        v: T,
778    ) -> Self {
779        self.bucket_option = std::option::Option::Some(
780            crate::model::distribution::BucketOption::ExplicitBuckets(v.into()),
781        );
782        self
783    }
784}
785
786impl wkt::message::Message for Distribution {
787    fn typename() -> &'static str {
788        "type.googleapis.com/google.api.servicecontrol.v1.Distribution"
789    }
790}
791
792#[doc(hidden)]
793impl<'de> serde::de::Deserialize<'de> for Distribution {
794    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
795    where
796        D: serde::Deserializer<'de>,
797    {
798        #[allow(non_camel_case_types)]
799        #[doc(hidden)]
800        #[derive(PartialEq, Eq, Hash)]
801        enum __FieldTag {
802            __count,
803            __mean,
804            __minimum,
805            __maximum,
806            __sum_of_squared_deviation,
807            __bucket_counts,
808            __linear_buckets,
809            __exponential_buckets,
810            __explicit_buckets,
811            __exemplars,
812            Unknown(std::string::String),
813        }
814        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
815            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
816            where
817                D: serde::Deserializer<'de>,
818            {
819                struct Visitor;
820                impl<'de> serde::de::Visitor<'de> for Visitor {
821                    type Value = __FieldTag;
822                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
823                        formatter.write_str("a field name for Distribution")
824                    }
825                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
826                    where
827                        E: serde::de::Error,
828                    {
829                        use std::result::Result::Ok;
830                        use std::string::ToString;
831                        match value {
832                            "count" => Ok(__FieldTag::__count),
833                            "mean" => Ok(__FieldTag::__mean),
834                            "minimum" => Ok(__FieldTag::__minimum),
835                            "maximum" => Ok(__FieldTag::__maximum),
836                            "sumOfSquaredDeviation" => Ok(__FieldTag::__sum_of_squared_deviation),
837                            "sum_of_squared_deviation" => {
838                                Ok(__FieldTag::__sum_of_squared_deviation)
839                            }
840                            "bucketCounts" => Ok(__FieldTag::__bucket_counts),
841                            "bucket_counts" => Ok(__FieldTag::__bucket_counts),
842                            "linearBuckets" => Ok(__FieldTag::__linear_buckets),
843                            "linear_buckets" => Ok(__FieldTag::__linear_buckets),
844                            "exponentialBuckets" => Ok(__FieldTag::__exponential_buckets),
845                            "exponential_buckets" => Ok(__FieldTag::__exponential_buckets),
846                            "explicitBuckets" => Ok(__FieldTag::__explicit_buckets),
847                            "explicit_buckets" => Ok(__FieldTag::__explicit_buckets),
848                            "exemplars" => Ok(__FieldTag::__exemplars),
849                            _ => Ok(__FieldTag::Unknown(value.to_string())),
850                        }
851                    }
852                }
853                deserializer.deserialize_identifier(Visitor)
854            }
855        }
856        struct Visitor;
857        impl<'de> serde::de::Visitor<'de> for Visitor {
858            type Value = Distribution;
859            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
860                formatter.write_str("struct Distribution")
861            }
862            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
863            where
864                A: serde::de::MapAccess<'de>,
865            {
866                #[allow(unused_imports)]
867                use serde::de::Error;
868                use std::option::Option::Some;
869                let mut fields = std::collections::HashSet::new();
870                let mut result = Self::Value::new();
871                while let Some(tag) = map.next_key::<__FieldTag>()? {
872                    #[allow(clippy::match_single_binding)]
873                    match tag {
874                        __FieldTag::__count => {
875                            if !fields.insert(__FieldTag::__count) {
876                                return std::result::Result::Err(A::Error::duplicate_field(
877                                    "multiple values for count",
878                                ));
879                            }
880                            struct __With(std::option::Option<i64>);
881                            impl<'de> serde::de::Deserialize<'de> for __With {
882                                fn deserialize<D>(
883                                    deserializer: D,
884                                ) -> std::result::Result<Self, D::Error>
885                                where
886                                    D: serde::de::Deserializer<'de>,
887                                {
888                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
889                                }
890                            }
891                            result.count = map.next_value::<__With>()?.0.unwrap_or_default();
892                        }
893                        __FieldTag::__mean => {
894                            if !fields.insert(__FieldTag::__mean) {
895                                return std::result::Result::Err(A::Error::duplicate_field(
896                                    "multiple values for mean",
897                                ));
898                            }
899                            struct __With(std::option::Option<f64>);
900                            impl<'de> serde::de::Deserialize<'de> for __With {
901                                fn deserialize<D>(
902                                    deserializer: D,
903                                ) -> std::result::Result<Self, D::Error>
904                                where
905                                    D: serde::de::Deserializer<'de>,
906                                {
907                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
908                                }
909                            }
910                            result.mean = map.next_value::<__With>()?.0.unwrap_or_default();
911                        }
912                        __FieldTag::__minimum => {
913                            if !fields.insert(__FieldTag::__minimum) {
914                                return std::result::Result::Err(A::Error::duplicate_field(
915                                    "multiple values for minimum",
916                                ));
917                            }
918                            struct __With(std::option::Option<f64>);
919                            impl<'de> serde::de::Deserialize<'de> for __With {
920                                fn deserialize<D>(
921                                    deserializer: D,
922                                ) -> std::result::Result<Self, D::Error>
923                                where
924                                    D: serde::de::Deserializer<'de>,
925                                {
926                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
927                                }
928                            }
929                            result.minimum = map.next_value::<__With>()?.0.unwrap_or_default();
930                        }
931                        __FieldTag::__maximum => {
932                            if !fields.insert(__FieldTag::__maximum) {
933                                return std::result::Result::Err(A::Error::duplicate_field(
934                                    "multiple values for maximum",
935                                ));
936                            }
937                            struct __With(std::option::Option<f64>);
938                            impl<'de> serde::de::Deserialize<'de> for __With {
939                                fn deserialize<D>(
940                                    deserializer: D,
941                                ) -> std::result::Result<Self, D::Error>
942                                where
943                                    D: serde::de::Deserializer<'de>,
944                                {
945                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
946                                }
947                            }
948                            result.maximum = map.next_value::<__With>()?.0.unwrap_or_default();
949                        }
950                        __FieldTag::__sum_of_squared_deviation => {
951                            if !fields.insert(__FieldTag::__sum_of_squared_deviation) {
952                                return std::result::Result::Err(A::Error::duplicate_field(
953                                    "multiple values for sum_of_squared_deviation",
954                                ));
955                            }
956                            struct __With(std::option::Option<f64>);
957                            impl<'de> serde::de::Deserialize<'de> for __With {
958                                fn deserialize<D>(
959                                    deserializer: D,
960                                ) -> std::result::Result<Self, D::Error>
961                                where
962                                    D: serde::de::Deserializer<'de>,
963                                {
964                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
965                                }
966                            }
967                            result.sum_of_squared_deviation =
968                                map.next_value::<__With>()?.0.unwrap_or_default();
969                        }
970                        __FieldTag::__bucket_counts => {
971                            if !fields.insert(__FieldTag::__bucket_counts) {
972                                return std::result::Result::Err(A::Error::duplicate_field(
973                                    "multiple values for bucket_counts",
974                                ));
975                            }
976                            struct __With(std::option::Option<std::vec::Vec<i64>>);
977                            impl<'de> serde::de::Deserialize<'de> for __With {
978                                fn deserialize<D>(
979                                    deserializer: D,
980                                ) -> std::result::Result<Self, D::Error>
981                                where
982                                    D: serde::de::Deserializer<'de>,
983                                {
984                                    serde_with::As::<
985                                        std::option::Option<std::vec::Vec<wkt::internal::I64>>,
986                                    >::deserialize(deserializer)
987                                    .map(__With)
988                                }
989                            }
990                            result.bucket_counts =
991                                map.next_value::<__With>()?.0.unwrap_or_default();
992                        }
993                        __FieldTag::__linear_buckets => {
994                            if !fields.insert(__FieldTag::__linear_buckets) {
995                                return std::result::Result::Err(A::Error::duplicate_field(
996                                    "multiple values for linear_buckets",
997                                ));
998                            }
999                            if result.bucket_option.is_some() {
1000                                return std::result::Result::Err(A::Error::duplicate_field(
1001                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.linear_buckets, latest field was linearBuckets",
1002                                ));
1003                            }
1004                            result.bucket_option = std::option::Option::Some(
1005                                crate::model::distribution::BucketOption::LinearBuckets(
1006                                    map.next_value::<std::option::Option<
1007                                        std::boxed::Box<crate::model::distribution::LinearBuckets>,
1008                                    >>()?
1009                                    .unwrap_or_default(),
1010                                ),
1011                            );
1012                        }
1013                        __FieldTag::__exponential_buckets => {
1014                            if !fields.insert(__FieldTag::__exponential_buckets) {
1015                                return std::result::Result::Err(A::Error::duplicate_field(
1016                                    "multiple values for exponential_buckets",
1017                                ));
1018                            }
1019                            if result.bucket_option.is_some() {
1020                                return std::result::Result::Err(A::Error::duplicate_field(
1021                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.exponential_buckets, latest field was exponentialBuckets",
1022                                ));
1023                            }
1024                            result.bucket_option = std::option::Option::Some(
1025                                crate::model::distribution::BucketOption::ExponentialBuckets(
1026                                    map.next_value::<std::option::Option<
1027                                        std::boxed::Box<
1028                                            crate::model::distribution::ExponentialBuckets,
1029                                        >,
1030                                    >>()?
1031                                    .unwrap_or_default(),
1032                                ),
1033                            );
1034                        }
1035                        __FieldTag::__explicit_buckets => {
1036                            if !fields.insert(__FieldTag::__explicit_buckets) {
1037                                return std::result::Result::Err(A::Error::duplicate_field(
1038                                    "multiple values for explicit_buckets",
1039                                ));
1040                            }
1041                            if result.bucket_option.is_some() {
1042                                return std::result::Result::Err(A::Error::duplicate_field(
1043                                    "multiple values for `bucket_option`, a oneof with full ID .google.api.servicecontrol.v1.Distribution.explicit_buckets, latest field was explicitBuckets",
1044                                ));
1045                            }
1046                            result.bucket_option = std::option::Option::Some(
1047                                crate::model::distribution::BucketOption::ExplicitBuckets(
1048                                    map.next_value::<std::option::Option<
1049                                        std::boxed::Box<
1050                                            crate::model::distribution::ExplicitBuckets,
1051                                        >,
1052                                    >>()?
1053                                    .unwrap_or_default(),
1054                                ),
1055                            );
1056                        }
1057                        __FieldTag::__exemplars => {
1058                            if !fields.insert(__FieldTag::__exemplars) {
1059                                return std::result::Result::Err(A::Error::duplicate_field(
1060                                    "multiple values for exemplars",
1061                                ));
1062                            }
1063                            result.exemplars = map
1064                                .next_value::<std::option::Option<
1065                                    std::vec::Vec<api::model::distribution::Exemplar>,
1066                                >>()?
1067                                .unwrap_or_default();
1068                        }
1069                        __FieldTag::Unknown(key) => {
1070                            let value = map.next_value::<serde_json::Value>()?;
1071                            result._unknown_fields.insert(key, value);
1072                        }
1073                    }
1074                }
1075                std::result::Result::Ok(result)
1076            }
1077        }
1078        deserializer.deserialize_any(Visitor)
1079    }
1080}
1081
1082#[doc(hidden)]
1083impl serde::ser::Serialize for Distribution {
1084    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1085    where
1086        S: serde::ser::Serializer,
1087    {
1088        use serde::ser::SerializeMap;
1089        #[allow(unused_imports)]
1090        use std::option::Option::Some;
1091        let mut state = serializer.serialize_map(std::option::Option::None)?;
1092        if !wkt::internal::is_default(&self.count) {
1093            struct __With<'a>(&'a i64);
1094            impl<'a> serde::ser::Serialize for __With<'a> {
1095                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1096                where
1097                    S: serde::ser::Serializer,
1098                {
1099                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
1100                }
1101            }
1102            state.serialize_entry("count", &__With(&self.count))?;
1103        }
1104        if !wkt::internal::is_default(&self.mean) {
1105            struct __With<'a>(&'a f64);
1106            impl<'a> serde::ser::Serialize for __With<'a> {
1107                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1108                where
1109                    S: serde::ser::Serializer,
1110                {
1111                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1112                }
1113            }
1114            state.serialize_entry("mean", &__With(&self.mean))?;
1115        }
1116        if !wkt::internal::is_default(&self.minimum) {
1117            struct __With<'a>(&'a f64);
1118            impl<'a> serde::ser::Serialize for __With<'a> {
1119                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1120                where
1121                    S: serde::ser::Serializer,
1122                {
1123                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1124                }
1125            }
1126            state.serialize_entry("minimum", &__With(&self.minimum))?;
1127        }
1128        if !wkt::internal::is_default(&self.maximum) {
1129            struct __With<'a>(&'a f64);
1130            impl<'a> serde::ser::Serialize for __With<'a> {
1131                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1132                where
1133                    S: serde::ser::Serializer,
1134                {
1135                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1136                }
1137            }
1138            state.serialize_entry("maximum", &__With(&self.maximum))?;
1139        }
1140        if !wkt::internal::is_default(&self.sum_of_squared_deviation) {
1141            struct __With<'a>(&'a f64);
1142            impl<'a> serde::ser::Serialize for __With<'a> {
1143                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1144                where
1145                    S: serde::ser::Serializer,
1146                {
1147                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1148                }
1149            }
1150            state.serialize_entry(
1151                "sumOfSquaredDeviation",
1152                &__With(&self.sum_of_squared_deviation),
1153            )?;
1154        }
1155        if !self.bucket_counts.is_empty() {
1156            struct __With<'a>(&'a std::vec::Vec<i64>);
1157            impl<'a> serde::ser::Serialize for __With<'a> {
1158                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1159                where
1160                    S: serde::ser::Serializer,
1161                {
1162                    serde_with::As::<std::vec::Vec<wkt::internal::I64>>::serialize(
1163                        self.0, serializer,
1164                    )
1165                }
1166            }
1167            state.serialize_entry("bucketCounts", &__With(&self.bucket_counts))?;
1168        }
1169        if let Some(value) = self.linear_buckets() {
1170            state.serialize_entry("linearBuckets", value)?;
1171        }
1172        if let Some(value) = self.exponential_buckets() {
1173            state.serialize_entry("exponentialBuckets", value)?;
1174        }
1175        if let Some(value) = self.explicit_buckets() {
1176            state.serialize_entry("explicitBuckets", value)?;
1177        }
1178        if !self.exemplars.is_empty() {
1179            state.serialize_entry("exemplars", &self.exemplars)?;
1180        }
1181        if !self._unknown_fields.is_empty() {
1182            for (key, value) in self._unknown_fields.iter() {
1183                state.serialize_entry(key, &value)?;
1184            }
1185        }
1186        state.end()
1187    }
1188}
1189
1190/// Defines additional types related to [Distribution].
1191pub mod distribution {
1192    #[allow(unused_imports)]
1193    use super::*;
1194
1195    /// Describing buckets with constant width.
1196    #[derive(Clone, Debug, Default, PartialEq)]
1197    #[non_exhaustive]
1198    pub struct LinearBuckets {
1199        /// The number of finite buckets. With the underflow and overflow buckets,
1200        /// the total number of buckets is `num_finite_buckets` + 2.
1201        /// See comments on `bucket_options` for details.
1202        pub num_finite_buckets: i32,
1203
1204        /// The i'th linear bucket covers the interval
1205        /// [offset + (i-1) * width, offset + i * width)
1206        /// where i ranges from 1 to num_finite_buckets, inclusive.
1207        /// Must be strictly positive.
1208        pub width: f64,
1209
1210        /// The i'th linear bucket covers the interval
1211        /// [offset + (i-1) * width, offset + i * width)
1212        /// where i ranges from 1 to num_finite_buckets, inclusive.
1213        pub offset: f64,
1214
1215        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1216    }
1217
1218    impl LinearBuckets {
1219        pub fn new() -> Self {
1220            std::default::Default::default()
1221        }
1222
1223        /// Sets the value of [num_finite_buckets][crate::model::distribution::LinearBuckets::num_finite_buckets].
1224        pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1225            self.num_finite_buckets = v.into();
1226            self
1227        }
1228
1229        /// Sets the value of [width][crate::model::distribution::LinearBuckets::width].
1230        pub fn set_width<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1231            self.width = v.into();
1232            self
1233        }
1234
1235        /// Sets the value of [offset][crate::model::distribution::LinearBuckets::offset].
1236        pub fn set_offset<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1237            self.offset = v.into();
1238            self
1239        }
1240    }
1241
1242    impl wkt::message::Message for LinearBuckets {
1243        fn typename() -> &'static str {
1244            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.LinearBuckets"
1245        }
1246    }
1247
1248    #[doc(hidden)]
1249    impl<'de> serde::de::Deserialize<'de> for LinearBuckets {
1250        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1251        where
1252            D: serde::Deserializer<'de>,
1253        {
1254            #[allow(non_camel_case_types)]
1255            #[doc(hidden)]
1256            #[derive(PartialEq, Eq, Hash)]
1257            enum __FieldTag {
1258                __num_finite_buckets,
1259                __width,
1260                __offset,
1261                Unknown(std::string::String),
1262            }
1263            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1264                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1265                where
1266                    D: serde::Deserializer<'de>,
1267                {
1268                    struct Visitor;
1269                    impl<'de> serde::de::Visitor<'de> for Visitor {
1270                        type Value = __FieldTag;
1271                        fn expecting(
1272                            &self,
1273                            formatter: &mut std::fmt::Formatter,
1274                        ) -> std::fmt::Result {
1275                            formatter.write_str("a field name for LinearBuckets")
1276                        }
1277                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1278                        where
1279                            E: serde::de::Error,
1280                        {
1281                            use std::result::Result::Ok;
1282                            use std::string::ToString;
1283                            match value {
1284                                "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
1285                                "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
1286                                "width" => Ok(__FieldTag::__width),
1287                                "offset" => Ok(__FieldTag::__offset),
1288                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1289                            }
1290                        }
1291                    }
1292                    deserializer.deserialize_identifier(Visitor)
1293                }
1294            }
1295            struct Visitor;
1296            impl<'de> serde::de::Visitor<'de> for Visitor {
1297                type Value = LinearBuckets;
1298                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1299                    formatter.write_str("struct LinearBuckets")
1300                }
1301                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1302                where
1303                    A: serde::de::MapAccess<'de>,
1304                {
1305                    #[allow(unused_imports)]
1306                    use serde::de::Error;
1307                    use std::option::Option::Some;
1308                    let mut fields = std::collections::HashSet::new();
1309                    let mut result = Self::Value::new();
1310                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1311                        #[allow(clippy::match_single_binding)]
1312                        match tag {
1313                            __FieldTag::__num_finite_buckets => {
1314                                if !fields.insert(__FieldTag::__num_finite_buckets) {
1315                                    return std::result::Result::Err(A::Error::duplicate_field(
1316                                        "multiple values for num_finite_buckets",
1317                                    ));
1318                                }
1319                                struct __With(std::option::Option<i32>);
1320                                impl<'de> serde::de::Deserialize<'de> for __With {
1321                                    fn deserialize<D>(
1322                                        deserializer: D,
1323                                    ) -> std::result::Result<Self, D::Error>
1324                                    where
1325                                        D: serde::de::Deserializer<'de>,
1326                                    {
1327                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1328                                    }
1329                                }
1330                                result.num_finite_buckets =
1331                                    map.next_value::<__With>()?.0.unwrap_or_default();
1332                            }
1333                            __FieldTag::__width => {
1334                                if !fields.insert(__FieldTag::__width) {
1335                                    return std::result::Result::Err(A::Error::duplicate_field(
1336                                        "multiple values for width",
1337                                    ));
1338                                }
1339                                struct __With(std::option::Option<f64>);
1340                                impl<'de> serde::de::Deserialize<'de> for __With {
1341                                    fn deserialize<D>(
1342                                        deserializer: D,
1343                                    ) -> std::result::Result<Self, D::Error>
1344                                    where
1345                                        D: serde::de::Deserializer<'de>,
1346                                    {
1347                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1348                                    }
1349                                }
1350                                result.width = map.next_value::<__With>()?.0.unwrap_or_default();
1351                            }
1352                            __FieldTag::__offset => {
1353                                if !fields.insert(__FieldTag::__offset) {
1354                                    return std::result::Result::Err(A::Error::duplicate_field(
1355                                        "multiple values for offset",
1356                                    ));
1357                                }
1358                                struct __With(std::option::Option<f64>);
1359                                impl<'de> serde::de::Deserialize<'de> for __With {
1360                                    fn deserialize<D>(
1361                                        deserializer: D,
1362                                    ) -> std::result::Result<Self, D::Error>
1363                                    where
1364                                        D: serde::de::Deserializer<'de>,
1365                                    {
1366                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1367                                    }
1368                                }
1369                                result.offset = map.next_value::<__With>()?.0.unwrap_or_default();
1370                            }
1371                            __FieldTag::Unknown(key) => {
1372                                let value = map.next_value::<serde_json::Value>()?;
1373                                result._unknown_fields.insert(key, value);
1374                            }
1375                        }
1376                    }
1377                    std::result::Result::Ok(result)
1378                }
1379            }
1380            deserializer.deserialize_any(Visitor)
1381        }
1382    }
1383
1384    #[doc(hidden)]
1385    impl serde::ser::Serialize for LinearBuckets {
1386        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1387        where
1388            S: serde::ser::Serializer,
1389        {
1390            use serde::ser::SerializeMap;
1391            #[allow(unused_imports)]
1392            use std::option::Option::Some;
1393            let mut state = serializer.serialize_map(std::option::Option::None)?;
1394            if !wkt::internal::is_default(&self.num_finite_buckets) {
1395                struct __With<'a>(&'a i32);
1396                impl<'a> serde::ser::Serialize for __With<'a> {
1397                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1398                    where
1399                        S: serde::ser::Serializer,
1400                    {
1401                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1402                    }
1403                }
1404                state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
1405            }
1406            if !wkt::internal::is_default(&self.width) {
1407                struct __With<'a>(&'a f64);
1408                impl<'a> serde::ser::Serialize for __With<'a> {
1409                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1410                    where
1411                        S: serde::ser::Serializer,
1412                    {
1413                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1414                    }
1415                }
1416                state.serialize_entry("width", &__With(&self.width))?;
1417            }
1418            if !wkt::internal::is_default(&self.offset) {
1419                struct __With<'a>(&'a f64);
1420                impl<'a> serde::ser::Serialize for __With<'a> {
1421                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1422                    where
1423                        S: serde::ser::Serializer,
1424                    {
1425                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1426                    }
1427                }
1428                state.serialize_entry("offset", &__With(&self.offset))?;
1429            }
1430            if !self._unknown_fields.is_empty() {
1431                for (key, value) in self._unknown_fields.iter() {
1432                    state.serialize_entry(key, &value)?;
1433                }
1434            }
1435            state.end()
1436        }
1437    }
1438
1439    /// Describing buckets with exponentially growing width.
1440    #[derive(Clone, Debug, Default, PartialEq)]
1441    #[non_exhaustive]
1442    pub struct ExponentialBuckets {
1443        /// The number of finite buckets. With the underflow and overflow buckets,
1444        /// the total number of buckets is `num_finite_buckets` + 2.
1445        /// See comments on `bucket_options` for details.
1446        pub num_finite_buckets: i32,
1447
1448        /// The i'th exponential bucket covers the interval
1449        /// [scale * growth_factor^(i-1), scale * growth_factor^i)
1450        /// where i ranges from 1 to num_finite_buckets inclusive.
1451        /// Must be larger than 1.0.
1452        pub growth_factor: f64,
1453
1454        /// The i'th exponential bucket covers the interval
1455        /// [scale * growth_factor^(i-1), scale * growth_factor^i)
1456        /// where i ranges from 1 to num_finite_buckets inclusive.
1457        /// Must be > 0.
1458        pub scale: f64,
1459
1460        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1461    }
1462
1463    impl ExponentialBuckets {
1464        pub fn new() -> Self {
1465            std::default::Default::default()
1466        }
1467
1468        /// Sets the value of [num_finite_buckets][crate::model::distribution::ExponentialBuckets::num_finite_buckets].
1469        pub fn set_num_finite_buckets<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1470            self.num_finite_buckets = v.into();
1471            self
1472        }
1473
1474        /// Sets the value of [growth_factor][crate::model::distribution::ExponentialBuckets::growth_factor].
1475        pub fn set_growth_factor<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1476            self.growth_factor = v.into();
1477            self
1478        }
1479
1480        /// Sets the value of [scale][crate::model::distribution::ExponentialBuckets::scale].
1481        pub fn set_scale<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1482            self.scale = v.into();
1483            self
1484        }
1485    }
1486
1487    impl wkt::message::Message for ExponentialBuckets {
1488        fn typename() -> &'static str {
1489            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExponentialBuckets"
1490        }
1491    }
1492
1493    #[doc(hidden)]
1494    impl<'de> serde::de::Deserialize<'de> for ExponentialBuckets {
1495        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1496        where
1497            D: serde::Deserializer<'de>,
1498        {
1499            #[allow(non_camel_case_types)]
1500            #[doc(hidden)]
1501            #[derive(PartialEq, Eq, Hash)]
1502            enum __FieldTag {
1503                __num_finite_buckets,
1504                __growth_factor,
1505                __scale,
1506                Unknown(std::string::String),
1507            }
1508            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1509                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1510                where
1511                    D: serde::Deserializer<'de>,
1512                {
1513                    struct Visitor;
1514                    impl<'de> serde::de::Visitor<'de> for Visitor {
1515                        type Value = __FieldTag;
1516                        fn expecting(
1517                            &self,
1518                            formatter: &mut std::fmt::Formatter,
1519                        ) -> std::fmt::Result {
1520                            formatter.write_str("a field name for ExponentialBuckets")
1521                        }
1522                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1523                        where
1524                            E: serde::de::Error,
1525                        {
1526                            use std::result::Result::Ok;
1527                            use std::string::ToString;
1528                            match value {
1529                                "numFiniteBuckets" => Ok(__FieldTag::__num_finite_buckets),
1530                                "num_finite_buckets" => Ok(__FieldTag::__num_finite_buckets),
1531                                "growthFactor" => Ok(__FieldTag::__growth_factor),
1532                                "growth_factor" => Ok(__FieldTag::__growth_factor),
1533                                "scale" => Ok(__FieldTag::__scale),
1534                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1535                            }
1536                        }
1537                    }
1538                    deserializer.deserialize_identifier(Visitor)
1539                }
1540            }
1541            struct Visitor;
1542            impl<'de> serde::de::Visitor<'de> for Visitor {
1543                type Value = ExponentialBuckets;
1544                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1545                    formatter.write_str("struct ExponentialBuckets")
1546                }
1547                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1548                where
1549                    A: serde::de::MapAccess<'de>,
1550                {
1551                    #[allow(unused_imports)]
1552                    use serde::de::Error;
1553                    use std::option::Option::Some;
1554                    let mut fields = std::collections::HashSet::new();
1555                    let mut result = Self::Value::new();
1556                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1557                        #[allow(clippy::match_single_binding)]
1558                        match tag {
1559                            __FieldTag::__num_finite_buckets => {
1560                                if !fields.insert(__FieldTag::__num_finite_buckets) {
1561                                    return std::result::Result::Err(A::Error::duplicate_field(
1562                                        "multiple values for num_finite_buckets",
1563                                    ));
1564                                }
1565                                struct __With(std::option::Option<i32>);
1566                                impl<'de> serde::de::Deserialize<'de> for __With {
1567                                    fn deserialize<D>(
1568                                        deserializer: D,
1569                                    ) -> std::result::Result<Self, D::Error>
1570                                    where
1571                                        D: serde::de::Deserializer<'de>,
1572                                    {
1573                                        serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
1574                                    }
1575                                }
1576                                result.num_finite_buckets =
1577                                    map.next_value::<__With>()?.0.unwrap_or_default();
1578                            }
1579                            __FieldTag::__growth_factor => {
1580                                if !fields.insert(__FieldTag::__growth_factor) {
1581                                    return std::result::Result::Err(A::Error::duplicate_field(
1582                                        "multiple values for growth_factor",
1583                                    ));
1584                                }
1585                                struct __With(std::option::Option<f64>);
1586                                impl<'de> serde::de::Deserialize<'de> for __With {
1587                                    fn deserialize<D>(
1588                                        deserializer: D,
1589                                    ) -> std::result::Result<Self, D::Error>
1590                                    where
1591                                        D: serde::de::Deserializer<'de>,
1592                                    {
1593                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1594                                    }
1595                                }
1596                                result.growth_factor =
1597                                    map.next_value::<__With>()?.0.unwrap_or_default();
1598                            }
1599                            __FieldTag::__scale => {
1600                                if !fields.insert(__FieldTag::__scale) {
1601                                    return std::result::Result::Err(A::Error::duplicate_field(
1602                                        "multiple values for scale",
1603                                    ));
1604                                }
1605                                struct __With(std::option::Option<f64>);
1606                                impl<'de> serde::de::Deserialize<'de> for __With {
1607                                    fn deserialize<D>(
1608                                        deserializer: D,
1609                                    ) -> std::result::Result<Self, D::Error>
1610                                    where
1611                                        D: serde::de::Deserializer<'de>,
1612                                    {
1613                                        serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
1614                                    }
1615                                }
1616                                result.scale = map.next_value::<__With>()?.0.unwrap_or_default();
1617                            }
1618                            __FieldTag::Unknown(key) => {
1619                                let value = map.next_value::<serde_json::Value>()?;
1620                                result._unknown_fields.insert(key, value);
1621                            }
1622                        }
1623                    }
1624                    std::result::Result::Ok(result)
1625                }
1626            }
1627            deserializer.deserialize_any(Visitor)
1628        }
1629    }
1630
1631    #[doc(hidden)]
1632    impl serde::ser::Serialize for ExponentialBuckets {
1633        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1634        where
1635            S: serde::ser::Serializer,
1636        {
1637            use serde::ser::SerializeMap;
1638            #[allow(unused_imports)]
1639            use std::option::Option::Some;
1640            let mut state = serializer.serialize_map(std::option::Option::None)?;
1641            if !wkt::internal::is_default(&self.num_finite_buckets) {
1642                struct __With<'a>(&'a i32);
1643                impl<'a> serde::ser::Serialize for __With<'a> {
1644                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1645                    where
1646                        S: serde::ser::Serializer,
1647                    {
1648                        serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
1649                    }
1650                }
1651                state.serialize_entry("numFiniteBuckets", &__With(&self.num_finite_buckets))?;
1652            }
1653            if !wkt::internal::is_default(&self.growth_factor) {
1654                struct __With<'a>(&'a f64);
1655                impl<'a> serde::ser::Serialize for __With<'a> {
1656                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1657                    where
1658                        S: serde::ser::Serializer,
1659                    {
1660                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1661                    }
1662                }
1663                state.serialize_entry("growthFactor", &__With(&self.growth_factor))?;
1664            }
1665            if !wkt::internal::is_default(&self.scale) {
1666                struct __With<'a>(&'a f64);
1667                impl<'a> serde::ser::Serialize for __With<'a> {
1668                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1669                    where
1670                        S: serde::ser::Serializer,
1671                    {
1672                        serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
1673                    }
1674                }
1675                state.serialize_entry("scale", &__With(&self.scale))?;
1676            }
1677            if !self._unknown_fields.is_empty() {
1678                for (key, value) in self._unknown_fields.iter() {
1679                    state.serialize_entry(key, &value)?;
1680                }
1681            }
1682            state.end()
1683        }
1684    }
1685
1686    /// Describing buckets with arbitrary user-provided width.
1687    #[derive(Clone, Debug, Default, PartialEq)]
1688    #[non_exhaustive]
1689    pub struct ExplicitBuckets {
1690        /// 'bound' is a list of strictly increasing boundaries between
1691        /// buckets. Note that a list of length N-1 defines N buckets because
1692        /// of fenceposting. See comments on `bucket_options` for details.
1693        ///
1694        /// The i'th finite bucket covers the interval
1695        /// [bound[i-1], bound[i])
1696        /// where i ranges from 1 to bound_size() - 1. Note that there are no
1697        /// finite buckets at all if 'bound' only contains a single element; in
1698        /// that special case the single bound defines the boundary between the
1699        /// underflow and overflow buckets.
1700        ///
1701        /// bucket number                   lower bound    upper bound
1702        /// i == 0 (underflow)              -inf           bound[i]
1703        /// 0 < i < bound_size()            bound[i-1]     bound[i]
1704        /// i == bound_size() (overflow)    bound[i-1]     +inf
1705        pub bounds: std::vec::Vec<f64>,
1706
1707        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1708    }
1709
1710    impl ExplicitBuckets {
1711        pub fn new() -> Self {
1712            std::default::Default::default()
1713        }
1714
1715        /// Sets the value of [bounds][crate::model::distribution::ExplicitBuckets::bounds].
1716        pub fn set_bounds<T, V>(mut self, v: T) -> Self
1717        where
1718            T: std::iter::IntoIterator<Item = V>,
1719            V: std::convert::Into<f64>,
1720        {
1721            use std::iter::Iterator;
1722            self.bounds = v.into_iter().map(|i| i.into()).collect();
1723            self
1724        }
1725    }
1726
1727    impl wkt::message::Message for ExplicitBuckets {
1728        fn typename() -> &'static str {
1729            "type.googleapis.com/google.api.servicecontrol.v1.Distribution.ExplicitBuckets"
1730        }
1731    }
1732
1733    #[doc(hidden)]
1734    impl<'de> serde::de::Deserialize<'de> for ExplicitBuckets {
1735        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1736        where
1737            D: serde::Deserializer<'de>,
1738        {
1739            #[allow(non_camel_case_types)]
1740            #[doc(hidden)]
1741            #[derive(PartialEq, Eq, Hash)]
1742            enum __FieldTag {
1743                __bounds,
1744                Unknown(std::string::String),
1745            }
1746            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1747                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1748                where
1749                    D: serde::Deserializer<'de>,
1750                {
1751                    struct Visitor;
1752                    impl<'de> serde::de::Visitor<'de> for Visitor {
1753                        type Value = __FieldTag;
1754                        fn expecting(
1755                            &self,
1756                            formatter: &mut std::fmt::Formatter,
1757                        ) -> std::fmt::Result {
1758                            formatter.write_str("a field name for ExplicitBuckets")
1759                        }
1760                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1761                        where
1762                            E: serde::de::Error,
1763                        {
1764                            use std::result::Result::Ok;
1765                            use std::string::ToString;
1766                            match value {
1767                                "bounds" => Ok(__FieldTag::__bounds),
1768                                _ => Ok(__FieldTag::Unknown(value.to_string())),
1769                            }
1770                        }
1771                    }
1772                    deserializer.deserialize_identifier(Visitor)
1773                }
1774            }
1775            struct Visitor;
1776            impl<'de> serde::de::Visitor<'de> for Visitor {
1777                type Value = ExplicitBuckets;
1778                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1779                    formatter.write_str("struct ExplicitBuckets")
1780                }
1781                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1782                where
1783                    A: serde::de::MapAccess<'de>,
1784                {
1785                    #[allow(unused_imports)]
1786                    use serde::de::Error;
1787                    use std::option::Option::Some;
1788                    let mut fields = std::collections::HashSet::new();
1789                    let mut result = Self::Value::new();
1790                    while let Some(tag) = map.next_key::<__FieldTag>()? {
1791                        #[allow(clippy::match_single_binding)]
1792                        match tag {
1793                            __FieldTag::__bounds => {
1794                                if !fields.insert(__FieldTag::__bounds) {
1795                                    return std::result::Result::Err(A::Error::duplicate_field(
1796                                        "multiple values for bounds",
1797                                    ));
1798                                }
1799                                struct __With(std::option::Option<std::vec::Vec<f64>>);
1800                                impl<'de> serde::de::Deserialize<'de> for __With {
1801                                    fn deserialize<D>(
1802                                        deserializer: D,
1803                                    ) -> std::result::Result<Self, D::Error>
1804                                    where
1805                                        D: serde::de::Deserializer<'de>,
1806                                    {
1807                                        serde_with::As::<
1808                                            std::option::Option<std::vec::Vec<wkt::internal::F64>>,
1809                                        >::deserialize(
1810                                            deserializer
1811                                        )
1812                                        .map(__With)
1813                                    }
1814                                }
1815                                result.bounds = map.next_value::<__With>()?.0.unwrap_or_default();
1816                            }
1817                            __FieldTag::Unknown(key) => {
1818                                let value = map.next_value::<serde_json::Value>()?;
1819                                result._unknown_fields.insert(key, value);
1820                            }
1821                        }
1822                    }
1823                    std::result::Result::Ok(result)
1824                }
1825            }
1826            deserializer.deserialize_any(Visitor)
1827        }
1828    }
1829
1830    #[doc(hidden)]
1831    impl serde::ser::Serialize for ExplicitBuckets {
1832        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1833        where
1834            S: serde::ser::Serializer,
1835        {
1836            use serde::ser::SerializeMap;
1837            #[allow(unused_imports)]
1838            use std::option::Option::Some;
1839            let mut state = serializer.serialize_map(std::option::Option::None)?;
1840            if !self.bounds.is_empty() {
1841                struct __With<'a>(&'a std::vec::Vec<f64>);
1842                impl<'a> serde::ser::Serialize for __With<'a> {
1843                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1844                    where
1845                        S: serde::ser::Serializer,
1846                    {
1847                        serde_with::As::<std::vec::Vec<wkt::internal::F64>>::serialize(
1848                            self.0, serializer,
1849                        )
1850                    }
1851                }
1852                state.serialize_entry("bounds", &__With(&self.bounds))?;
1853            }
1854            if !self._unknown_fields.is_empty() {
1855                for (key, value) in self._unknown_fields.iter() {
1856                    state.serialize_entry(key, &value)?;
1857                }
1858            }
1859            state.end()
1860        }
1861    }
1862
1863    /// Defines the buckets in the histogram. `bucket_option` and `bucket_counts`
1864    /// must be both set, or both unset.
1865    ///
1866    /// Buckets are numbered in the range of [0, N], with a total of N+1 buckets.
1867    /// There must be at least two buckets (a single-bucket histogram gives
1868    /// no information that isn't already provided by `count`).
1869    ///
1870    /// The first bucket is the underflow bucket which has a lower bound
1871    /// of -inf. The last bucket is the overflow bucket which has an
1872    /// upper bound of +inf. All other buckets (if any) are called "finite"
1873    /// buckets because they have finite lower and upper bounds. As described
1874    /// below, there are three ways to define the finite buckets.
1875    ///
1876    /// (1) Buckets with constant width.
1877    /// (2) Buckets with exponentially growing widths.
1878    /// (3) Buckets with arbitrary user-provided widths.
1879    ///
1880    /// In all cases, the buckets cover the entire real number line (-inf,
1881    /// +inf). Bucket upper bounds are exclusive and lower bounds are
1882    /// inclusive. The upper bound of the underflow bucket is equal to the
1883    /// lower bound of the smallest finite bucket; the lower bound of the
1884    /// overflow bucket is equal to the upper bound of the largest finite
1885    /// bucket.
1886    #[derive(Clone, Debug, PartialEq)]
1887    #[non_exhaustive]
1888    pub enum BucketOption {
1889        /// Buckets with constant width.
1890        LinearBuckets(std::boxed::Box<crate::model::distribution::LinearBuckets>),
1891        /// Buckets with exponentially growing width.
1892        ExponentialBuckets(std::boxed::Box<crate::model::distribution::ExponentialBuckets>),
1893        /// Buckets with arbitrary user-provided width.
1894        ExplicitBuckets(std::boxed::Box<crate::model::distribution::ExplicitBuckets>),
1895    }
1896}
1897
1898/// A common proto for logging HTTP requests. Only contains semantics
1899/// defined by the HTTP specification. Product-specific logging
1900/// information MUST be defined in a separate message.
1901#[derive(Clone, Debug, Default, PartialEq)]
1902#[non_exhaustive]
1903pub struct HttpRequest {
1904    /// The request method. Examples: `"GET"`, `"HEAD"`, `"PUT"`, `"POST"`.
1905    pub request_method: std::string::String,
1906
1907    /// The scheme (http, https), the host name, the path, and the query
1908    /// portion of the URL that was requested.
1909    /// Example: ``http://example.com/some/info?color=red``.
1910    pub request_url: std::string::String,
1911
1912    /// The size of the HTTP request message in bytes, including the request
1913    /// headers and the request body.
1914    pub request_size: i64,
1915
1916    /// The response code indicating the status of the response.
1917    /// Examples: 200, 404.
1918    pub status: i32,
1919
1920    /// The size of the HTTP response message sent back to the client, in bytes,
1921    /// including the response headers and the response body.
1922    pub response_size: i64,
1923
1924    /// The user agent sent by the client. Example:
1925    /// `"Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Q312461; .NET
1926    /// CLR 1.0.3705)"`.
1927    pub user_agent: std::string::String,
1928
1929    /// The IP address (IPv4 or IPv6) of the client that issued the HTTP
1930    /// request. Examples: `"192.168.1.1"`, `"FE80::0202:B3FF:FE1E:8329"`.
1931    pub remote_ip: std::string::String,
1932
1933    /// The IP address (IPv4 or IPv6) of the origin server that the request was
1934    /// sent to.
1935    pub server_ip: std::string::String,
1936
1937    /// The referer URL of the request, as defined in
1938    /// [HTTP/1.1 Header Field
1939    /// Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
1940    pub referer: std::string::String,
1941
1942    /// The request processing latency on the server, from the time the request was
1943    /// received until the response was sent.
1944    pub latency: std::option::Option<wkt::Duration>,
1945
1946    /// Whether or not a cache lookup was attempted.
1947    pub cache_lookup: bool,
1948
1949    /// Whether or not an entity was served from cache
1950    /// (with or without validation).
1951    pub cache_hit: bool,
1952
1953    /// Whether or not the response was validated with the origin server before
1954    /// being served from cache. This field is only meaningful if `cache_hit` is
1955    /// True.
1956    pub cache_validated_with_origin_server: bool,
1957
1958    /// The number of HTTP response bytes inserted into cache. Set only when a
1959    /// cache fill was attempted.
1960    pub cache_fill_bytes: i64,
1961
1962    /// Protocol used for the request. Examples: "HTTP/1.1", "HTTP/2", "websocket"
1963    pub protocol: std::string::String,
1964
1965    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1966}
1967
1968impl HttpRequest {
1969    pub fn new() -> Self {
1970        std::default::Default::default()
1971    }
1972
1973    /// Sets the value of [request_method][crate::model::HttpRequest::request_method].
1974    pub fn set_request_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1975        self.request_method = v.into();
1976        self
1977    }
1978
1979    /// Sets the value of [request_url][crate::model::HttpRequest::request_url].
1980    pub fn set_request_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1981        self.request_url = v.into();
1982        self
1983    }
1984
1985    /// Sets the value of [request_size][crate::model::HttpRequest::request_size].
1986    pub fn set_request_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1987        self.request_size = v.into();
1988        self
1989    }
1990
1991    /// Sets the value of [status][crate::model::HttpRequest::status].
1992    pub fn set_status<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1993        self.status = v.into();
1994        self
1995    }
1996
1997    /// Sets the value of [response_size][crate::model::HttpRequest::response_size].
1998    pub fn set_response_size<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
1999        self.response_size = v.into();
2000        self
2001    }
2002
2003    /// Sets the value of [user_agent][crate::model::HttpRequest::user_agent].
2004    pub fn set_user_agent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2005        self.user_agent = v.into();
2006        self
2007    }
2008
2009    /// Sets the value of [remote_ip][crate::model::HttpRequest::remote_ip].
2010    pub fn set_remote_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2011        self.remote_ip = v.into();
2012        self
2013    }
2014
2015    /// Sets the value of [server_ip][crate::model::HttpRequest::server_ip].
2016    pub fn set_server_ip<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2017        self.server_ip = v.into();
2018        self
2019    }
2020
2021    /// Sets the value of [referer][crate::model::HttpRequest::referer].
2022    pub fn set_referer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2023        self.referer = v.into();
2024        self
2025    }
2026
2027    /// Sets the value of [latency][crate::model::HttpRequest::latency].
2028    pub fn set_latency<T>(mut self, v: T) -> Self
2029    where
2030        T: std::convert::Into<wkt::Duration>,
2031    {
2032        self.latency = std::option::Option::Some(v.into());
2033        self
2034    }
2035
2036    /// Sets or clears the value of [latency][crate::model::HttpRequest::latency].
2037    pub fn set_or_clear_latency<T>(mut self, v: std::option::Option<T>) -> Self
2038    where
2039        T: std::convert::Into<wkt::Duration>,
2040    {
2041        self.latency = v.map(|x| x.into());
2042        self
2043    }
2044
2045    /// Sets the value of [cache_lookup][crate::model::HttpRequest::cache_lookup].
2046    pub fn set_cache_lookup<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2047        self.cache_lookup = v.into();
2048        self
2049    }
2050
2051    /// Sets the value of [cache_hit][crate::model::HttpRequest::cache_hit].
2052    pub fn set_cache_hit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2053        self.cache_hit = v.into();
2054        self
2055    }
2056
2057    /// Sets the value of [cache_validated_with_origin_server][crate::model::HttpRequest::cache_validated_with_origin_server].
2058    pub fn set_cache_validated_with_origin_server<T: std::convert::Into<bool>>(
2059        mut self,
2060        v: T,
2061    ) -> Self {
2062        self.cache_validated_with_origin_server = v.into();
2063        self
2064    }
2065
2066    /// Sets the value of [cache_fill_bytes][crate::model::HttpRequest::cache_fill_bytes].
2067    pub fn set_cache_fill_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
2068        self.cache_fill_bytes = v.into();
2069        self
2070    }
2071
2072    /// Sets the value of [protocol][crate::model::HttpRequest::protocol].
2073    pub fn set_protocol<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2074        self.protocol = v.into();
2075        self
2076    }
2077}
2078
2079impl wkt::message::Message for HttpRequest {
2080    fn typename() -> &'static str {
2081        "type.googleapis.com/google.api.servicecontrol.v1.HttpRequest"
2082    }
2083}
2084
2085#[doc(hidden)]
2086impl<'de> serde::de::Deserialize<'de> for HttpRequest {
2087    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2088    where
2089        D: serde::Deserializer<'de>,
2090    {
2091        #[allow(non_camel_case_types)]
2092        #[doc(hidden)]
2093        #[derive(PartialEq, Eq, Hash)]
2094        enum __FieldTag {
2095            __request_method,
2096            __request_url,
2097            __request_size,
2098            __status,
2099            __response_size,
2100            __user_agent,
2101            __remote_ip,
2102            __server_ip,
2103            __referer,
2104            __latency,
2105            __cache_lookup,
2106            __cache_hit,
2107            __cache_validated_with_origin_server,
2108            __cache_fill_bytes,
2109            __protocol,
2110            Unknown(std::string::String),
2111        }
2112        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2113            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2114            where
2115                D: serde::Deserializer<'de>,
2116            {
2117                struct Visitor;
2118                impl<'de> serde::de::Visitor<'de> for Visitor {
2119                    type Value = __FieldTag;
2120                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2121                        formatter.write_str("a field name for HttpRequest")
2122                    }
2123                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2124                    where
2125                        E: serde::de::Error,
2126                    {
2127                        use std::result::Result::Ok;
2128                        use std::string::ToString;
2129                        match value {
2130                            "requestMethod" => Ok(__FieldTag::__request_method),
2131                            "request_method" => Ok(__FieldTag::__request_method),
2132                            "requestUrl" => Ok(__FieldTag::__request_url),
2133                            "request_url" => Ok(__FieldTag::__request_url),
2134                            "requestSize" => Ok(__FieldTag::__request_size),
2135                            "request_size" => Ok(__FieldTag::__request_size),
2136                            "status" => Ok(__FieldTag::__status),
2137                            "responseSize" => Ok(__FieldTag::__response_size),
2138                            "response_size" => Ok(__FieldTag::__response_size),
2139                            "userAgent" => Ok(__FieldTag::__user_agent),
2140                            "user_agent" => Ok(__FieldTag::__user_agent),
2141                            "remoteIp" => Ok(__FieldTag::__remote_ip),
2142                            "remote_ip" => Ok(__FieldTag::__remote_ip),
2143                            "serverIp" => Ok(__FieldTag::__server_ip),
2144                            "server_ip" => Ok(__FieldTag::__server_ip),
2145                            "referer" => Ok(__FieldTag::__referer),
2146                            "latency" => Ok(__FieldTag::__latency),
2147                            "cacheLookup" => Ok(__FieldTag::__cache_lookup),
2148                            "cache_lookup" => Ok(__FieldTag::__cache_lookup),
2149                            "cacheHit" => Ok(__FieldTag::__cache_hit),
2150                            "cache_hit" => Ok(__FieldTag::__cache_hit),
2151                            "cacheValidatedWithOriginServer" => {
2152                                Ok(__FieldTag::__cache_validated_with_origin_server)
2153                            }
2154                            "cache_validated_with_origin_server" => {
2155                                Ok(__FieldTag::__cache_validated_with_origin_server)
2156                            }
2157                            "cacheFillBytes" => Ok(__FieldTag::__cache_fill_bytes),
2158                            "cache_fill_bytes" => Ok(__FieldTag::__cache_fill_bytes),
2159                            "protocol" => Ok(__FieldTag::__protocol),
2160                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2161                        }
2162                    }
2163                }
2164                deserializer.deserialize_identifier(Visitor)
2165            }
2166        }
2167        struct Visitor;
2168        impl<'de> serde::de::Visitor<'de> for Visitor {
2169            type Value = HttpRequest;
2170            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2171                formatter.write_str("struct HttpRequest")
2172            }
2173            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2174            where
2175                A: serde::de::MapAccess<'de>,
2176            {
2177                #[allow(unused_imports)]
2178                use serde::de::Error;
2179                use std::option::Option::Some;
2180                let mut fields = std::collections::HashSet::new();
2181                let mut result = Self::Value::new();
2182                while let Some(tag) = map.next_key::<__FieldTag>()? {
2183                    #[allow(clippy::match_single_binding)]
2184                    match tag {
2185                        __FieldTag::__request_method => {
2186                            if !fields.insert(__FieldTag::__request_method) {
2187                                return std::result::Result::Err(A::Error::duplicate_field(
2188                                    "multiple values for request_method",
2189                                ));
2190                            }
2191                            result.request_method = map
2192                                .next_value::<std::option::Option<std::string::String>>()?
2193                                .unwrap_or_default();
2194                        }
2195                        __FieldTag::__request_url => {
2196                            if !fields.insert(__FieldTag::__request_url) {
2197                                return std::result::Result::Err(A::Error::duplicate_field(
2198                                    "multiple values for request_url",
2199                                ));
2200                            }
2201                            result.request_url = map
2202                                .next_value::<std::option::Option<std::string::String>>()?
2203                                .unwrap_or_default();
2204                        }
2205                        __FieldTag::__request_size => {
2206                            if !fields.insert(__FieldTag::__request_size) {
2207                                return std::result::Result::Err(A::Error::duplicate_field(
2208                                    "multiple values for request_size",
2209                                ));
2210                            }
2211                            struct __With(std::option::Option<i64>);
2212                            impl<'de> serde::de::Deserialize<'de> for __With {
2213                                fn deserialize<D>(
2214                                    deserializer: D,
2215                                ) -> std::result::Result<Self, D::Error>
2216                                where
2217                                    D: serde::de::Deserializer<'de>,
2218                                {
2219                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2220                                }
2221                            }
2222                            result.request_size = map.next_value::<__With>()?.0.unwrap_or_default();
2223                        }
2224                        __FieldTag::__status => {
2225                            if !fields.insert(__FieldTag::__status) {
2226                                return std::result::Result::Err(A::Error::duplicate_field(
2227                                    "multiple values for status",
2228                                ));
2229                            }
2230                            struct __With(std::option::Option<i32>);
2231                            impl<'de> serde::de::Deserialize<'de> for __With {
2232                                fn deserialize<D>(
2233                                    deserializer: D,
2234                                ) -> std::result::Result<Self, D::Error>
2235                                where
2236                                    D: serde::de::Deserializer<'de>,
2237                                {
2238                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
2239                                }
2240                            }
2241                            result.status = map.next_value::<__With>()?.0.unwrap_or_default();
2242                        }
2243                        __FieldTag::__response_size => {
2244                            if !fields.insert(__FieldTag::__response_size) {
2245                                return std::result::Result::Err(A::Error::duplicate_field(
2246                                    "multiple values for response_size",
2247                                ));
2248                            }
2249                            struct __With(std::option::Option<i64>);
2250                            impl<'de> serde::de::Deserialize<'de> for __With {
2251                                fn deserialize<D>(
2252                                    deserializer: D,
2253                                ) -> std::result::Result<Self, D::Error>
2254                                where
2255                                    D: serde::de::Deserializer<'de>,
2256                                {
2257                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2258                                }
2259                            }
2260                            result.response_size =
2261                                map.next_value::<__With>()?.0.unwrap_or_default();
2262                        }
2263                        __FieldTag::__user_agent => {
2264                            if !fields.insert(__FieldTag::__user_agent) {
2265                                return std::result::Result::Err(A::Error::duplicate_field(
2266                                    "multiple values for user_agent",
2267                                ));
2268                            }
2269                            result.user_agent = map
2270                                .next_value::<std::option::Option<std::string::String>>()?
2271                                .unwrap_or_default();
2272                        }
2273                        __FieldTag::__remote_ip => {
2274                            if !fields.insert(__FieldTag::__remote_ip) {
2275                                return std::result::Result::Err(A::Error::duplicate_field(
2276                                    "multiple values for remote_ip",
2277                                ));
2278                            }
2279                            result.remote_ip = map
2280                                .next_value::<std::option::Option<std::string::String>>()?
2281                                .unwrap_or_default();
2282                        }
2283                        __FieldTag::__server_ip => {
2284                            if !fields.insert(__FieldTag::__server_ip) {
2285                                return std::result::Result::Err(A::Error::duplicate_field(
2286                                    "multiple values for server_ip",
2287                                ));
2288                            }
2289                            result.server_ip = map
2290                                .next_value::<std::option::Option<std::string::String>>()?
2291                                .unwrap_or_default();
2292                        }
2293                        __FieldTag::__referer => {
2294                            if !fields.insert(__FieldTag::__referer) {
2295                                return std::result::Result::Err(A::Error::duplicate_field(
2296                                    "multiple values for referer",
2297                                ));
2298                            }
2299                            result.referer = map
2300                                .next_value::<std::option::Option<std::string::String>>()?
2301                                .unwrap_or_default();
2302                        }
2303                        __FieldTag::__latency => {
2304                            if !fields.insert(__FieldTag::__latency) {
2305                                return std::result::Result::Err(A::Error::duplicate_field(
2306                                    "multiple values for latency",
2307                                ));
2308                            }
2309                            result.latency =
2310                                map.next_value::<std::option::Option<wkt::Duration>>()?;
2311                        }
2312                        __FieldTag::__cache_lookup => {
2313                            if !fields.insert(__FieldTag::__cache_lookup) {
2314                                return std::result::Result::Err(A::Error::duplicate_field(
2315                                    "multiple values for cache_lookup",
2316                                ));
2317                            }
2318                            result.cache_lookup = map
2319                                .next_value::<std::option::Option<bool>>()?
2320                                .unwrap_or_default();
2321                        }
2322                        __FieldTag::__cache_hit => {
2323                            if !fields.insert(__FieldTag::__cache_hit) {
2324                                return std::result::Result::Err(A::Error::duplicate_field(
2325                                    "multiple values for cache_hit",
2326                                ));
2327                            }
2328                            result.cache_hit = map
2329                                .next_value::<std::option::Option<bool>>()?
2330                                .unwrap_or_default();
2331                        }
2332                        __FieldTag::__cache_validated_with_origin_server => {
2333                            if !fields.insert(__FieldTag::__cache_validated_with_origin_server) {
2334                                return std::result::Result::Err(A::Error::duplicate_field(
2335                                    "multiple values for cache_validated_with_origin_server",
2336                                ));
2337                            }
2338                            result.cache_validated_with_origin_server = map
2339                                .next_value::<std::option::Option<bool>>()?
2340                                .unwrap_or_default();
2341                        }
2342                        __FieldTag::__cache_fill_bytes => {
2343                            if !fields.insert(__FieldTag::__cache_fill_bytes) {
2344                                return std::result::Result::Err(A::Error::duplicate_field(
2345                                    "multiple values for cache_fill_bytes",
2346                                ));
2347                            }
2348                            struct __With(std::option::Option<i64>);
2349                            impl<'de> serde::de::Deserialize<'de> for __With {
2350                                fn deserialize<D>(
2351                                    deserializer: D,
2352                                ) -> std::result::Result<Self, D::Error>
2353                                where
2354                                    D: serde::de::Deserializer<'de>,
2355                                {
2356                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
2357                                }
2358                            }
2359                            result.cache_fill_bytes =
2360                                map.next_value::<__With>()?.0.unwrap_or_default();
2361                        }
2362                        __FieldTag::__protocol => {
2363                            if !fields.insert(__FieldTag::__protocol) {
2364                                return std::result::Result::Err(A::Error::duplicate_field(
2365                                    "multiple values for protocol",
2366                                ));
2367                            }
2368                            result.protocol = map
2369                                .next_value::<std::option::Option<std::string::String>>()?
2370                                .unwrap_or_default();
2371                        }
2372                        __FieldTag::Unknown(key) => {
2373                            let value = map.next_value::<serde_json::Value>()?;
2374                            result._unknown_fields.insert(key, value);
2375                        }
2376                    }
2377                }
2378                std::result::Result::Ok(result)
2379            }
2380        }
2381        deserializer.deserialize_any(Visitor)
2382    }
2383}
2384
2385#[doc(hidden)]
2386impl serde::ser::Serialize for HttpRequest {
2387    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2388    where
2389        S: serde::ser::Serializer,
2390    {
2391        use serde::ser::SerializeMap;
2392        #[allow(unused_imports)]
2393        use std::option::Option::Some;
2394        let mut state = serializer.serialize_map(std::option::Option::None)?;
2395        if !self.request_method.is_empty() {
2396            state.serialize_entry("requestMethod", &self.request_method)?;
2397        }
2398        if !self.request_url.is_empty() {
2399            state.serialize_entry("requestUrl", &self.request_url)?;
2400        }
2401        if !wkt::internal::is_default(&self.request_size) {
2402            struct __With<'a>(&'a i64);
2403            impl<'a> serde::ser::Serialize for __With<'a> {
2404                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2405                where
2406                    S: serde::ser::Serializer,
2407                {
2408                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2409                }
2410            }
2411            state.serialize_entry("requestSize", &__With(&self.request_size))?;
2412        }
2413        if !wkt::internal::is_default(&self.status) {
2414            struct __With<'a>(&'a i32);
2415            impl<'a> serde::ser::Serialize for __With<'a> {
2416                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2417                where
2418                    S: serde::ser::Serializer,
2419                {
2420                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
2421                }
2422            }
2423            state.serialize_entry("status", &__With(&self.status))?;
2424        }
2425        if !wkt::internal::is_default(&self.response_size) {
2426            struct __With<'a>(&'a i64);
2427            impl<'a> serde::ser::Serialize for __With<'a> {
2428                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2429                where
2430                    S: serde::ser::Serializer,
2431                {
2432                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2433                }
2434            }
2435            state.serialize_entry("responseSize", &__With(&self.response_size))?;
2436        }
2437        if !self.user_agent.is_empty() {
2438            state.serialize_entry("userAgent", &self.user_agent)?;
2439        }
2440        if !self.remote_ip.is_empty() {
2441            state.serialize_entry("remoteIp", &self.remote_ip)?;
2442        }
2443        if !self.server_ip.is_empty() {
2444            state.serialize_entry("serverIp", &self.server_ip)?;
2445        }
2446        if !self.referer.is_empty() {
2447            state.serialize_entry("referer", &self.referer)?;
2448        }
2449        if self.latency.is_some() {
2450            state.serialize_entry("latency", &self.latency)?;
2451        }
2452        if !wkt::internal::is_default(&self.cache_lookup) {
2453            state.serialize_entry("cacheLookup", &self.cache_lookup)?;
2454        }
2455        if !wkt::internal::is_default(&self.cache_hit) {
2456            state.serialize_entry("cacheHit", &self.cache_hit)?;
2457        }
2458        if !wkt::internal::is_default(&self.cache_validated_with_origin_server) {
2459            state.serialize_entry(
2460                "cacheValidatedWithOriginServer",
2461                &self.cache_validated_with_origin_server,
2462            )?;
2463        }
2464        if !wkt::internal::is_default(&self.cache_fill_bytes) {
2465            struct __With<'a>(&'a i64);
2466            impl<'a> serde::ser::Serialize for __With<'a> {
2467                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2468                where
2469                    S: serde::ser::Serializer,
2470                {
2471                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
2472                }
2473            }
2474            state.serialize_entry("cacheFillBytes", &__With(&self.cache_fill_bytes))?;
2475        }
2476        if !self.protocol.is_empty() {
2477            state.serialize_entry("protocol", &self.protocol)?;
2478        }
2479        if !self._unknown_fields.is_empty() {
2480            for (key, value) in self._unknown_fields.iter() {
2481                state.serialize_entry(key, &value)?;
2482            }
2483        }
2484        state.end()
2485    }
2486}
2487
2488/// An individual log entry.
2489#[derive(Clone, Debug, Default, PartialEq)]
2490#[non_exhaustive]
2491pub struct LogEntry {
2492    /// Required. The log to which this log entry belongs. Examples: `"syslog"`,
2493    /// `"book_log"`.
2494    pub name: std::string::String,
2495
2496    /// The time the event described by the log entry occurred. If
2497    /// omitted, defaults to operation start time.
2498    pub timestamp: std::option::Option<wkt::Timestamp>,
2499
2500    /// The severity of the log entry. The default value is
2501    /// `LogSeverity.DEFAULT`.
2502    pub severity: logging_type::model::LogSeverity,
2503
2504    /// Optional. Information about the HTTP request associated with this
2505    /// log entry, if applicable.
2506    pub http_request: std::option::Option<crate::model::HttpRequest>,
2507
2508    /// Optional. Resource name of the trace associated with the log entry, if any.
2509    /// If this field contains a relative resource name, you can assume the name is
2510    /// relative to `//tracing.googleapis.com`. Example:
2511    /// `projects/my-projectid/traces/06796866738c859f2f19b7cfb3214824`
2512    pub trace: std::string::String,
2513
2514    /// A unique ID for the log entry used for deduplication. If omitted,
2515    /// the implementation will generate one based on operation_id.
2516    pub insert_id: std::string::String,
2517
2518    /// A set of user-defined (key, value) data that provides additional
2519    /// information about the log entry.
2520    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
2521
2522    /// Optional. Information about an operation associated with the log entry, if
2523    /// applicable.
2524    pub operation: std::option::Option<crate::model::LogEntryOperation>,
2525
2526    /// Optional. Source code location information associated with the log entry,
2527    /// if any.
2528    pub source_location: std::option::Option<crate::model::LogEntrySourceLocation>,
2529
2530    /// The log entry payload, which can be one of multiple types.
2531    pub payload: std::option::Option<crate::model::log_entry::Payload>,
2532
2533    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2534}
2535
2536impl LogEntry {
2537    pub fn new() -> Self {
2538        std::default::Default::default()
2539    }
2540
2541    /// Sets the value of [name][crate::model::LogEntry::name].
2542    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2543        self.name = v.into();
2544        self
2545    }
2546
2547    /// Sets the value of [timestamp][crate::model::LogEntry::timestamp].
2548    pub fn set_timestamp<T>(mut self, v: T) -> Self
2549    where
2550        T: std::convert::Into<wkt::Timestamp>,
2551    {
2552        self.timestamp = std::option::Option::Some(v.into());
2553        self
2554    }
2555
2556    /// Sets or clears the value of [timestamp][crate::model::LogEntry::timestamp].
2557    pub fn set_or_clear_timestamp<T>(mut self, v: std::option::Option<T>) -> Self
2558    where
2559        T: std::convert::Into<wkt::Timestamp>,
2560    {
2561        self.timestamp = v.map(|x| x.into());
2562        self
2563    }
2564
2565    /// Sets the value of [severity][crate::model::LogEntry::severity].
2566    pub fn set_severity<T: std::convert::Into<logging_type::model::LogSeverity>>(
2567        mut self,
2568        v: T,
2569    ) -> Self {
2570        self.severity = v.into();
2571        self
2572    }
2573
2574    /// Sets the value of [http_request][crate::model::LogEntry::http_request].
2575    pub fn set_http_request<T>(mut self, v: T) -> Self
2576    where
2577        T: std::convert::Into<crate::model::HttpRequest>,
2578    {
2579        self.http_request = std::option::Option::Some(v.into());
2580        self
2581    }
2582
2583    /// Sets or clears the value of [http_request][crate::model::LogEntry::http_request].
2584    pub fn set_or_clear_http_request<T>(mut self, v: std::option::Option<T>) -> Self
2585    where
2586        T: std::convert::Into<crate::model::HttpRequest>,
2587    {
2588        self.http_request = v.map(|x| x.into());
2589        self
2590    }
2591
2592    /// Sets the value of [trace][crate::model::LogEntry::trace].
2593    pub fn set_trace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2594        self.trace = v.into();
2595        self
2596    }
2597
2598    /// Sets the value of [insert_id][crate::model::LogEntry::insert_id].
2599    pub fn set_insert_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2600        self.insert_id = v.into();
2601        self
2602    }
2603
2604    /// Sets the value of [labels][crate::model::LogEntry::labels].
2605    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
2606    where
2607        T: std::iter::IntoIterator<Item = (K, V)>,
2608        K: std::convert::Into<std::string::String>,
2609        V: std::convert::Into<std::string::String>,
2610    {
2611        use std::iter::Iterator;
2612        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2613        self
2614    }
2615
2616    /// Sets the value of [operation][crate::model::LogEntry::operation].
2617    pub fn set_operation<T>(mut self, v: T) -> Self
2618    where
2619        T: std::convert::Into<crate::model::LogEntryOperation>,
2620    {
2621        self.operation = std::option::Option::Some(v.into());
2622        self
2623    }
2624
2625    /// Sets or clears the value of [operation][crate::model::LogEntry::operation].
2626    pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
2627    where
2628        T: std::convert::Into<crate::model::LogEntryOperation>,
2629    {
2630        self.operation = v.map(|x| x.into());
2631        self
2632    }
2633
2634    /// Sets the value of [source_location][crate::model::LogEntry::source_location].
2635    pub fn set_source_location<T>(mut self, v: T) -> Self
2636    where
2637        T: std::convert::Into<crate::model::LogEntrySourceLocation>,
2638    {
2639        self.source_location = std::option::Option::Some(v.into());
2640        self
2641    }
2642
2643    /// Sets or clears the value of [source_location][crate::model::LogEntry::source_location].
2644    pub fn set_or_clear_source_location<T>(mut self, v: std::option::Option<T>) -> Self
2645    where
2646        T: std::convert::Into<crate::model::LogEntrySourceLocation>,
2647    {
2648        self.source_location = v.map(|x| x.into());
2649        self
2650    }
2651
2652    /// Sets the value of [payload][crate::model::LogEntry::payload].
2653    ///
2654    /// Note that all the setters affecting `payload` are mutually
2655    /// exclusive.
2656    pub fn set_payload<
2657        T: std::convert::Into<std::option::Option<crate::model::log_entry::Payload>>,
2658    >(
2659        mut self,
2660        v: T,
2661    ) -> Self {
2662        self.payload = v.into();
2663        self
2664    }
2665
2666    /// The value of [payload][crate::model::LogEntry::payload]
2667    /// if it holds a `ProtoPayload`, `None` if the field is not set or
2668    /// holds a different branch.
2669    pub fn proto_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Any>> {
2670        #[allow(unreachable_patterns)]
2671        self.payload.as_ref().and_then(|v| match v {
2672            crate::model::log_entry::Payload::ProtoPayload(v) => std::option::Option::Some(v),
2673            _ => std::option::Option::None,
2674        })
2675    }
2676
2677    /// Sets the value of [payload][crate::model::LogEntry::payload]
2678    /// to hold a `ProtoPayload`.
2679    ///
2680    /// Note that all the setters affecting `payload` are
2681    /// mutually exclusive.
2682    pub fn set_proto_payload<T: std::convert::Into<std::boxed::Box<wkt::Any>>>(
2683        mut self,
2684        v: T,
2685    ) -> Self {
2686        self.payload =
2687            std::option::Option::Some(crate::model::log_entry::Payload::ProtoPayload(v.into()));
2688        self
2689    }
2690
2691    /// The value of [payload][crate::model::LogEntry::payload]
2692    /// if it holds a `TextPayload`, `None` if the field is not set or
2693    /// holds a different branch.
2694    pub fn text_payload(&self) -> std::option::Option<&std::string::String> {
2695        #[allow(unreachable_patterns)]
2696        self.payload.as_ref().and_then(|v| match v {
2697            crate::model::log_entry::Payload::TextPayload(v) => std::option::Option::Some(v),
2698            _ => std::option::Option::None,
2699        })
2700    }
2701
2702    /// Sets the value of [payload][crate::model::LogEntry::payload]
2703    /// to hold a `TextPayload`.
2704    ///
2705    /// Note that all the setters affecting `payload` are
2706    /// mutually exclusive.
2707    pub fn set_text_payload<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2708        self.payload =
2709            std::option::Option::Some(crate::model::log_entry::Payload::TextPayload(v.into()));
2710        self
2711    }
2712
2713    /// The value of [payload][crate::model::LogEntry::payload]
2714    /// if it holds a `StructPayload`, `None` if the field is not set or
2715    /// holds a different branch.
2716    pub fn struct_payload(&self) -> std::option::Option<&std::boxed::Box<wkt::Struct>> {
2717        #[allow(unreachable_patterns)]
2718        self.payload.as_ref().and_then(|v| match v {
2719            crate::model::log_entry::Payload::StructPayload(v) => std::option::Option::Some(v),
2720            _ => std::option::Option::None,
2721        })
2722    }
2723
2724    /// Sets the value of [payload][crate::model::LogEntry::payload]
2725    /// to hold a `StructPayload`.
2726    ///
2727    /// Note that all the setters affecting `payload` are
2728    /// mutually exclusive.
2729    pub fn set_struct_payload<T: std::convert::Into<std::boxed::Box<wkt::Struct>>>(
2730        mut self,
2731        v: T,
2732    ) -> Self {
2733        self.payload =
2734            std::option::Option::Some(crate::model::log_entry::Payload::StructPayload(v.into()));
2735        self
2736    }
2737}
2738
2739impl wkt::message::Message for LogEntry {
2740    fn typename() -> &'static str {
2741        "type.googleapis.com/google.api.servicecontrol.v1.LogEntry"
2742    }
2743}
2744
2745#[doc(hidden)]
2746impl<'de> serde::de::Deserialize<'de> for LogEntry {
2747    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2748    where
2749        D: serde::Deserializer<'de>,
2750    {
2751        #[allow(non_camel_case_types)]
2752        #[doc(hidden)]
2753        #[derive(PartialEq, Eq, Hash)]
2754        enum __FieldTag {
2755            __name,
2756            __timestamp,
2757            __severity,
2758            __http_request,
2759            __trace,
2760            __insert_id,
2761            __labels,
2762            __proto_payload,
2763            __text_payload,
2764            __struct_payload,
2765            __operation,
2766            __source_location,
2767            Unknown(std::string::String),
2768        }
2769        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2770            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2771            where
2772                D: serde::Deserializer<'de>,
2773            {
2774                struct Visitor;
2775                impl<'de> serde::de::Visitor<'de> for Visitor {
2776                    type Value = __FieldTag;
2777                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2778                        formatter.write_str("a field name for LogEntry")
2779                    }
2780                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2781                    where
2782                        E: serde::de::Error,
2783                    {
2784                        use std::result::Result::Ok;
2785                        use std::string::ToString;
2786                        match value {
2787                            "name" => Ok(__FieldTag::__name),
2788                            "timestamp" => Ok(__FieldTag::__timestamp),
2789                            "severity" => Ok(__FieldTag::__severity),
2790                            "httpRequest" => Ok(__FieldTag::__http_request),
2791                            "http_request" => Ok(__FieldTag::__http_request),
2792                            "trace" => Ok(__FieldTag::__trace),
2793                            "insertId" => Ok(__FieldTag::__insert_id),
2794                            "insert_id" => Ok(__FieldTag::__insert_id),
2795                            "labels" => Ok(__FieldTag::__labels),
2796                            "protoPayload" => Ok(__FieldTag::__proto_payload),
2797                            "proto_payload" => Ok(__FieldTag::__proto_payload),
2798                            "textPayload" => Ok(__FieldTag::__text_payload),
2799                            "text_payload" => Ok(__FieldTag::__text_payload),
2800                            "structPayload" => Ok(__FieldTag::__struct_payload),
2801                            "struct_payload" => Ok(__FieldTag::__struct_payload),
2802                            "operation" => Ok(__FieldTag::__operation),
2803                            "sourceLocation" => Ok(__FieldTag::__source_location),
2804                            "source_location" => Ok(__FieldTag::__source_location),
2805                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2806                        }
2807                    }
2808                }
2809                deserializer.deserialize_identifier(Visitor)
2810            }
2811        }
2812        struct Visitor;
2813        impl<'de> serde::de::Visitor<'de> for Visitor {
2814            type Value = LogEntry;
2815            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2816                formatter.write_str("struct LogEntry")
2817            }
2818            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2819            where
2820                A: serde::de::MapAccess<'de>,
2821            {
2822                #[allow(unused_imports)]
2823                use serde::de::Error;
2824                use std::option::Option::Some;
2825                let mut fields = std::collections::HashSet::new();
2826                let mut result = Self::Value::new();
2827                while let Some(tag) = map.next_key::<__FieldTag>()? {
2828                    #[allow(clippy::match_single_binding)]
2829                    match tag {
2830                        __FieldTag::__name => {
2831                            if !fields.insert(__FieldTag::__name) {
2832                                return std::result::Result::Err(A::Error::duplicate_field(
2833                                    "multiple values for name",
2834                                ));
2835                            }
2836                            result.name = map
2837                                .next_value::<std::option::Option<std::string::String>>()?
2838                                .unwrap_or_default();
2839                        }
2840                        __FieldTag::__timestamp => {
2841                            if !fields.insert(__FieldTag::__timestamp) {
2842                                return std::result::Result::Err(A::Error::duplicate_field(
2843                                    "multiple values for timestamp",
2844                                ));
2845                            }
2846                            result.timestamp =
2847                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
2848                        }
2849                        __FieldTag::__severity => {
2850                            if !fields.insert(__FieldTag::__severity) {
2851                                return std::result::Result::Err(A::Error::duplicate_field(
2852                                    "multiple values for severity",
2853                                ));
2854                            }
2855                            result.severity = map.next_value::<std::option::Option<logging_type::model::LogSeverity>>()?.unwrap_or_default();
2856                        }
2857                        __FieldTag::__http_request => {
2858                            if !fields.insert(__FieldTag::__http_request) {
2859                                return std::result::Result::Err(A::Error::duplicate_field(
2860                                    "multiple values for http_request",
2861                                ));
2862                            }
2863                            result.http_request =
2864                                map.next_value::<std::option::Option<crate::model::HttpRequest>>()?;
2865                        }
2866                        __FieldTag::__trace => {
2867                            if !fields.insert(__FieldTag::__trace) {
2868                                return std::result::Result::Err(A::Error::duplicate_field(
2869                                    "multiple values for trace",
2870                                ));
2871                            }
2872                            result.trace = map
2873                                .next_value::<std::option::Option<std::string::String>>()?
2874                                .unwrap_or_default();
2875                        }
2876                        __FieldTag::__insert_id => {
2877                            if !fields.insert(__FieldTag::__insert_id) {
2878                                return std::result::Result::Err(A::Error::duplicate_field(
2879                                    "multiple values for insert_id",
2880                                ));
2881                            }
2882                            result.insert_id = map
2883                                .next_value::<std::option::Option<std::string::String>>()?
2884                                .unwrap_or_default();
2885                        }
2886                        __FieldTag::__labels => {
2887                            if !fields.insert(__FieldTag::__labels) {
2888                                return std::result::Result::Err(A::Error::duplicate_field(
2889                                    "multiple values for labels",
2890                                ));
2891                            }
2892                            result.labels = map
2893                                .next_value::<std::option::Option<
2894                                    std::collections::HashMap<
2895                                        std::string::String,
2896                                        std::string::String,
2897                                    >,
2898                                >>()?
2899                                .unwrap_or_default();
2900                        }
2901                        __FieldTag::__proto_payload => {
2902                            if !fields.insert(__FieldTag::__proto_payload) {
2903                                return std::result::Result::Err(A::Error::duplicate_field(
2904                                    "multiple values for proto_payload",
2905                                ));
2906                            }
2907                            if result.payload.is_some() {
2908                                return std::result::Result::Err(A::Error::duplicate_field(
2909                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.proto_payload, latest field was protoPayload",
2910                                ));
2911                            }
2912                            result.payload = std::option::Option::Some(
2913                                crate::model::log_entry::Payload::ProtoPayload(
2914                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Any>>>()?.unwrap_or_default()
2915                                ),
2916                            );
2917                        }
2918                        __FieldTag::__text_payload => {
2919                            if !fields.insert(__FieldTag::__text_payload) {
2920                                return std::result::Result::Err(A::Error::duplicate_field(
2921                                    "multiple values for text_payload",
2922                                ));
2923                            }
2924                            if result.payload.is_some() {
2925                                return std::result::Result::Err(A::Error::duplicate_field(
2926                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.text_payload, latest field was textPayload",
2927                                ));
2928                            }
2929                            result.payload = std::option::Option::Some(
2930                                crate::model::log_entry::Payload::TextPayload(
2931                                    map.next_value::<std::option::Option<std::string::String>>()?
2932                                        .unwrap_or_default(),
2933                                ),
2934                            );
2935                        }
2936                        __FieldTag::__struct_payload => {
2937                            if !fields.insert(__FieldTag::__struct_payload) {
2938                                return std::result::Result::Err(A::Error::duplicate_field(
2939                                    "multiple values for struct_payload",
2940                                ));
2941                            }
2942                            if result.payload.is_some() {
2943                                return std::result::Result::Err(A::Error::duplicate_field(
2944                                    "multiple values for `payload`, a oneof with full ID .google.api.servicecontrol.v1.LogEntry.struct_payload, latest field was structPayload",
2945                                ));
2946                            }
2947                            result.payload = std::option::Option::Some(
2948                                crate::model::log_entry::Payload::StructPayload(
2949                                    map.next_value::<std::option::Option<std::boxed::Box<wkt::Struct>>>()?.unwrap_or_default()
2950                                ),
2951                            );
2952                        }
2953                        __FieldTag::__operation => {
2954                            if !fields.insert(__FieldTag::__operation) {
2955                                return std::result::Result::Err(A::Error::duplicate_field(
2956                                    "multiple values for operation",
2957                                ));
2958                            }
2959                            result.operation = map
2960                                .next_value::<std::option::Option<crate::model::LogEntryOperation>>(
2961                                )?;
2962                        }
2963                        __FieldTag::__source_location => {
2964                            if !fields.insert(__FieldTag::__source_location) {
2965                                return std::result::Result::Err(A::Error::duplicate_field(
2966                                    "multiple values for source_location",
2967                                ));
2968                            }
2969                            result.source_location = map.next_value::<std::option::Option<crate::model::LogEntrySourceLocation>>()?
2970                                ;
2971                        }
2972                        __FieldTag::Unknown(key) => {
2973                            let value = map.next_value::<serde_json::Value>()?;
2974                            result._unknown_fields.insert(key, value);
2975                        }
2976                    }
2977                }
2978                std::result::Result::Ok(result)
2979            }
2980        }
2981        deserializer.deserialize_any(Visitor)
2982    }
2983}
2984
2985#[doc(hidden)]
2986impl serde::ser::Serialize for LogEntry {
2987    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2988    where
2989        S: serde::ser::Serializer,
2990    {
2991        use serde::ser::SerializeMap;
2992        #[allow(unused_imports)]
2993        use std::option::Option::Some;
2994        let mut state = serializer.serialize_map(std::option::Option::None)?;
2995        if !self.name.is_empty() {
2996            state.serialize_entry("name", &self.name)?;
2997        }
2998        if self.timestamp.is_some() {
2999            state.serialize_entry("timestamp", &self.timestamp)?;
3000        }
3001        if !wkt::internal::is_default(&self.severity) {
3002            state.serialize_entry("severity", &self.severity)?;
3003        }
3004        if self.http_request.is_some() {
3005            state.serialize_entry("httpRequest", &self.http_request)?;
3006        }
3007        if !self.trace.is_empty() {
3008            state.serialize_entry("trace", &self.trace)?;
3009        }
3010        if !self.insert_id.is_empty() {
3011            state.serialize_entry("insertId", &self.insert_id)?;
3012        }
3013        if !self.labels.is_empty() {
3014            state.serialize_entry("labels", &self.labels)?;
3015        }
3016        if let Some(value) = self.proto_payload() {
3017            state.serialize_entry("protoPayload", value)?;
3018        }
3019        if let Some(value) = self.text_payload() {
3020            state.serialize_entry("textPayload", value)?;
3021        }
3022        if let Some(value) = self.struct_payload() {
3023            state.serialize_entry("structPayload", value)?;
3024        }
3025        if self.operation.is_some() {
3026            state.serialize_entry("operation", &self.operation)?;
3027        }
3028        if self.source_location.is_some() {
3029            state.serialize_entry("sourceLocation", &self.source_location)?;
3030        }
3031        if !self._unknown_fields.is_empty() {
3032            for (key, value) in self._unknown_fields.iter() {
3033                state.serialize_entry(key, &value)?;
3034            }
3035        }
3036        state.end()
3037    }
3038}
3039
3040/// Defines additional types related to [LogEntry].
3041pub mod log_entry {
3042    #[allow(unused_imports)]
3043    use super::*;
3044
3045    /// The log entry payload, which can be one of multiple types.
3046    #[derive(Clone, Debug, PartialEq)]
3047    #[non_exhaustive]
3048    pub enum Payload {
3049        /// The log entry payload, represented as a protocol buffer that is
3050        /// expressed as a JSON object. The only accepted type currently is
3051        /// [AuditLog][google.cloud.audit.AuditLog].
3052        ProtoPayload(std::boxed::Box<wkt::Any>),
3053        /// The log entry payload, represented as a Unicode string (UTF-8).
3054        TextPayload(std::string::String),
3055        /// The log entry payload, represented as a structure that
3056        /// is expressed as a JSON object.
3057        StructPayload(std::boxed::Box<wkt::Struct>),
3058    }
3059}
3060
3061/// Additional information about a potentially long-running operation with which
3062/// a log entry is associated.
3063#[derive(Clone, Debug, Default, PartialEq)]
3064#[non_exhaustive]
3065pub struct LogEntryOperation {
3066    /// Optional. An arbitrary operation identifier. Log entries with the
3067    /// same identifier are assumed to be part of the same operation.
3068    pub id: std::string::String,
3069
3070    /// Optional. An arbitrary producer identifier. The combination of
3071    /// `id` and `producer` must be globally unique.  Examples for `producer`:
3072    /// `"MyDivision.MyBigCompany.com"`, `"github.com/MyProject/MyApplication"`.
3073    pub producer: std::string::String,
3074
3075    /// Optional. Set this to True if this is the first log entry in the operation.
3076    pub first: bool,
3077
3078    /// Optional. Set this to True if this is the last log entry in the operation.
3079    pub last: bool,
3080
3081    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3082}
3083
3084impl LogEntryOperation {
3085    pub fn new() -> Self {
3086        std::default::Default::default()
3087    }
3088
3089    /// Sets the value of [id][crate::model::LogEntryOperation::id].
3090    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3091        self.id = v.into();
3092        self
3093    }
3094
3095    /// Sets the value of [producer][crate::model::LogEntryOperation::producer].
3096    pub fn set_producer<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3097        self.producer = v.into();
3098        self
3099    }
3100
3101    /// Sets the value of [first][crate::model::LogEntryOperation::first].
3102    pub fn set_first<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3103        self.first = v.into();
3104        self
3105    }
3106
3107    /// Sets the value of [last][crate::model::LogEntryOperation::last].
3108    pub fn set_last<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3109        self.last = v.into();
3110        self
3111    }
3112}
3113
3114impl wkt::message::Message for LogEntryOperation {
3115    fn typename() -> &'static str {
3116        "type.googleapis.com/google.api.servicecontrol.v1.LogEntryOperation"
3117    }
3118}
3119
3120#[doc(hidden)]
3121impl<'de> serde::de::Deserialize<'de> for LogEntryOperation {
3122    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3123    where
3124        D: serde::Deserializer<'de>,
3125    {
3126        #[allow(non_camel_case_types)]
3127        #[doc(hidden)]
3128        #[derive(PartialEq, Eq, Hash)]
3129        enum __FieldTag {
3130            __id,
3131            __producer,
3132            __first,
3133            __last,
3134            Unknown(std::string::String),
3135        }
3136        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3137            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3138            where
3139                D: serde::Deserializer<'de>,
3140            {
3141                struct Visitor;
3142                impl<'de> serde::de::Visitor<'de> for Visitor {
3143                    type Value = __FieldTag;
3144                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3145                        formatter.write_str("a field name for LogEntryOperation")
3146                    }
3147                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3148                    where
3149                        E: serde::de::Error,
3150                    {
3151                        use std::result::Result::Ok;
3152                        use std::string::ToString;
3153                        match value {
3154                            "id" => Ok(__FieldTag::__id),
3155                            "producer" => Ok(__FieldTag::__producer),
3156                            "first" => Ok(__FieldTag::__first),
3157                            "last" => Ok(__FieldTag::__last),
3158                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3159                        }
3160                    }
3161                }
3162                deserializer.deserialize_identifier(Visitor)
3163            }
3164        }
3165        struct Visitor;
3166        impl<'de> serde::de::Visitor<'de> for Visitor {
3167            type Value = LogEntryOperation;
3168            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3169                formatter.write_str("struct LogEntryOperation")
3170            }
3171            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3172            where
3173                A: serde::de::MapAccess<'de>,
3174            {
3175                #[allow(unused_imports)]
3176                use serde::de::Error;
3177                use std::option::Option::Some;
3178                let mut fields = std::collections::HashSet::new();
3179                let mut result = Self::Value::new();
3180                while let Some(tag) = map.next_key::<__FieldTag>()? {
3181                    #[allow(clippy::match_single_binding)]
3182                    match tag {
3183                        __FieldTag::__id => {
3184                            if !fields.insert(__FieldTag::__id) {
3185                                return std::result::Result::Err(A::Error::duplicate_field(
3186                                    "multiple values for id",
3187                                ));
3188                            }
3189                            result.id = map
3190                                .next_value::<std::option::Option<std::string::String>>()?
3191                                .unwrap_or_default();
3192                        }
3193                        __FieldTag::__producer => {
3194                            if !fields.insert(__FieldTag::__producer) {
3195                                return std::result::Result::Err(A::Error::duplicate_field(
3196                                    "multiple values for producer",
3197                                ));
3198                            }
3199                            result.producer = map
3200                                .next_value::<std::option::Option<std::string::String>>()?
3201                                .unwrap_or_default();
3202                        }
3203                        __FieldTag::__first => {
3204                            if !fields.insert(__FieldTag::__first) {
3205                                return std::result::Result::Err(A::Error::duplicate_field(
3206                                    "multiple values for first",
3207                                ));
3208                            }
3209                            result.first = map
3210                                .next_value::<std::option::Option<bool>>()?
3211                                .unwrap_or_default();
3212                        }
3213                        __FieldTag::__last => {
3214                            if !fields.insert(__FieldTag::__last) {
3215                                return std::result::Result::Err(A::Error::duplicate_field(
3216                                    "multiple values for last",
3217                                ));
3218                            }
3219                            result.last = map
3220                                .next_value::<std::option::Option<bool>>()?
3221                                .unwrap_or_default();
3222                        }
3223                        __FieldTag::Unknown(key) => {
3224                            let value = map.next_value::<serde_json::Value>()?;
3225                            result._unknown_fields.insert(key, value);
3226                        }
3227                    }
3228                }
3229                std::result::Result::Ok(result)
3230            }
3231        }
3232        deserializer.deserialize_any(Visitor)
3233    }
3234}
3235
3236#[doc(hidden)]
3237impl serde::ser::Serialize for LogEntryOperation {
3238    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3239    where
3240        S: serde::ser::Serializer,
3241    {
3242        use serde::ser::SerializeMap;
3243        #[allow(unused_imports)]
3244        use std::option::Option::Some;
3245        let mut state = serializer.serialize_map(std::option::Option::None)?;
3246        if !self.id.is_empty() {
3247            state.serialize_entry("id", &self.id)?;
3248        }
3249        if !self.producer.is_empty() {
3250            state.serialize_entry("producer", &self.producer)?;
3251        }
3252        if !wkt::internal::is_default(&self.first) {
3253            state.serialize_entry("first", &self.first)?;
3254        }
3255        if !wkt::internal::is_default(&self.last) {
3256            state.serialize_entry("last", &self.last)?;
3257        }
3258        if !self._unknown_fields.is_empty() {
3259            for (key, value) in self._unknown_fields.iter() {
3260                state.serialize_entry(key, &value)?;
3261            }
3262        }
3263        state.end()
3264    }
3265}
3266
3267/// Additional information about the source code location that produced the log
3268/// entry.
3269#[derive(Clone, Debug, Default, PartialEq)]
3270#[non_exhaustive]
3271pub struct LogEntrySourceLocation {
3272    /// Optional. Source file name. Depending on the runtime environment, this
3273    /// might be a simple name or a fully-qualified name.
3274    pub file: std::string::String,
3275
3276    /// Optional. Line within the source file. 1-based; 0 indicates no line number
3277    /// available.
3278    pub line: i64,
3279
3280    /// Optional. Human-readable name of the function or method being invoked, with
3281    /// optional context such as the class or package name. This information may be
3282    /// used in contexts such as the logs viewer, where a file and line number are
3283    /// less meaningful. The format can vary by language. For example:
3284    /// `qual.if.ied.Class.method` (Java), `dir/package.func` (Go), `function`
3285    /// (Python).
3286    pub function: std::string::String,
3287
3288    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3289}
3290
3291impl LogEntrySourceLocation {
3292    pub fn new() -> Self {
3293        std::default::Default::default()
3294    }
3295
3296    /// Sets the value of [file][crate::model::LogEntrySourceLocation::file].
3297    pub fn set_file<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3298        self.file = v.into();
3299        self
3300    }
3301
3302    /// Sets the value of [line][crate::model::LogEntrySourceLocation::line].
3303    pub fn set_line<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3304        self.line = v.into();
3305        self
3306    }
3307
3308    /// Sets the value of [function][crate::model::LogEntrySourceLocation::function].
3309    pub fn set_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3310        self.function = v.into();
3311        self
3312    }
3313}
3314
3315impl wkt::message::Message for LogEntrySourceLocation {
3316    fn typename() -> &'static str {
3317        "type.googleapis.com/google.api.servicecontrol.v1.LogEntrySourceLocation"
3318    }
3319}
3320
3321#[doc(hidden)]
3322impl<'de> serde::de::Deserialize<'de> for LogEntrySourceLocation {
3323    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3324    where
3325        D: serde::Deserializer<'de>,
3326    {
3327        #[allow(non_camel_case_types)]
3328        #[doc(hidden)]
3329        #[derive(PartialEq, Eq, Hash)]
3330        enum __FieldTag {
3331            __file,
3332            __line,
3333            __function,
3334            Unknown(std::string::String),
3335        }
3336        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3337            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3338            where
3339                D: serde::Deserializer<'de>,
3340            {
3341                struct Visitor;
3342                impl<'de> serde::de::Visitor<'de> for Visitor {
3343                    type Value = __FieldTag;
3344                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3345                        formatter.write_str("a field name for LogEntrySourceLocation")
3346                    }
3347                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3348                    where
3349                        E: serde::de::Error,
3350                    {
3351                        use std::result::Result::Ok;
3352                        use std::string::ToString;
3353                        match value {
3354                            "file" => Ok(__FieldTag::__file),
3355                            "line" => Ok(__FieldTag::__line),
3356                            "function" => Ok(__FieldTag::__function),
3357                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3358                        }
3359                    }
3360                }
3361                deserializer.deserialize_identifier(Visitor)
3362            }
3363        }
3364        struct Visitor;
3365        impl<'de> serde::de::Visitor<'de> for Visitor {
3366            type Value = LogEntrySourceLocation;
3367            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3368                formatter.write_str("struct LogEntrySourceLocation")
3369            }
3370            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3371            where
3372                A: serde::de::MapAccess<'de>,
3373            {
3374                #[allow(unused_imports)]
3375                use serde::de::Error;
3376                use std::option::Option::Some;
3377                let mut fields = std::collections::HashSet::new();
3378                let mut result = Self::Value::new();
3379                while let Some(tag) = map.next_key::<__FieldTag>()? {
3380                    #[allow(clippy::match_single_binding)]
3381                    match tag {
3382                        __FieldTag::__file => {
3383                            if !fields.insert(__FieldTag::__file) {
3384                                return std::result::Result::Err(A::Error::duplicate_field(
3385                                    "multiple values for file",
3386                                ));
3387                            }
3388                            result.file = map
3389                                .next_value::<std::option::Option<std::string::String>>()?
3390                                .unwrap_or_default();
3391                        }
3392                        __FieldTag::__line => {
3393                            if !fields.insert(__FieldTag::__line) {
3394                                return std::result::Result::Err(A::Error::duplicate_field(
3395                                    "multiple values for line",
3396                                ));
3397                            }
3398                            struct __With(std::option::Option<i64>);
3399                            impl<'de> serde::de::Deserialize<'de> for __With {
3400                                fn deserialize<D>(
3401                                    deserializer: D,
3402                                ) -> std::result::Result<Self, D::Error>
3403                                where
3404                                    D: serde::de::Deserializer<'de>,
3405                                {
3406                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
3407                                }
3408                            }
3409                            result.line = map.next_value::<__With>()?.0.unwrap_or_default();
3410                        }
3411                        __FieldTag::__function => {
3412                            if !fields.insert(__FieldTag::__function) {
3413                                return std::result::Result::Err(A::Error::duplicate_field(
3414                                    "multiple values for function",
3415                                ));
3416                            }
3417                            result.function = map
3418                                .next_value::<std::option::Option<std::string::String>>()?
3419                                .unwrap_or_default();
3420                        }
3421                        __FieldTag::Unknown(key) => {
3422                            let value = map.next_value::<serde_json::Value>()?;
3423                            result._unknown_fields.insert(key, value);
3424                        }
3425                    }
3426                }
3427                std::result::Result::Ok(result)
3428            }
3429        }
3430        deserializer.deserialize_any(Visitor)
3431    }
3432}
3433
3434#[doc(hidden)]
3435impl serde::ser::Serialize for LogEntrySourceLocation {
3436    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3437    where
3438        S: serde::ser::Serializer,
3439    {
3440        use serde::ser::SerializeMap;
3441        #[allow(unused_imports)]
3442        use std::option::Option::Some;
3443        let mut state = serializer.serialize_map(std::option::Option::None)?;
3444        if !self.file.is_empty() {
3445            state.serialize_entry("file", &self.file)?;
3446        }
3447        if !wkt::internal::is_default(&self.line) {
3448            struct __With<'a>(&'a i64);
3449            impl<'a> serde::ser::Serialize for __With<'a> {
3450                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3451                where
3452                    S: serde::ser::Serializer,
3453                {
3454                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
3455                }
3456            }
3457            state.serialize_entry("line", &__With(&self.line))?;
3458        }
3459        if !self.function.is_empty() {
3460            state.serialize_entry("function", &self.function)?;
3461        }
3462        if !self._unknown_fields.is_empty() {
3463            for (key, value) in self._unknown_fields.iter() {
3464                state.serialize_entry(key, &value)?;
3465            }
3466        }
3467        state.end()
3468    }
3469}
3470
3471/// Represents a single metric value.
3472#[derive(Clone, Debug, Default, PartialEq)]
3473#[non_exhaustive]
3474pub struct MetricValue {
3475    /// The labels describing the metric value.
3476    /// See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for
3477    /// the overriding relationship.
3478    /// Note that this map must not contain monitored resource labels.
3479    ///
3480    /// [google.api.servicecontrol.v1.Operation.labels]: crate::model::Operation::labels
3481    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
3482
3483    /// The start of the time period over which this metric value's measurement
3484    /// applies. The time period has different semantics for different metric
3485    /// types (cumulative, delta, and gauge). See the metric definition
3486    /// documentation in the service configuration for details. If not specified,
3487    /// [google.api.servicecontrol.v1.Operation.start_time][google.api.servicecontrol.v1.Operation.start_time] will be used.
3488    ///
3489    /// [google.api.servicecontrol.v1.Operation.start_time]: crate::model::Operation::start_time
3490    pub start_time: std::option::Option<wkt::Timestamp>,
3491
3492    /// The end of the time period over which this metric value's measurement
3493    /// applies.  If not specified,
3494    /// [google.api.servicecontrol.v1.Operation.end_time][google.api.servicecontrol.v1.Operation.end_time] will be used.
3495    ///
3496    /// [google.api.servicecontrol.v1.Operation.end_time]: crate::model::Operation::end_time
3497    pub end_time: std::option::Option<wkt::Timestamp>,
3498
3499    /// The value. The type of value used in the request must
3500    /// agree with the metric definition in the service configuration, otherwise
3501    /// the MetricValue is rejected.
3502    pub value: std::option::Option<crate::model::metric_value::Value>,
3503
3504    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3505}
3506
3507impl MetricValue {
3508    pub fn new() -> Self {
3509        std::default::Default::default()
3510    }
3511
3512    /// Sets the value of [labels][crate::model::MetricValue::labels].
3513    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
3514    where
3515        T: std::iter::IntoIterator<Item = (K, V)>,
3516        K: std::convert::Into<std::string::String>,
3517        V: std::convert::Into<std::string::String>,
3518    {
3519        use std::iter::Iterator;
3520        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3521        self
3522    }
3523
3524    /// Sets the value of [start_time][crate::model::MetricValue::start_time].
3525    pub fn set_start_time<T>(mut self, v: T) -> Self
3526    where
3527        T: std::convert::Into<wkt::Timestamp>,
3528    {
3529        self.start_time = std::option::Option::Some(v.into());
3530        self
3531    }
3532
3533    /// Sets or clears the value of [start_time][crate::model::MetricValue::start_time].
3534    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
3535    where
3536        T: std::convert::Into<wkt::Timestamp>,
3537    {
3538        self.start_time = v.map(|x| x.into());
3539        self
3540    }
3541
3542    /// Sets the value of [end_time][crate::model::MetricValue::end_time].
3543    pub fn set_end_time<T>(mut self, v: T) -> Self
3544    where
3545        T: std::convert::Into<wkt::Timestamp>,
3546    {
3547        self.end_time = std::option::Option::Some(v.into());
3548        self
3549    }
3550
3551    /// Sets or clears the value of [end_time][crate::model::MetricValue::end_time].
3552    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
3553    where
3554        T: std::convert::Into<wkt::Timestamp>,
3555    {
3556        self.end_time = v.map(|x| x.into());
3557        self
3558    }
3559
3560    /// Sets the value of [value][crate::model::MetricValue::value].
3561    ///
3562    /// Note that all the setters affecting `value` are mutually
3563    /// exclusive.
3564    pub fn set_value<
3565        T: std::convert::Into<std::option::Option<crate::model::metric_value::Value>>,
3566    >(
3567        mut self,
3568        v: T,
3569    ) -> Self {
3570        self.value = v.into();
3571        self
3572    }
3573
3574    /// The value of [value][crate::model::MetricValue::value]
3575    /// if it holds a `BoolValue`, `None` if the field is not set or
3576    /// holds a different branch.
3577    pub fn bool_value(&self) -> std::option::Option<&bool> {
3578        #[allow(unreachable_patterns)]
3579        self.value.as_ref().and_then(|v| match v {
3580            crate::model::metric_value::Value::BoolValue(v) => std::option::Option::Some(v),
3581            _ => std::option::Option::None,
3582        })
3583    }
3584
3585    /// Sets the value of [value][crate::model::MetricValue::value]
3586    /// to hold a `BoolValue`.
3587    ///
3588    /// Note that all the setters affecting `value` are
3589    /// mutually exclusive.
3590    pub fn set_bool_value<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3591        self.value =
3592            std::option::Option::Some(crate::model::metric_value::Value::BoolValue(v.into()));
3593        self
3594    }
3595
3596    /// The value of [value][crate::model::MetricValue::value]
3597    /// if it holds a `Int64Value`, `None` if the field is not set or
3598    /// holds a different branch.
3599    pub fn int64_value(&self) -> std::option::Option<&i64> {
3600        #[allow(unreachable_patterns)]
3601        self.value.as_ref().and_then(|v| match v {
3602            crate::model::metric_value::Value::Int64Value(v) => std::option::Option::Some(v),
3603            _ => std::option::Option::None,
3604        })
3605    }
3606
3607    /// Sets the value of [value][crate::model::MetricValue::value]
3608    /// to hold a `Int64Value`.
3609    ///
3610    /// Note that all the setters affecting `value` are
3611    /// mutually exclusive.
3612    pub fn set_int64_value<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
3613        self.value =
3614            std::option::Option::Some(crate::model::metric_value::Value::Int64Value(v.into()));
3615        self
3616    }
3617
3618    /// The value of [value][crate::model::MetricValue::value]
3619    /// if it holds a `DoubleValue`, `None` if the field is not set or
3620    /// holds a different branch.
3621    pub fn double_value(&self) -> std::option::Option<&f64> {
3622        #[allow(unreachable_patterns)]
3623        self.value.as_ref().and_then(|v| match v {
3624            crate::model::metric_value::Value::DoubleValue(v) => std::option::Option::Some(v),
3625            _ => std::option::Option::None,
3626        })
3627    }
3628
3629    /// Sets the value of [value][crate::model::MetricValue::value]
3630    /// to hold a `DoubleValue`.
3631    ///
3632    /// Note that all the setters affecting `value` are
3633    /// mutually exclusive.
3634    pub fn set_double_value<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
3635        self.value =
3636            std::option::Option::Some(crate::model::metric_value::Value::DoubleValue(v.into()));
3637        self
3638    }
3639
3640    /// The value of [value][crate::model::MetricValue::value]
3641    /// if it holds a `StringValue`, `None` if the field is not set or
3642    /// holds a different branch.
3643    pub fn string_value(&self) -> std::option::Option<&std::string::String> {
3644        #[allow(unreachable_patterns)]
3645        self.value.as_ref().and_then(|v| match v {
3646            crate::model::metric_value::Value::StringValue(v) => std::option::Option::Some(v),
3647            _ => std::option::Option::None,
3648        })
3649    }
3650
3651    /// Sets the value of [value][crate::model::MetricValue::value]
3652    /// to hold a `StringValue`.
3653    ///
3654    /// Note that all the setters affecting `value` are
3655    /// mutually exclusive.
3656    pub fn set_string_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3657        self.value =
3658            std::option::Option::Some(crate::model::metric_value::Value::StringValue(v.into()));
3659        self
3660    }
3661
3662    /// The value of [value][crate::model::MetricValue::value]
3663    /// if it holds a `DistributionValue`, `None` if the field is not set or
3664    /// holds a different branch.
3665    pub fn distribution_value(
3666        &self,
3667    ) -> std::option::Option<&std::boxed::Box<crate::model::Distribution>> {
3668        #[allow(unreachable_patterns)]
3669        self.value.as_ref().and_then(|v| match v {
3670            crate::model::metric_value::Value::DistributionValue(v) => std::option::Option::Some(v),
3671            _ => std::option::Option::None,
3672        })
3673    }
3674
3675    /// Sets the value of [value][crate::model::MetricValue::value]
3676    /// to hold a `DistributionValue`.
3677    ///
3678    /// Note that all the setters affecting `value` are
3679    /// mutually exclusive.
3680    pub fn set_distribution_value<
3681        T: std::convert::Into<std::boxed::Box<crate::model::Distribution>>,
3682    >(
3683        mut self,
3684        v: T,
3685    ) -> Self {
3686        self.value = std::option::Option::Some(
3687            crate::model::metric_value::Value::DistributionValue(v.into()),
3688        );
3689        self
3690    }
3691}
3692
3693impl wkt::message::Message for MetricValue {
3694    fn typename() -> &'static str {
3695        "type.googleapis.com/google.api.servicecontrol.v1.MetricValue"
3696    }
3697}
3698
3699#[doc(hidden)]
3700impl<'de> serde::de::Deserialize<'de> for MetricValue {
3701    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3702    where
3703        D: serde::Deserializer<'de>,
3704    {
3705        #[allow(non_camel_case_types)]
3706        #[doc(hidden)]
3707        #[derive(PartialEq, Eq, Hash)]
3708        enum __FieldTag {
3709            __labels,
3710            __start_time,
3711            __end_time,
3712            __bool_value,
3713            __int64_value,
3714            __double_value,
3715            __string_value,
3716            __distribution_value,
3717            Unknown(std::string::String),
3718        }
3719        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3720            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3721            where
3722                D: serde::Deserializer<'de>,
3723            {
3724                struct Visitor;
3725                impl<'de> serde::de::Visitor<'de> for Visitor {
3726                    type Value = __FieldTag;
3727                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3728                        formatter.write_str("a field name for MetricValue")
3729                    }
3730                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3731                    where
3732                        E: serde::de::Error,
3733                    {
3734                        use std::result::Result::Ok;
3735                        use std::string::ToString;
3736                        match value {
3737                            "labels" => Ok(__FieldTag::__labels),
3738                            "startTime" => Ok(__FieldTag::__start_time),
3739                            "start_time" => Ok(__FieldTag::__start_time),
3740                            "endTime" => Ok(__FieldTag::__end_time),
3741                            "end_time" => Ok(__FieldTag::__end_time),
3742                            "boolValue" => Ok(__FieldTag::__bool_value),
3743                            "bool_value" => Ok(__FieldTag::__bool_value),
3744                            "int64Value" => Ok(__FieldTag::__int64_value),
3745                            "int64_value" => Ok(__FieldTag::__int64_value),
3746                            "doubleValue" => Ok(__FieldTag::__double_value),
3747                            "double_value" => Ok(__FieldTag::__double_value),
3748                            "stringValue" => Ok(__FieldTag::__string_value),
3749                            "string_value" => Ok(__FieldTag::__string_value),
3750                            "distributionValue" => Ok(__FieldTag::__distribution_value),
3751                            "distribution_value" => Ok(__FieldTag::__distribution_value),
3752                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3753                        }
3754                    }
3755                }
3756                deserializer.deserialize_identifier(Visitor)
3757            }
3758        }
3759        struct Visitor;
3760        impl<'de> serde::de::Visitor<'de> for Visitor {
3761            type Value = MetricValue;
3762            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3763                formatter.write_str("struct MetricValue")
3764            }
3765            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3766            where
3767                A: serde::de::MapAccess<'de>,
3768            {
3769                #[allow(unused_imports)]
3770                use serde::de::Error;
3771                use std::option::Option::Some;
3772                let mut fields = std::collections::HashSet::new();
3773                let mut result = Self::Value::new();
3774                while let Some(tag) = map.next_key::<__FieldTag>()? {
3775                    #[allow(clippy::match_single_binding)]
3776                    match tag {
3777                        __FieldTag::__labels => {
3778                            if !fields.insert(__FieldTag::__labels) {
3779                                return std::result::Result::Err(A::Error::duplicate_field(
3780                                    "multiple values for labels",
3781                                ));
3782                            }
3783                            result.labels = map
3784                                .next_value::<std::option::Option<
3785                                    std::collections::HashMap<
3786                                        std::string::String,
3787                                        std::string::String,
3788                                    >,
3789                                >>()?
3790                                .unwrap_or_default();
3791                        }
3792                        __FieldTag::__start_time => {
3793                            if !fields.insert(__FieldTag::__start_time) {
3794                                return std::result::Result::Err(A::Error::duplicate_field(
3795                                    "multiple values for start_time",
3796                                ));
3797                            }
3798                            result.start_time =
3799                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3800                        }
3801                        __FieldTag::__end_time => {
3802                            if !fields.insert(__FieldTag::__end_time) {
3803                                return std::result::Result::Err(A::Error::duplicate_field(
3804                                    "multiple values for end_time",
3805                                ));
3806                            }
3807                            result.end_time =
3808                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
3809                        }
3810                        __FieldTag::__bool_value => {
3811                            if !fields.insert(__FieldTag::__bool_value) {
3812                                return std::result::Result::Err(A::Error::duplicate_field(
3813                                    "multiple values for bool_value",
3814                                ));
3815                            }
3816                            if result.value.is_some() {
3817                                return std::result::Result::Err(A::Error::duplicate_field(
3818                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.bool_value, latest field was boolValue",
3819                                ));
3820                            }
3821                            result.value = std::option::Option::Some(
3822                                crate::model::metric_value::Value::BoolValue(
3823                                    map.next_value::<std::option::Option<bool>>()?
3824                                        .unwrap_or_default(),
3825                                ),
3826                            );
3827                        }
3828                        __FieldTag::__int64_value => {
3829                            if !fields.insert(__FieldTag::__int64_value) {
3830                                return std::result::Result::Err(A::Error::duplicate_field(
3831                                    "multiple values for int64_value",
3832                                ));
3833                            }
3834                            struct __With(std::option::Option<i64>);
3835                            impl<'de> serde::de::Deserialize<'de> for __With {
3836                                fn deserialize<D>(
3837                                    deserializer: D,
3838                                ) -> std::result::Result<Self, D::Error>
3839                                where
3840                                    D: serde::de::Deserializer<'de>,
3841                                {
3842                                    serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
3843                                }
3844                            }
3845                            if result.value.is_some() {
3846                                return std::result::Result::Err(A::Error::duplicate_field(
3847                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.int64_value, latest field was int64Value",
3848                                ));
3849                            }
3850                            result.value = std::option::Option::Some(
3851                                crate::model::metric_value::Value::Int64Value(
3852                                    map.next_value::<__With>()?.0.unwrap_or_default(),
3853                                ),
3854                            );
3855                        }
3856                        __FieldTag::__double_value => {
3857                            if !fields.insert(__FieldTag::__double_value) {
3858                                return std::result::Result::Err(A::Error::duplicate_field(
3859                                    "multiple values for double_value",
3860                                ));
3861                            }
3862                            struct __With(std::option::Option<f64>);
3863                            impl<'de> serde::de::Deserialize<'de> for __With {
3864                                fn deserialize<D>(
3865                                    deserializer: D,
3866                                ) -> std::result::Result<Self, D::Error>
3867                                where
3868                                    D: serde::de::Deserializer<'de>,
3869                                {
3870                                    serde_with::As::< std::option::Option<wkt::internal::F64> >::deserialize(deserializer).map(__With)
3871                                }
3872                            }
3873                            if result.value.is_some() {
3874                                return std::result::Result::Err(A::Error::duplicate_field(
3875                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.double_value, latest field was doubleValue",
3876                                ));
3877                            }
3878                            result.value = std::option::Option::Some(
3879                                crate::model::metric_value::Value::DoubleValue(
3880                                    map.next_value::<__With>()?.0.unwrap_or_default(),
3881                                ),
3882                            );
3883                        }
3884                        __FieldTag::__string_value => {
3885                            if !fields.insert(__FieldTag::__string_value) {
3886                                return std::result::Result::Err(A::Error::duplicate_field(
3887                                    "multiple values for string_value",
3888                                ));
3889                            }
3890                            if result.value.is_some() {
3891                                return std::result::Result::Err(A::Error::duplicate_field(
3892                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.string_value, latest field was stringValue",
3893                                ));
3894                            }
3895                            result.value = std::option::Option::Some(
3896                                crate::model::metric_value::Value::StringValue(
3897                                    map.next_value::<std::option::Option<std::string::String>>()?
3898                                        .unwrap_or_default(),
3899                                ),
3900                            );
3901                        }
3902                        __FieldTag::__distribution_value => {
3903                            if !fields.insert(__FieldTag::__distribution_value) {
3904                                return std::result::Result::Err(A::Error::duplicate_field(
3905                                    "multiple values for distribution_value",
3906                                ));
3907                            }
3908                            if result.value.is_some() {
3909                                return std::result::Result::Err(A::Error::duplicate_field(
3910                                    "multiple values for `value`, a oneof with full ID .google.api.servicecontrol.v1.MetricValue.distribution_value, latest field was distributionValue",
3911                                ));
3912                            }
3913                            result.value = std::option::Option::Some(
3914                                crate::model::metric_value::Value::DistributionValue(
3915                                    map.next_value::<std::option::Option<
3916                                        std::boxed::Box<crate::model::Distribution>,
3917                                    >>()?
3918                                    .unwrap_or_default(),
3919                                ),
3920                            );
3921                        }
3922                        __FieldTag::Unknown(key) => {
3923                            let value = map.next_value::<serde_json::Value>()?;
3924                            result._unknown_fields.insert(key, value);
3925                        }
3926                    }
3927                }
3928                std::result::Result::Ok(result)
3929            }
3930        }
3931        deserializer.deserialize_any(Visitor)
3932    }
3933}
3934
3935#[doc(hidden)]
3936impl serde::ser::Serialize for MetricValue {
3937    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3938    where
3939        S: serde::ser::Serializer,
3940    {
3941        use serde::ser::SerializeMap;
3942        #[allow(unused_imports)]
3943        use std::option::Option::Some;
3944        let mut state = serializer.serialize_map(std::option::Option::None)?;
3945        if !self.labels.is_empty() {
3946            state.serialize_entry("labels", &self.labels)?;
3947        }
3948        if self.start_time.is_some() {
3949            state.serialize_entry("startTime", &self.start_time)?;
3950        }
3951        if self.end_time.is_some() {
3952            state.serialize_entry("endTime", &self.end_time)?;
3953        }
3954        if let Some(value) = self.bool_value() {
3955            state.serialize_entry("boolValue", value)?;
3956        }
3957        if let Some(value) = self.int64_value() {
3958            struct __With<'a>(&'a i64);
3959            impl<'a> serde::ser::Serialize for __With<'a> {
3960                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3961                where
3962                    S: serde::ser::Serializer,
3963                {
3964                    serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
3965                }
3966            }
3967            state.serialize_entry("int64Value", &__With(value))?;
3968        }
3969        if let Some(value) = self.double_value() {
3970            struct __With<'a>(&'a f64);
3971            impl<'a> serde::ser::Serialize for __With<'a> {
3972                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3973                where
3974                    S: serde::ser::Serializer,
3975                {
3976                    serde_with::As::<wkt::internal::F64>::serialize(self.0, serializer)
3977                }
3978            }
3979            state.serialize_entry("doubleValue", &__With(value))?;
3980        }
3981        if let Some(value) = self.string_value() {
3982            state.serialize_entry("stringValue", value)?;
3983        }
3984        if let Some(value) = self.distribution_value() {
3985            state.serialize_entry("distributionValue", value)?;
3986        }
3987        if !self._unknown_fields.is_empty() {
3988            for (key, value) in self._unknown_fields.iter() {
3989                state.serialize_entry(key, &value)?;
3990            }
3991        }
3992        state.end()
3993    }
3994}
3995
3996/// Defines additional types related to [MetricValue].
3997pub mod metric_value {
3998    #[allow(unused_imports)]
3999    use super::*;
4000
4001    /// The value. The type of value used in the request must
4002    /// agree with the metric definition in the service configuration, otherwise
4003    /// the MetricValue is rejected.
4004    #[derive(Clone, Debug, PartialEq)]
4005    #[non_exhaustive]
4006    pub enum Value {
4007        /// A boolean value.
4008        BoolValue(bool),
4009        /// A signed 64-bit integer value.
4010        Int64Value(i64),
4011        /// A double precision floating point value.
4012        DoubleValue(f64),
4013        /// A text string value.
4014        StringValue(std::string::String),
4015        /// A distribution value.
4016        DistributionValue(std::boxed::Box<crate::model::Distribution>),
4017    }
4018}
4019
4020/// Represents a set of metric values in the same metric.
4021/// Each metric value in the set should have a unique combination of start time,
4022/// end time, and label values.
4023#[derive(Clone, Debug, Default, PartialEq)]
4024#[non_exhaustive]
4025pub struct MetricValueSet {
4026    /// The metric name defined in the service configuration.
4027    pub metric_name: std::string::String,
4028
4029    /// The values in this metric.
4030    pub metric_values: std::vec::Vec<crate::model::MetricValue>,
4031
4032    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4033}
4034
4035impl MetricValueSet {
4036    pub fn new() -> Self {
4037        std::default::Default::default()
4038    }
4039
4040    /// Sets the value of [metric_name][crate::model::MetricValueSet::metric_name].
4041    pub fn set_metric_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4042        self.metric_name = v.into();
4043        self
4044    }
4045
4046    /// Sets the value of [metric_values][crate::model::MetricValueSet::metric_values].
4047    pub fn set_metric_values<T, V>(mut self, v: T) -> Self
4048    where
4049        T: std::iter::IntoIterator<Item = V>,
4050        V: std::convert::Into<crate::model::MetricValue>,
4051    {
4052        use std::iter::Iterator;
4053        self.metric_values = v.into_iter().map(|i| i.into()).collect();
4054        self
4055    }
4056}
4057
4058impl wkt::message::Message for MetricValueSet {
4059    fn typename() -> &'static str {
4060        "type.googleapis.com/google.api.servicecontrol.v1.MetricValueSet"
4061    }
4062}
4063
4064#[doc(hidden)]
4065impl<'de> serde::de::Deserialize<'de> for MetricValueSet {
4066    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4067    where
4068        D: serde::Deserializer<'de>,
4069    {
4070        #[allow(non_camel_case_types)]
4071        #[doc(hidden)]
4072        #[derive(PartialEq, Eq, Hash)]
4073        enum __FieldTag {
4074            __metric_name,
4075            __metric_values,
4076            Unknown(std::string::String),
4077        }
4078        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4079            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4080            where
4081                D: serde::Deserializer<'de>,
4082            {
4083                struct Visitor;
4084                impl<'de> serde::de::Visitor<'de> for Visitor {
4085                    type Value = __FieldTag;
4086                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4087                        formatter.write_str("a field name for MetricValueSet")
4088                    }
4089                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4090                    where
4091                        E: serde::de::Error,
4092                    {
4093                        use std::result::Result::Ok;
4094                        use std::string::ToString;
4095                        match value {
4096                            "metricName" => Ok(__FieldTag::__metric_name),
4097                            "metric_name" => Ok(__FieldTag::__metric_name),
4098                            "metricValues" => Ok(__FieldTag::__metric_values),
4099                            "metric_values" => Ok(__FieldTag::__metric_values),
4100                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4101                        }
4102                    }
4103                }
4104                deserializer.deserialize_identifier(Visitor)
4105            }
4106        }
4107        struct Visitor;
4108        impl<'de> serde::de::Visitor<'de> for Visitor {
4109            type Value = MetricValueSet;
4110            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4111                formatter.write_str("struct MetricValueSet")
4112            }
4113            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4114            where
4115                A: serde::de::MapAccess<'de>,
4116            {
4117                #[allow(unused_imports)]
4118                use serde::de::Error;
4119                use std::option::Option::Some;
4120                let mut fields = std::collections::HashSet::new();
4121                let mut result = Self::Value::new();
4122                while let Some(tag) = map.next_key::<__FieldTag>()? {
4123                    #[allow(clippy::match_single_binding)]
4124                    match tag {
4125                        __FieldTag::__metric_name => {
4126                            if !fields.insert(__FieldTag::__metric_name) {
4127                                return std::result::Result::Err(A::Error::duplicate_field(
4128                                    "multiple values for metric_name",
4129                                ));
4130                            }
4131                            result.metric_name = map
4132                                .next_value::<std::option::Option<std::string::String>>()?
4133                                .unwrap_or_default();
4134                        }
4135                        __FieldTag::__metric_values => {
4136                            if !fields.insert(__FieldTag::__metric_values) {
4137                                return std::result::Result::Err(A::Error::duplicate_field(
4138                                    "multiple values for metric_values",
4139                                ));
4140                            }
4141                            result.metric_values = map.next_value::<std::option::Option<std::vec::Vec<crate::model::MetricValue>>>()?.unwrap_or_default();
4142                        }
4143                        __FieldTag::Unknown(key) => {
4144                            let value = map.next_value::<serde_json::Value>()?;
4145                            result._unknown_fields.insert(key, value);
4146                        }
4147                    }
4148                }
4149                std::result::Result::Ok(result)
4150            }
4151        }
4152        deserializer.deserialize_any(Visitor)
4153    }
4154}
4155
4156#[doc(hidden)]
4157impl serde::ser::Serialize for MetricValueSet {
4158    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4159    where
4160        S: serde::ser::Serializer,
4161    {
4162        use serde::ser::SerializeMap;
4163        #[allow(unused_imports)]
4164        use std::option::Option::Some;
4165        let mut state = serializer.serialize_map(std::option::Option::None)?;
4166        if !self.metric_name.is_empty() {
4167            state.serialize_entry("metricName", &self.metric_name)?;
4168        }
4169        if !self.metric_values.is_empty() {
4170            state.serialize_entry("metricValues", &self.metric_values)?;
4171        }
4172        if !self._unknown_fields.is_empty() {
4173            for (key, value) in self._unknown_fields.iter() {
4174                state.serialize_entry(key, &value)?;
4175            }
4176        }
4177        state.end()
4178    }
4179}
4180
4181/// Represents information regarding an operation.
4182#[derive(Clone, Debug, Default, PartialEq)]
4183#[non_exhaustive]
4184pub struct Operation {
4185    /// Identity of the operation. This must be unique within the scope of the
4186    /// service that generated the operation. If the service calls
4187    /// Check() and Report() on the same operation, the two calls should carry
4188    /// the same id.
4189    ///
4190    /// UUID version 4 is recommended, though not required.
4191    /// In scenarios where an operation is computed from existing information
4192    /// and an idempotent id is desirable for deduplication purpose, UUID version 5
4193    /// is recommended. See RFC 4122 for details.
4194    pub operation_id: std::string::String,
4195
4196    /// Fully qualified name of the operation. Reserved for future use.
4197    pub operation_name: std::string::String,
4198
4199    /// Identity of the consumer who is using the service.
4200    /// This field should be filled in for the operations initiated by a
4201    /// consumer, but not for service-initiated operations that are
4202    /// not related to a specific consumer.
4203    ///
4204    /// - This can be in one of the following formats:
4205    ///   - project:PROJECT_ID,
4206    ///   - project`_`number:PROJECT_NUMBER,
4207    ///   - projects/PROJECT_ID or PROJECT_NUMBER,
4208    ///   - folders/FOLDER_NUMBER,
4209    ///   - organizations/ORGANIZATION_NUMBER,
4210    ///   - api`_`key:API_KEY.
4211    pub consumer_id: std::string::String,
4212
4213    /// Required. Start time of the operation.
4214    pub start_time: std::option::Option<wkt::Timestamp>,
4215
4216    /// End time of the operation.
4217    /// Required when the operation is used in
4218    /// [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report],
4219    /// but optional when the operation is used in
4220    /// [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check].
4221    ///
4222    /// [google.api.servicecontrol.v1.ServiceController.Check]: crate::client::ServiceController::check
4223    /// [google.api.servicecontrol.v1.ServiceController.Report]: crate::client::ServiceController::report
4224    pub end_time: std::option::Option<wkt::Timestamp>,
4225
4226    /// Labels describing the operation. Only the following labels are allowed:
4227    ///
4228    /// - Labels describing monitored resources as defined in
4229    ///   the service configuration.
4230    /// - Default labels of metric values. When specified, labels defined in the
4231    ///   metric value override these default.
4232    /// - The following labels defined by Google Cloud Platform:
4233    ///   - `cloud.googleapis.com/location` describing the location where the
4234    ///     operation happened,
4235    ///   - `servicecontrol.googleapis.com/user_agent` describing the user agent
4236    ///     of the API request,
4237    ///   - `servicecontrol.googleapis.com/service_agent` describing the service
4238    ///     used to handle the API request (e.g. ESP),
4239    ///   - `servicecontrol.googleapis.com/platform` describing the platform
4240    ///     where the API is served, such as App Engine, Compute Engine, or
4241    ///     Kubernetes Engine.
4242    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
4243
4244    /// Represents information about this operation. Each MetricValueSet
4245    /// corresponds to a metric defined in the service configuration.
4246    /// The data type used in the MetricValueSet must agree with
4247    /// the data type specified in the metric definition.
4248    ///
4249    /// Within a single operation, it is not allowed to have more than one
4250    /// MetricValue instances that have the same metric names and identical
4251    /// label value combinations. If a request has such duplicated MetricValue
4252    /// instances, the entire request is rejected with
4253    /// an invalid argument error.
4254    pub metric_value_sets: std::vec::Vec<crate::model::MetricValueSet>,
4255
4256    /// Represents information to be logged.
4257    pub log_entries: std::vec::Vec<crate::model::LogEntry>,
4258
4259    /// DO NOT USE. This is an experimental field.
4260    pub importance: crate::model::operation::Importance,
4261
4262    /// Unimplemented.
4263    pub extensions: std::vec::Vec<wkt::Any>,
4264
4265    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4266}
4267
4268impl Operation {
4269    pub fn new() -> Self {
4270        std::default::Default::default()
4271    }
4272
4273    /// Sets the value of [operation_id][crate::model::Operation::operation_id].
4274    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4275        self.operation_id = v.into();
4276        self
4277    }
4278
4279    /// Sets the value of [operation_name][crate::model::Operation::operation_name].
4280    pub fn set_operation_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4281        self.operation_name = v.into();
4282        self
4283    }
4284
4285    /// Sets the value of [consumer_id][crate::model::Operation::consumer_id].
4286    pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4287        self.consumer_id = v.into();
4288        self
4289    }
4290
4291    /// Sets the value of [start_time][crate::model::Operation::start_time].
4292    pub fn set_start_time<T>(mut self, v: T) -> Self
4293    where
4294        T: std::convert::Into<wkt::Timestamp>,
4295    {
4296        self.start_time = std::option::Option::Some(v.into());
4297        self
4298    }
4299
4300    /// Sets or clears the value of [start_time][crate::model::Operation::start_time].
4301    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
4302    where
4303        T: std::convert::Into<wkt::Timestamp>,
4304    {
4305        self.start_time = v.map(|x| x.into());
4306        self
4307    }
4308
4309    /// Sets the value of [end_time][crate::model::Operation::end_time].
4310    pub fn set_end_time<T>(mut self, v: T) -> Self
4311    where
4312        T: std::convert::Into<wkt::Timestamp>,
4313    {
4314        self.end_time = std::option::Option::Some(v.into());
4315        self
4316    }
4317
4318    /// Sets or clears the value of [end_time][crate::model::Operation::end_time].
4319    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
4320    where
4321        T: std::convert::Into<wkt::Timestamp>,
4322    {
4323        self.end_time = v.map(|x| x.into());
4324        self
4325    }
4326
4327    /// Sets the value of [labels][crate::model::Operation::labels].
4328    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
4329    where
4330        T: std::iter::IntoIterator<Item = (K, V)>,
4331        K: std::convert::Into<std::string::String>,
4332        V: std::convert::Into<std::string::String>,
4333    {
4334        use std::iter::Iterator;
4335        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4336        self
4337    }
4338
4339    /// Sets the value of [metric_value_sets][crate::model::Operation::metric_value_sets].
4340    pub fn set_metric_value_sets<T, V>(mut self, v: T) -> Self
4341    where
4342        T: std::iter::IntoIterator<Item = V>,
4343        V: std::convert::Into<crate::model::MetricValueSet>,
4344    {
4345        use std::iter::Iterator;
4346        self.metric_value_sets = v.into_iter().map(|i| i.into()).collect();
4347        self
4348    }
4349
4350    /// Sets the value of [log_entries][crate::model::Operation::log_entries].
4351    pub fn set_log_entries<T, V>(mut self, v: T) -> Self
4352    where
4353        T: std::iter::IntoIterator<Item = V>,
4354        V: std::convert::Into<crate::model::LogEntry>,
4355    {
4356        use std::iter::Iterator;
4357        self.log_entries = v.into_iter().map(|i| i.into()).collect();
4358        self
4359    }
4360
4361    /// Sets the value of [importance][crate::model::Operation::importance].
4362    pub fn set_importance<T: std::convert::Into<crate::model::operation::Importance>>(
4363        mut self,
4364        v: T,
4365    ) -> Self {
4366        self.importance = v.into();
4367        self
4368    }
4369
4370    /// Sets the value of [extensions][crate::model::Operation::extensions].
4371    pub fn set_extensions<T, V>(mut self, v: T) -> Self
4372    where
4373        T: std::iter::IntoIterator<Item = V>,
4374        V: std::convert::Into<wkt::Any>,
4375    {
4376        use std::iter::Iterator;
4377        self.extensions = v.into_iter().map(|i| i.into()).collect();
4378        self
4379    }
4380}
4381
4382impl wkt::message::Message for Operation {
4383    fn typename() -> &'static str {
4384        "type.googleapis.com/google.api.servicecontrol.v1.Operation"
4385    }
4386}
4387
4388#[doc(hidden)]
4389impl<'de> serde::de::Deserialize<'de> for Operation {
4390    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4391    where
4392        D: serde::Deserializer<'de>,
4393    {
4394        #[allow(non_camel_case_types)]
4395        #[doc(hidden)]
4396        #[derive(PartialEq, Eq, Hash)]
4397        enum __FieldTag {
4398            __operation_id,
4399            __operation_name,
4400            __consumer_id,
4401            __start_time,
4402            __end_time,
4403            __labels,
4404            __metric_value_sets,
4405            __log_entries,
4406            __importance,
4407            __extensions,
4408            Unknown(std::string::String),
4409        }
4410        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4411            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4412            where
4413                D: serde::Deserializer<'de>,
4414            {
4415                struct Visitor;
4416                impl<'de> serde::de::Visitor<'de> for Visitor {
4417                    type Value = __FieldTag;
4418                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4419                        formatter.write_str("a field name for Operation")
4420                    }
4421                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4422                    where
4423                        E: serde::de::Error,
4424                    {
4425                        use std::result::Result::Ok;
4426                        use std::string::ToString;
4427                        match value {
4428                            "operationId" => Ok(__FieldTag::__operation_id),
4429                            "operation_id" => Ok(__FieldTag::__operation_id),
4430                            "operationName" => Ok(__FieldTag::__operation_name),
4431                            "operation_name" => Ok(__FieldTag::__operation_name),
4432                            "consumerId" => Ok(__FieldTag::__consumer_id),
4433                            "consumer_id" => Ok(__FieldTag::__consumer_id),
4434                            "startTime" => Ok(__FieldTag::__start_time),
4435                            "start_time" => Ok(__FieldTag::__start_time),
4436                            "endTime" => Ok(__FieldTag::__end_time),
4437                            "end_time" => Ok(__FieldTag::__end_time),
4438                            "labels" => Ok(__FieldTag::__labels),
4439                            "metricValueSets" => Ok(__FieldTag::__metric_value_sets),
4440                            "metric_value_sets" => Ok(__FieldTag::__metric_value_sets),
4441                            "logEntries" => Ok(__FieldTag::__log_entries),
4442                            "log_entries" => Ok(__FieldTag::__log_entries),
4443                            "importance" => Ok(__FieldTag::__importance),
4444                            "extensions" => Ok(__FieldTag::__extensions),
4445                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4446                        }
4447                    }
4448                }
4449                deserializer.deserialize_identifier(Visitor)
4450            }
4451        }
4452        struct Visitor;
4453        impl<'de> serde::de::Visitor<'de> for Visitor {
4454            type Value = Operation;
4455            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4456                formatter.write_str("struct Operation")
4457            }
4458            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4459            where
4460                A: serde::de::MapAccess<'de>,
4461            {
4462                #[allow(unused_imports)]
4463                use serde::de::Error;
4464                use std::option::Option::Some;
4465                let mut fields = std::collections::HashSet::new();
4466                let mut result = Self::Value::new();
4467                while let Some(tag) = map.next_key::<__FieldTag>()? {
4468                    #[allow(clippy::match_single_binding)]
4469                    match tag {
4470                        __FieldTag::__operation_id => {
4471                            if !fields.insert(__FieldTag::__operation_id) {
4472                                return std::result::Result::Err(A::Error::duplicate_field(
4473                                    "multiple values for operation_id",
4474                                ));
4475                            }
4476                            result.operation_id = map
4477                                .next_value::<std::option::Option<std::string::String>>()?
4478                                .unwrap_or_default();
4479                        }
4480                        __FieldTag::__operation_name => {
4481                            if !fields.insert(__FieldTag::__operation_name) {
4482                                return std::result::Result::Err(A::Error::duplicate_field(
4483                                    "multiple values for operation_name",
4484                                ));
4485                            }
4486                            result.operation_name = map
4487                                .next_value::<std::option::Option<std::string::String>>()?
4488                                .unwrap_or_default();
4489                        }
4490                        __FieldTag::__consumer_id => {
4491                            if !fields.insert(__FieldTag::__consumer_id) {
4492                                return std::result::Result::Err(A::Error::duplicate_field(
4493                                    "multiple values for consumer_id",
4494                                ));
4495                            }
4496                            result.consumer_id = map
4497                                .next_value::<std::option::Option<std::string::String>>()?
4498                                .unwrap_or_default();
4499                        }
4500                        __FieldTag::__start_time => {
4501                            if !fields.insert(__FieldTag::__start_time) {
4502                                return std::result::Result::Err(A::Error::duplicate_field(
4503                                    "multiple values for start_time",
4504                                ));
4505                            }
4506                            result.start_time =
4507                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4508                        }
4509                        __FieldTag::__end_time => {
4510                            if !fields.insert(__FieldTag::__end_time) {
4511                                return std::result::Result::Err(A::Error::duplicate_field(
4512                                    "multiple values for end_time",
4513                                ));
4514                            }
4515                            result.end_time =
4516                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
4517                        }
4518                        __FieldTag::__labels => {
4519                            if !fields.insert(__FieldTag::__labels) {
4520                                return std::result::Result::Err(A::Error::duplicate_field(
4521                                    "multiple values for labels",
4522                                ));
4523                            }
4524                            result.labels = map
4525                                .next_value::<std::option::Option<
4526                                    std::collections::HashMap<
4527                                        std::string::String,
4528                                        std::string::String,
4529                                    >,
4530                                >>()?
4531                                .unwrap_or_default();
4532                        }
4533                        __FieldTag::__metric_value_sets => {
4534                            if !fields.insert(__FieldTag::__metric_value_sets) {
4535                                return std::result::Result::Err(A::Error::duplicate_field(
4536                                    "multiple values for metric_value_sets",
4537                                ));
4538                            }
4539                            result.metric_value_sets =
4540                                map.next_value::<std::option::Option<
4541                                    std::vec::Vec<crate::model::MetricValueSet>,
4542                                >>()?
4543                                .unwrap_or_default();
4544                        }
4545                        __FieldTag::__log_entries => {
4546                            if !fields.insert(__FieldTag::__log_entries) {
4547                                return std::result::Result::Err(A::Error::duplicate_field(
4548                                    "multiple values for log_entries",
4549                                ));
4550                            }
4551                            result.log_entries = map.next_value::<std::option::Option<std::vec::Vec<crate::model::LogEntry>>>()?.unwrap_or_default();
4552                        }
4553                        __FieldTag::__importance => {
4554                            if !fields.insert(__FieldTag::__importance) {
4555                                return std::result::Result::Err(A::Error::duplicate_field(
4556                                    "multiple values for importance",
4557                                ));
4558                            }
4559                            result.importance = map.next_value::<std::option::Option<crate::model::operation::Importance>>()?.unwrap_or_default();
4560                        }
4561                        __FieldTag::__extensions => {
4562                            if !fields.insert(__FieldTag::__extensions) {
4563                                return std::result::Result::Err(A::Error::duplicate_field(
4564                                    "multiple values for extensions",
4565                                ));
4566                            }
4567                            result.extensions = map
4568                                .next_value::<std::option::Option<std::vec::Vec<wkt::Any>>>()?
4569                                .unwrap_or_default();
4570                        }
4571                        __FieldTag::Unknown(key) => {
4572                            let value = map.next_value::<serde_json::Value>()?;
4573                            result._unknown_fields.insert(key, value);
4574                        }
4575                    }
4576                }
4577                std::result::Result::Ok(result)
4578            }
4579        }
4580        deserializer.deserialize_any(Visitor)
4581    }
4582}
4583
4584#[doc(hidden)]
4585impl serde::ser::Serialize for Operation {
4586    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4587    where
4588        S: serde::ser::Serializer,
4589    {
4590        use serde::ser::SerializeMap;
4591        #[allow(unused_imports)]
4592        use std::option::Option::Some;
4593        let mut state = serializer.serialize_map(std::option::Option::None)?;
4594        if !self.operation_id.is_empty() {
4595            state.serialize_entry("operationId", &self.operation_id)?;
4596        }
4597        if !self.operation_name.is_empty() {
4598            state.serialize_entry("operationName", &self.operation_name)?;
4599        }
4600        if !self.consumer_id.is_empty() {
4601            state.serialize_entry("consumerId", &self.consumer_id)?;
4602        }
4603        if self.start_time.is_some() {
4604            state.serialize_entry("startTime", &self.start_time)?;
4605        }
4606        if self.end_time.is_some() {
4607            state.serialize_entry("endTime", &self.end_time)?;
4608        }
4609        if !self.labels.is_empty() {
4610            state.serialize_entry("labels", &self.labels)?;
4611        }
4612        if !self.metric_value_sets.is_empty() {
4613            state.serialize_entry("metricValueSets", &self.metric_value_sets)?;
4614        }
4615        if !self.log_entries.is_empty() {
4616            state.serialize_entry("logEntries", &self.log_entries)?;
4617        }
4618        if !wkt::internal::is_default(&self.importance) {
4619            state.serialize_entry("importance", &self.importance)?;
4620        }
4621        if !self.extensions.is_empty() {
4622            state.serialize_entry("extensions", &self.extensions)?;
4623        }
4624        if !self._unknown_fields.is_empty() {
4625            for (key, value) in self._unknown_fields.iter() {
4626                state.serialize_entry(key, &value)?;
4627            }
4628        }
4629        state.end()
4630    }
4631}
4632
4633/// Defines additional types related to [Operation].
4634pub mod operation {
4635    #[allow(unused_imports)]
4636    use super::*;
4637
4638    /// Defines the importance of the data contained in the operation.
4639    ///
4640    /// # Working with unknown values
4641    ///
4642    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4643    /// additional enum variants at any time. Adding new variants is not considered
4644    /// a breaking change. Applications should write their code in anticipation of:
4645    ///
4646    /// - New values appearing in future releases of the client library, **and**
4647    /// - New values received dynamically, without application changes.
4648    ///
4649    /// Please consult the [Working with enums] section in the user guide for some
4650    /// guidelines.
4651    ///
4652    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4653    #[derive(Clone, Debug, PartialEq)]
4654    #[non_exhaustive]
4655    pub enum Importance {
4656        /// Allows data caching, batching, and aggregation. It provides
4657        /// higher performance with higher data loss risk.
4658        Low,
4659        /// Disables data aggregation to minimize data loss. It is for operations
4660        /// that contains significant monetary value or audit trail. This feature
4661        /// only applies to the client libraries.
4662        High,
4663        /// If set, the enum was initialized with an unknown value.
4664        ///
4665        /// Applications can examine the value using [Importance::value] or
4666        /// [Importance::name].
4667        UnknownValue(importance::UnknownValue),
4668    }
4669
4670    #[doc(hidden)]
4671    pub mod importance {
4672        #[allow(unused_imports)]
4673        use super::*;
4674        #[derive(Clone, Debug, PartialEq)]
4675        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4676    }
4677
4678    impl Importance {
4679        /// Gets the enum value.
4680        ///
4681        /// Returns `None` if the enum contains an unknown value deserialized from
4682        /// the string representation of enums.
4683        pub fn value(&self) -> std::option::Option<i32> {
4684            match self {
4685                Self::Low => std::option::Option::Some(0),
4686                Self::High => std::option::Option::Some(1),
4687                Self::UnknownValue(u) => u.0.value(),
4688            }
4689        }
4690
4691        /// Gets the enum value as a string.
4692        ///
4693        /// Returns `None` if the enum contains an unknown value deserialized from
4694        /// the integer representation of enums.
4695        pub fn name(&self) -> std::option::Option<&str> {
4696            match self {
4697                Self::Low => std::option::Option::Some("LOW"),
4698                Self::High => std::option::Option::Some("HIGH"),
4699                Self::UnknownValue(u) => u.0.name(),
4700            }
4701        }
4702    }
4703
4704    impl std::default::Default for Importance {
4705        fn default() -> Self {
4706            use std::convert::From;
4707            Self::from(0)
4708        }
4709    }
4710
4711    impl std::fmt::Display for Importance {
4712        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4713            wkt::internal::display_enum(f, self.name(), self.value())
4714        }
4715    }
4716
4717    impl std::convert::From<i32> for Importance {
4718        fn from(value: i32) -> Self {
4719            match value {
4720                0 => Self::Low,
4721                1 => Self::High,
4722                _ => Self::UnknownValue(importance::UnknownValue(
4723                    wkt::internal::UnknownEnumValue::Integer(value),
4724                )),
4725            }
4726        }
4727    }
4728
4729    impl std::convert::From<&str> for Importance {
4730        fn from(value: &str) -> Self {
4731            use std::string::ToString;
4732            match value {
4733                "LOW" => Self::Low,
4734                "HIGH" => Self::High,
4735                _ => Self::UnknownValue(importance::UnknownValue(
4736                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4737                )),
4738            }
4739        }
4740    }
4741
4742    impl serde::ser::Serialize for Importance {
4743        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4744        where
4745            S: serde::Serializer,
4746        {
4747            match self {
4748                Self::Low => serializer.serialize_i32(0),
4749                Self::High => serializer.serialize_i32(1),
4750                Self::UnknownValue(u) => u.0.serialize(serializer),
4751            }
4752        }
4753    }
4754
4755    impl<'de> serde::de::Deserialize<'de> for Importance {
4756        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4757        where
4758            D: serde::Deserializer<'de>,
4759        {
4760            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Importance>::new(
4761                ".google.api.servicecontrol.v1.Operation.Importance",
4762            ))
4763        }
4764    }
4765}
4766
4767/// Request message for the AllocateQuota method.
4768#[derive(Clone, Debug, Default, PartialEq)]
4769#[non_exhaustive]
4770pub struct AllocateQuotaRequest {
4771    /// Name of the service as specified in the service configuration. For example,
4772    /// `"pubsub.googleapis.com"`.
4773    ///
4774    /// See [google.api.Service][google.api.Service] for the definition of a service name.
4775    pub service_name: std::string::String,
4776
4777    /// Operation that describes the quota allocation.
4778    pub allocate_operation: std::option::Option<crate::model::QuotaOperation>,
4779
4780    /// Specifies which version of service configuration should be used to process
4781    /// the request. If unspecified or no matching version can be found, the latest
4782    /// one will be used.
4783    pub service_config_id: std::string::String,
4784
4785    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4786}
4787
4788impl AllocateQuotaRequest {
4789    pub fn new() -> Self {
4790        std::default::Default::default()
4791    }
4792
4793    /// Sets the value of [service_name][crate::model::AllocateQuotaRequest::service_name].
4794    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4795        self.service_name = v.into();
4796        self
4797    }
4798
4799    /// Sets the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
4800    pub fn set_allocate_operation<T>(mut self, v: T) -> Self
4801    where
4802        T: std::convert::Into<crate::model::QuotaOperation>,
4803    {
4804        self.allocate_operation = std::option::Option::Some(v.into());
4805        self
4806    }
4807
4808    /// Sets or clears the value of [allocate_operation][crate::model::AllocateQuotaRequest::allocate_operation].
4809    pub fn set_or_clear_allocate_operation<T>(mut self, v: std::option::Option<T>) -> Self
4810    where
4811        T: std::convert::Into<crate::model::QuotaOperation>,
4812    {
4813        self.allocate_operation = v.map(|x| x.into());
4814        self
4815    }
4816
4817    /// Sets the value of [service_config_id][crate::model::AllocateQuotaRequest::service_config_id].
4818    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
4819        mut self,
4820        v: T,
4821    ) -> Self {
4822        self.service_config_id = v.into();
4823        self
4824    }
4825}
4826
4827impl wkt::message::Message for AllocateQuotaRequest {
4828    fn typename() -> &'static str {
4829        "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaRequest"
4830    }
4831}
4832
4833#[doc(hidden)]
4834impl<'de> serde::de::Deserialize<'de> for AllocateQuotaRequest {
4835    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4836    where
4837        D: serde::Deserializer<'de>,
4838    {
4839        #[allow(non_camel_case_types)]
4840        #[doc(hidden)]
4841        #[derive(PartialEq, Eq, Hash)]
4842        enum __FieldTag {
4843            __service_name,
4844            __allocate_operation,
4845            __service_config_id,
4846            Unknown(std::string::String),
4847        }
4848        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4849            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4850            where
4851                D: serde::Deserializer<'de>,
4852            {
4853                struct Visitor;
4854                impl<'de> serde::de::Visitor<'de> for Visitor {
4855                    type Value = __FieldTag;
4856                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4857                        formatter.write_str("a field name for AllocateQuotaRequest")
4858                    }
4859                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4860                    where
4861                        E: serde::de::Error,
4862                    {
4863                        use std::result::Result::Ok;
4864                        use std::string::ToString;
4865                        match value {
4866                            "serviceName" => Ok(__FieldTag::__service_name),
4867                            "service_name" => Ok(__FieldTag::__service_name),
4868                            "allocateOperation" => Ok(__FieldTag::__allocate_operation),
4869                            "allocate_operation" => Ok(__FieldTag::__allocate_operation),
4870                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
4871                            "service_config_id" => Ok(__FieldTag::__service_config_id),
4872                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4873                        }
4874                    }
4875                }
4876                deserializer.deserialize_identifier(Visitor)
4877            }
4878        }
4879        struct Visitor;
4880        impl<'de> serde::de::Visitor<'de> for Visitor {
4881            type Value = AllocateQuotaRequest;
4882            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4883                formatter.write_str("struct AllocateQuotaRequest")
4884            }
4885            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4886            where
4887                A: serde::de::MapAccess<'de>,
4888            {
4889                #[allow(unused_imports)]
4890                use serde::de::Error;
4891                use std::option::Option::Some;
4892                let mut fields = std::collections::HashSet::new();
4893                let mut result = Self::Value::new();
4894                while let Some(tag) = map.next_key::<__FieldTag>()? {
4895                    #[allow(clippy::match_single_binding)]
4896                    match tag {
4897                        __FieldTag::__service_name => {
4898                            if !fields.insert(__FieldTag::__service_name) {
4899                                return std::result::Result::Err(A::Error::duplicate_field(
4900                                    "multiple values for service_name",
4901                                ));
4902                            }
4903                            result.service_name = map
4904                                .next_value::<std::option::Option<std::string::String>>()?
4905                                .unwrap_or_default();
4906                        }
4907                        __FieldTag::__allocate_operation => {
4908                            if !fields.insert(__FieldTag::__allocate_operation) {
4909                                return std::result::Result::Err(A::Error::duplicate_field(
4910                                    "multiple values for allocate_operation",
4911                                ));
4912                            }
4913                            result.allocate_operation = map
4914                                .next_value::<std::option::Option<crate::model::QuotaOperation>>(
4915                                )?;
4916                        }
4917                        __FieldTag::__service_config_id => {
4918                            if !fields.insert(__FieldTag::__service_config_id) {
4919                                return std::result::Result::Err(A::Error::duplicate_field(
4920                                    "multiple values for service_config_id",
4921                                ));
4922                            }
4923                            result.service_config_id = map
4924                                .next_value::<std::option::Option<std::string::String>>()?
4925                                .unwrap_or_default();
4926                        }
4927                        __FieldTag::Unknown(key) => {
4928                            let value = map.next_value::<serde_json::Value>()?;
4929                            result._unknown_fields.insert(key, value);
4930                        }
4931                    }
4932                }
4933                std::result::Result::Ok(result)
4934            }
4935        }
4936        deserializer.deserialize_any(Visitor)
4937    }
4938}
4939
4940#[doc(hidden)]
4941impl serde::ser::Serialize for AllocateQuotaRequest {
4942    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4943    where
4944        S: serde::ser::Serializer,
4945    {
4946        use serde::ser::SerializeMap;
4947        #[allow(unused_imports)]
4948        use std::option::Option::Some;
4949        let mut state = serializer.serialize_map(std::option::Option::None)?;
4950        if !self.service_name.is_empty() {
4951            state.serialize_entry("serviceName", &self.service_name)?;
4952        }
4953        if self.allocate_operation.is_some() {
4954            state.serialize_entry("allocateOperation", &self.allocate_operation)?;
4955        }
4956        if !self.service_config_id.is_empty() {
4957            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
4958        }
4959        if !self._unknown_fields.is_empty() {
4960            for (key, value) in self._unknown_fields.iter() {
4961                state.serialize_entry(key, &value)?;
4962            }
4963        }
4964        state.end()
4965    }
4966}
4967
4968/// Represents information regarding a quota operation.
4969#[derive(Clone, Debug, Default, PartialEq)]
4970#[non_exhaustive]
4971pub struct QuotaOperation {
4972    /// Identity of the operation. This is expected to be unique within the scope
4973    /// of the service that generated the operation, and guarantees idempotency in
4974    /// case of retries.
4975    ///
4976    /// In order to ensure best performance and latency in the Quota backends,
4977    /// operation_ids are optimally associated with time, so that related
4978    /// operations can be accessed fast in storage. For this reason, the
4979    /// recommended token for services that intend to operate at a high QPS is
4980    /// Unix time in nanos + UUID
4981    pub operation_id: std::string::String,
4982
4983    /// Fully qualified name of the API method for which this quota operation is
4984    /// requested. This name is used for matching quota rules or metric rules and
4985    /// billing status rules defined in service configuration.
4986    ///
4987    /// This field should not be set if any of the following is true:
4988    /// (1) the quota operation is performed on non-API resources.
4989    /// (2) quota_metrics is set because the caller is doing quota override.
4990    ///
4991    /// Example of an RPC method name:
4992    /// google.example.library.v1.LibraryService.CreateShelf
4993    pub method_name: std::string::String,
4994
4995    /// Identity of the consumer for whom this quota operation is being performed.
4996    ///
4997    /// This can be in one of the following formats:
4998    /// project:<project_id>,
4999    /// project_number:<project_number>,
5000    /// api_key:<api_key>.
5001    pub consumer_id: std::string::String,
5002
5003    /// Labels describing the operation.
5004    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
5005
5006    /// Represents information about this operation. Each MetricValueSet
5007    /// corresponds to a metric defined in the service configuration.
5008    /// The data type used in the MetricValueSet must agree with
5009    /// the data type specified in the metric definition.
5010    ///
5011    /// Within a single operation, it is not allowed to have more than one
5012    /// MetricValue instances that have the same metric names and identical
5013    /// label value combinations. If a request has such duplicated MetricValue
5014    /// instances, the entire request is rejected with
5015    /// an invalid argument error.
5016    ///
5017    /// This field is mutually exclusive with method_name.
5018    pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
5019
5020    /// Quota mode for this operation.
5021    pub quota_mode: crate::model::quota_operation::QuotaMode,
5022
5023    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5024}
5025
5026impl QuotaOperation {
5027    pub fn new() -> Self {
5028        std::default::Default::default()
5029    }
5030
5031    /// Sets the value of [operation_id][crate::model::QuotaOperation::operation_id].
5032    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5033        self.operation_id = v.into();
5034        self
5035    }
5036
5037    /// Sets the value of [method_name][crate::model::QuotaOperation::method_name].
5038    pub fn set_method_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5039        self.method_name = v.into();
5040        self
5041    }
5042
5043    /// Sets the value of [consumer_id][crate::model::QuotaOperation::consumer_id].
5044    pub fn set_consumer_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5045        self.consumer_id = v.into();
5046        self
5047    }
5048
5049    /// Sets the value of [labels][crate::model::QuotaOperation::labels].
5050    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
5051    where
5052        T: std::iter::IntoIterator<Item = (K, V)>,
5053        K: std::convert::Into<std::string::String>,
5054        V: std::convert::Into<std::string::String>,
5055    {
5056        use std::iter::Iterator;
5057        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5058        self
5059    }
5060
5061    /// Sets the value of [quota_metrics][crate::model::QuotaOperation::quota_metrics].
5062    pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
5063    where
5064        T: std::iter::IntoIterator<Item = V>,
5065        V: std::convert::Into<crate::model::MetricValueSet>,
5066    {
5067        use std::iter::Iterator;
5068        self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
5069        self
5070    }
5071
5072    /// Sets the value of [quota_mode][crate::model::QuotaOperation::quota_mode].
5073    pub fn set_quota_mode<T: std::convert::Into<crate::model::quota_operation::QuotaMode>>(
5074        mut self,
5075        v: T,
5076    ) -> Self {
5077        self.quota_mode = v.into();
5078        self
5079    }
5080}
5081
5082impl wkt::message::Message for QuotaOperation {
5083    fn typename() -> &'static str {
5084        "type.googleapis.com/google.api.servicecontrol.v1.QuotaOperation"
5085    }
5086}
5087
5088#[doc(hidden)]
5089impl<'de> serde::de::Deserialize<'de> for QuotaOperation {
5090    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5091    where
5092        D: serde::Deserializer<'de>,
5093    {
5094        #[allow(non_camel_case_types)]
5095        #[doc(hidden)]
5096        #[derive(PartialEq, Eq, Hash)]
5097        enum __FieldTag {
5098            __operation_id,
5099            __method_name,
5100            __consumer_id,
5101            __labels,
5102            __quota_metrics,
5103            __quota_mode,
5104            Unknown(std::string::String),
5105        }
5106        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5107            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5108            where
5109                D: serde::Deserializer<'de>,
5110            {
5111                struct Visitor;
5112                impl<'de> serde::de::Visitor<'de> for Visitor {
5113                    type Value = __FieldTag;
5114                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5115                        formatter.write_str("a field name for QuotaOperation")
5116                    }
5117                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5118                    where
5119                        E: serde::de::Error,
5120                    {
5121                        use std::result::Result::Ok;
5122                        use std::string::ToString;
5123                        match value {
5124                            "operationId" => Ok(__FieldTag::__operation_id),
5125                            "operation_id" => Ok(__FieldTag::__operation_id),
5126                            "methodName" => Ok(__FieldTag::__method_name),
5127                            "method_name" => Ok(__FieldTag::__method_name),
5128                            "consumerId" => Ok(__FieldTag::__consumer_id),
5129                            "consumer_id" => Ok(__FieldTag::__consumer_id),
5130                            "labels" => Ok(__FieldTag::__labels),
5131                            "quotaMetrics" => Ok(__FieldTag::__quota_metrics),
5132                            "quota_metrics" => Ok(__FieldTag::__quota_metrics),
5133                            "quotaMode" => Ok(__FieldTag::__quota_mode),
5134                            "quota_mode" => Ok(__FieldTag::__quota_mode),
5135                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5136                        }
5137                    }
5138                }
5139                deserializer.deserialize_identifier(Visitor)
5140            }
5141        }
5142        struct Visitor;
5143        impl<'de> serde::de::Visitor<'de> for Visitor {
5144            type Value = QuotaOperation;
5145            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5146                formatter.write_str("struct QuotaOperation")
5147            }
5148            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5149            where
5150                A: serde::de::MapAccess<'de>,
5151            {
5152                #[allow(unused_imports)]
5153                use serde::de::Error;
5154                use std::option::Option::Some;
5155                let mut fields = std::collections::HashSet::new();
5156                let mut result = Self::Value::new();
5157                while let Some(tag) = map.next_key::<__FieldTag>()? {
5158                    #[allow(clippy::match_single_binding)]
5159                    match tag {
5160                        __FieldTag::__operation_id => {
5161                            if !fields.insert(__FieldTag::__operation_id) {
5162                                return std::result::Result::Err(A::Error::duplicate_field(
5163                                    "multiple values for operation_id",
5164                                ));
5165                            }
5166                            result.operation_id = map
5167                                .next_value::<std::option::Option<std::string::String>>()?
5168                                .unwrap_or_default();
5169                        }
5170                        __FieldTag::__method_name => {
5171                            if !fields.insert(__FieldTag::__method_name) {
5172                                return std::result::Result::Err(A::Error::duplicate_field(
5173                                    "multiple values for method_name",
5174                                ));
5175                            }
5176                            result.method_name = map
5177                                .next_value::<std::option::Option<std::string::String>>()?
5178                                .unwrap_or_default();
5179                        }
5180                        __FieldTag::__consumer_id => {
5181                            if !fields.insert(__FieldTag::__consumer_id) {
5182                                return std::result::Result::Err(A::Error::duplicate_field(
5183                                    "multiple values for consumer_id",
5184                                ));
5185                            }
5186                            result.consumer_id = map
5187                                .next_value::<std::option::Option<std::string::String>>()?
5188                                .unwrap_or_default();
5189                        }
5190                        __FieldTag::__labels => {
5191                            if !fields.insert(__FieldTag::__labels) {
5192                                return std::result::Result::Err(A::Error::duplicate_field(
5193                                    "multiple values for labels",
5194                                ));
5195                            }
5196                            result.labels = map
5197                                .next_value::<std::option::Option<
5198                                    std::collections::HashMap<
5199                                        std::string::String,
5200                                        std::string::String,
5201                                    >,
5202                                >>()?
5203                                .unwrap_or_default();
5204                        }
5205                        __FieldTag::__quota_metrics => {
5206                            if !fields.insert(__FieldTag::__quota_metrics) {
5207                                return std::result::Result::Err(A::Error::duplicate_field(
5208                                    "multiple values for quota_metrics",
5209                                ));
5210                            }
5211                            result.quota_metrics =
5212                                map.next_value::<std::option::Option<
5213                                    std::vec::Vec<crate::model::MetricValueSet>,
5214                                >>()?
5215                                .unwrap_or_default();
5216                        }
5217                        __FieldTag::__quota_mode => {
5218                            if !fields.insert(__FieldTag::__quota_mode) {
5219                                return std::result::Result::Err(A::Error::duplicate_field(
5220                                    "multiple values for quota_mode",
5221                                ));
5222                            }
5223                            result.quota_mode = map.next_value::<std::option::Option<crate::model::quota_operation::QuotaMode>>()?.unwrap_or_default();
5224                        }
5225                        __FieldTag::Unknown(key) => {
5226                            let value = map.next_value::<serde_json::Value>()?;
5227                            result._unknown_fields.insert(key, value);
5228                        }
5229                    }
5230                }
5231                std::result::Result::Ok(result)
5232            }
5233        }
5234        deserializer.deserialize_any(Visitor)
5235    }
5236}
5237
5238#[doc(hidden)]
5239impl serde::ser::Serialize for QuotaOperation {
5240    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5241    where
5242        S: serde::ser::Serializer,
5243    {
5244        use serde::ser::SerializeMap;
5245        #[allow(unused_imports)]
5246        use std::option::Option::Some;
5247        let mut state = serializer.serialize_map(std::option::Option::None)?;
5248        if !self.operation_id.is_empty() {
5249            state.serialize_entry("operationId", &self.operation_id)?;
5250        }
5251        if !self.method_name.is_empty() {
5252            state.serialize_entry("methodName", &self.method_name)?;
5253        }
5254        if !self.consumer_id.is_empty() {
5255            state.serialize_entry("consumerId", &self.consumer_id)?;
5256        }
5257        if !self.labels.is_empty() {
5258            state.serialize_entry("labels", &self.labels)?;
5259        }
5260        if !self.quota_metrics.is_empty() {
5261            state.serialize_entry("quotaMetrics", &self.quota_metrics)?;
5262        }
5263        if !wkt::internal::is_default(&self.quota_mode) {
5264            state.serialize_entry("quotaMode", &self.quota_mode)?;
5265        }
5266        if !self._unknown_fields.is_empty() {
5267            for (key, value) in self._unknown_fields.iter() {
5268                state.serialize_entry(key, &value)?;
5269            }
5270        }
5271        state.end()
5272    }
5273}
5274
5275/// Defines additional types related to [QuotaOperation].
5276pub mod quota_operation {
5277    #[allow(unused_imports)]
5278    use super::*;
5279
5280    /// Supported quota modes.
5281    ///
5282    /// # Working with unknown values
5283    ///
5284    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5285    /// additional enum variants at any time. Adding new variants is not considered
5286    /// a breaking change. Applications should write their code in anticipation of:
5287    ///
5288    /// - New values appearing in future releases of the client library, **and**
5289    /// - New values received dynamically, without application changes.
5290    ///
5291    /// Please consult the [Working with enums] section in the user guide for some
5292    /// guidelines.
5293    ///
5294    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
5295    #[derive(Clone, Debug, PartialEq)]
5296    #[non_exhaustive]
5297    pub enum QuotaMode {
5298        /// Guard against implicit default. Must not be used.
5299        Unspecified,
5300        /// For AllocateQuota request, allocates quota for the amount specified in
5301        /// the service configuration or specified using the quota metrics. If the
5302        /// amount is higher than the available quota, allocation error will be
5303        /// returned and no quota will be allocated.
5304        /// If multiple quotas are part of the request, and one fails, none of the
5305        /// quotas are allocated or released.
5306        Normal,
5307        /// The operation allocates quota for the amount specified in the service
5308        /// configuration or specified using the quota metrics. If the amount is
5309        /// higher than the available quota, request does not fail but all available
5310        /// quota will be allocated.
5311        /// For rate quota, BEST_EFFORT will continue to deduct from other groups
5312        /// even if one does not have enough quota. For allocation, it will find the
5313        /// minimum available amount across all groups and deduct that amount from
5314        /// all the affected groups.
5315        BestEffort,
5316        /// For AllocateQuota request, only checks if there is enough quota
5317        /// available and does not change the available quota. No lock is placed on
5318        /// the available quota either.
5319        CheckOnly,
5320        /// Unimplemented. When used in AllocateQuotaRequest, this returns the
5321        /// effective quota limit(s) in the response, and no quota check will be
5322        /// performed. Not supported for other requests, and even for
5323        /// AllocateQuotaRequest, this is currently supported only for allowlisted
5324        /// services.
5325        QueryOnly,
5326        /// The operation allocates quota for the amount specified in the service
5327        /// configuration or specified using the quota metrics. If the requested
5328        /// amount is higher than the available quota, request does not fail and
5329        /// remaining quota would become negative (going over the limit).
5330        /// Not supported for Rate Quota.
5331        AdjustOnly,
5332        /// If set, the enum was initialized with an unknown value.
5333        ///
5334        /// Applications can examine the value using [QuotaMode::value] or
5335        /// [QuotaMode::name].
5336        UnknownValue(quota_mode::UnknownValue),
5337    }
5338
5339    #[doc(hidden)]
5340    pub mod quota_mode {
5341        #[allow(unused_imports)]
5342        use super::*;
5343        #[derive(Clone, Debug, PartialEq)]
5344        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5345    }
5346
5347    impl QuotaMode {
5348        /// Gets the enum value.
5349        ///
5350        /// Returns `None` if the enum contains an unknown value deserialized from
5351        /// the string representation of enums.
5352        pub fn value(&self) -> std::option::Option<i32> {
5353            match self {
5354                Self::Unspecified => std::option::Option::Some(0),
5355                Self::Normal => std::option::Option::Some(1),
5356                Self::BestEffort => std::option::Option::Some(2),
5357                Self::CheckOnly => std::option::Option::Some(3),
5358                Self::QueryOnly => std::option::Option::Some(4),
5359                Self::AdjustOnly => std::option::Option::Some(5),
5360                Self::UnknownValue(u) => u.0.value(),
5361            }
5362        }
5363
5364        /// Gets the enum value as a string.
5365        ///
5366        /// Returns `None` if the enum contains an unknown value deserialized from
5367        /// the integer representation of enums.
5368        pub fn name(&self) -> std::option::Option<&str> {
5369            match self {
5370                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
5371                Self::Normal => std::option::Option::Some("NORMAL"),
5372                Self::BestEffort => std::option::Option::Some("BEST_EFFORT"),
5373                Self::CheckOnly => std::option::Option::Some("CHECK_ONLY"),
5374                Self::QueryOnly => std::option::Option::Some("QUERY_ONLY"),
5375                Self::AdjustOnly => std::option::Option::Some("ADJUST_ONLY"),
5376                Self::UnknownValue(u) => u.0.name(),
5377            }
5378        }
5379    }
5380
5381    impl std::default::Default for QuotaMode {
5382        fn default() -> Self {
5383            use std::convert::From;
5384            Self::from(0)
5385        }
5386    }
5387
5388    impl std::fmt::Display for QuotaMode {
5389        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5390            wkt::internal::display_enum(f, self.name(), self.value())
5391        }
5392    }
5393
5394    impl std::convert::From<i32> for QuotaMode {
5395        fn from(value: i32) -> Self {
5396            match value {
5397                0 => Self::Unspecified,
5398                1 => Self::Normal,
5399                2 => Self::BestEffort,
5400                3 => Self::CheckOnly,
5401                4 => Self::QueryOnly,
5402                5 => Self::AdjustOnly,
5403                _ => Self::UnknownValue(quota_mode::UnknownValue(
5404                    wkt::internal::UnknownEnumValue::Integer(value),
5405                )),
5406            }
5407        }
5408    }
5409
5410    impl std::convert::From<&str> for QuotaMode {
5411        fn from(value: &str) -> Self {
5412            use std::string::ToString;
5413            match value {
5414                "UNSPECIFIED" => Self::Unspecified,
5415                "NORMAL" => Self::Normal,
5416                "BEST_EFFORT" => Self::BestEffort,
5417                "CHECK_ONLY" => Self::CheckOnly,
5418                "QUERY_ONLY" => Self::QueryOnly,
5419                "ADJUST_ONLY" => Self::AdjustOnly,
5420                _ => Self::UnknownValue(quota_mode::UnknownValue(
5421                    wkt::internal::UnknownEnumValue::String(value.to_string()),
5422                )),
5423            }
5424        }
5425    }
5426
5427    impl serde::ser::Serialize for QuotaMode {
5428        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5429        where
5430            S: serde::Serializer,
5431        {
5432            match self {
5433                Self::Unspecified => serializer.serialize_i32(0),
5434                Self::Normal => serializer.serialize_i32(1),
5435                Self::BestEffort => serializer.serialize_i32(2),
5436                Self::CheckOnly => serializer.serialize_i32(3),
5437                Self::QueryOnly => serializer.serialize_i32(4),
5438                Self::AdjustOnly => serializer.serialize_i32(5),
5439                Self::UnknownValue(u) => u.0.serialize(serializer),
5440            }
5441        }
5442    }
5443
5444    impl<'de> serde::de::Deserialize<'de> for QuotaMode {
5445        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5446        where
5447            D: serde::Deserializer<'de>,
5448        {
5449            deserializer.deserialize_any(wkt::internal::EnumVisitor::<QuotaMode>::new(
5450                ".google.api.servicecontrol.v1.QuotaOperation.QuotaMode",
5451            ))
5452        }
5453    }
5454}
5455
5456/// Response message for the AllocateQuota method.
5457#[derive(Clone, Debug, Default, PartialEq)]
5458#[non_exhaustive]
5459pub struct AllocateQuotaResponse {
5460    /// The same operation_id value used in the AllocateQuotaRequest. Used for
5461    /// logging and diagnostics purposes.
5462    pub operation_id: std::string::String,
5463
5464    /// Indicates the decision of the allocate.
5465    pub allocate_errors: std::vec::Vec<crate::model::QuotaError>,
5466
5467    /// Quota metrics to indicate the result of allocation. Depending on the
5468    /// request, one or more of the following metrics will be included:
5469    ///
5470    /// 1. Per quota group or per quota metric incremental usage will be specified
5471    ///    using the following delta metric :
5472    ///    "serviceruntime.googleapis.com/api/consumer/quota_used_count"
5473    ///
5474    /// 1. The quota limit reached condition will be specified using the following
5475    ///    boolean metric :
5476    ///    "serviceruntime.googleapis.com/quota/exceeded"
5477    ///
5478    pub quota_metrics: std::vec::Vec<crate::model::MetricValueSet>,
5479
5480    /// ID of the actual config used to process the request.
5481    pub service_config_id: std::string::String,
5482
5483    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5484}
5485
5486impl AllocateQuotaResponse {
5487    pub fn new() -> Self {
5488        std::default::Default::default()
5489    }
5490
5491    /// Sets the value of [operation_id][crate::model::AllocateQuotaResponse::operation_id].
5492    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5493        self.operation_id = v.into();
5494        self
5495    }
5496
5497    /// Sets the value of [allocate_errors][crate::model::AllocateQuotaResponse::allocate_errors].
5498    pub fn set_allocate_errors<T, V>(mut self, v: T) -> Self
5499    where
5500        T: std::iter::IntoIterator<Item = V>,
5501        V: std::convert::Into<crate::model::QuotaError>,
5502    {
5503        use std::iter::Iterator;
5504        self.allocate_errors = v.into_iter().map(|i| i.into()).collect();
5505        self
5506    }
5507
5508    /// Sets the value of [quota_metrics][crate::model::AllocateQuotaResponse::quota_metrics].
5509    pub fn set_quota_metrics<T, V>(mut self, v: T) -> Self
5510    where
5511        T: std::iter::IntoIterator<Item = V>,
5512        V: std::convert::Into<crate::model::MetricValueSet>,
5513    {
5514        use std::iter::Iterator;
5515        self.quota_metrics = v.into_iter().map(|i| i.into()).collect();
5516        self
5517    }
5518
5519    /// Sets the value of [service_config_id][crate::model::AllocateQuotaResponse::service_config_id].
5520    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
5521        mut self,
5522        v: T,
5523    ) -> Self {
5524        self.service_config_id = v.into();
5525        self
5526    }
5527}
5528
5529impl wkt::message::Message for AllocateQuotaResponse {
5530    fn typename() -> &'static str {
5531        "type.googleapis.com/google.api.servicecontrol.v1.AllocateQuotaResponse"
5532    }
5533}
5534
5535#[doc(hidden)]
5536impl<'de> serde::de::Deserialize<'de> for AllocateQuotaResponse {
5537    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5538    where
5539        D: serde::Deserializer<'de>,
5540    {
5541        #[allow(non_camel_case_types)]
5542        #[doc(hidden)]
5543        #[derive(PartialEq, Eq, Hash)]
5544        enum __FieldTag {
5545            __operation_id,
5546            __allocate_errors,
5547            __quota_metrics,
5548            __service_config_id,
5549            Unknown(std::string::String),
5550        }
5551        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5552            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5553            where
5554                D: serde::Deserializer<'de>,
5555            {
5556                struct Visitor;
5557                impl<'de> serde::de::Visitor<'de> for Visitor {
5558                    type Value = __FieldTag;
5559                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5560                        formatter.write_str("a field name for AllocateQuotaResponse")
5561                    }
5562                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5563                    where
5564                        E: serde::de::Error,
5565                    {
5566                        use std::result::Result::Ok;
5567                        use std::string::ToString;
5568                        match value {
5569                            "operationId" => Ok(__FieldTag::__operation_id),
5570                            "operation_id" => Ok(__FieldTag::__operation_id),
5571                            "allocateErrors" => Ok(__FieldTag::__allocate_errors),
5572                            "allocate_errors" => Ok(__FieldTag::__allocate_errors),
5573                            "quotaMetrics" => Ok(__FieldTag::__quota_metrics),
5574                            "quota_metrics" => Ok(__FieldTag::__quota_metrics),
5575                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
5576                            "service_config_id" => Ok(__FieldTag::__service_config_id),
5577                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5578                        }
5579                    }
5580                }
5581                deserializer.deserialize_identifier(Visitor)
5582            }
5583        }
5584        struct Visitor;
5585        impl<'de> serde::de::Visitor<'de> for Visitor {
5586            type Value = AllocateQuotaResponse;
5587            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5588                formatter.write_str("struct AllocateQuotaResponse")
5589            }
5590            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5591            where
5592                A: serde::de::MapAccess<'de>,
5593            {
5594                #[allow(unused_imports)]
5595                use serde::de::Error;
5596                use std::option::Option::Some;
5597                let mut fields = std::collections::HashSet::new();
5598                let mut result = Self::Value::new();
5599                while let Some(tag) = map.next_key::<__FieldTag>()? {
5600                    #[allow(clippy::match_single_binding)]
5601                    match tag {
5602                        __FieldTag::__operation_id => {
5603                            if !fields.insert(__FieldTag::__operation_id) {
5604                                return std::result::Result::Err(A::Error::duplicate_field(
5605                                    "multiple values for operation_id",
5606                                ));
5607                            }
5608                            result.operation_id = map
5609                                .next_value::<std::option::Option<std::string::String>>()?
5610                                .unwrap_or_default();
5611                        }
5612                        __FieldTag::__allocate_errors => {
5613                            if !fields.insert(__FieldTag::__allocate_errors) {
5614                                return std::result::Result::Err(A::Error::duplicate_field(
5615                                    "multiple values for allocate_errors",
5616                                ));
5617                            }
5618                            result.allocate_errors = map.next_value::<std::option::Option<std::vec::Vec<crate::model::QuotaError>>>()?.unwrap_or_default();
5619                        }
5620                        __FieldTag::__quota_metrics => {
5621                            if !fields.insert(__FieldTag::__quota_metrics) {
5622                                return std::result::Result::Err(A::Error::duplicate_field(
5623                                    "multiple values for quota_metrics",
5624                                ));
5625                            }
5626                            result.quota_metrics =
5627                                map.next_value::<std::option::Option<
5628                                    std::vec::Vec<crate::model::MetricValueSet>,
5629                                >>()?
5630                                .unwrap_or_default();
5631                        }
5632                        __FieldTag::__service_config_id => {
5633                            if !fields.insert(__FieldTag::__service_config_id) {
5634                                return std::result::Result::Err(A::Error::duplicate_field(
5635                                    "multiple values for service_config_id",
5636                                ));
5637                            }
5638                            result.service_config_id = map
5639                                .next_value::<std::option::Option<std::string::String>>()?
5640                                .unwrap_or_default();
5641                        }
5642                        __FieldTag::Unknown(key) => {
5643                            let value = map.next_value::<serde_json::Value>()?;
5644                            result._unknown_fields.insert(key, value);
5645                        }
5646                    }
5647                }
5648                std::result::Result::Ok(result)
5649            }
5650        }
5651        deserializer.deserialize_any(Visitor)
5652    }
5653}
5654
5655#[doc(hidden)]
5656impl serde::ser::Serialize for AllocateQuotaResponse {
5657    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5658    where
5659        S: serde::ser::Serializer,
5660    {
5661        use serde::ser::SerializeMap;
5662        #[allow(unused_imports)]
5663        use std::option::Option::Some;
5664        let mut state = serializer.serialize_map(std::option::Option::None)?;
5665        if !self.operation_id.is_empty() {
5666            state.serialize_entry("operationId", &self.operation_id)?;
5667        }
5668        if !self.allocate_errors.is_empty() {
5669            state.serialize_entry("allocateErrors", &self.allocate_errors)?;
5670        }
5671        if !self.quota_metrics.is_empty() {
5672            state.serialize_entry("quotaMetrics", &self.quota_metrics)?;
5673        }
5674        if !self.service_config_id.is_empty() {
5675            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
5676        }
5677        if !self._unknown_fields.is_empty() {
5678            for (key, value) in self._unknown_fields.iter() {
5679                state.serialize_entry(key, &value)?;
5680            }
5681        }
5682        state.end()
5683    }
5684}
5685
5686/// Represents error information for [QuotaOperation][google.api.servicecontrol.v1.QuotaOperation].
5687///
5688/// [google.api.servicecontrol.v1.QuotaOperation]: crate::model::QuotaOperation
5689#[derive(Clone, Debug, Default, PartialEq)]
5690#[non_exhaustive]
5691pub struct QuotaError {
5692    /// Error code.
5693    pub code: crate::model::quota_error::Code,
5694
5695    /// Subject to whom this error applies. See the specific enum for more details
5696    /// on this field. For example, "clientip:\<ip address of client\>" or
5697    /// "project:\<Google developer project id\>".
5698    pub subject: std::string::String,
5699
5700    /// Free-form text that provides details on the cause of the error.
5701    pub description: std::string::String,
5702
5703    /// Contains additional information about the quota error.
5704    /// If available, `status.code` will be non zero.
5705    pub status: std::option::Option<rpc::model::Status>,
5706
5707    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5708}
5709
5710impl QuotaError {
5711    pub fn new() -> Self {
5712        std::default::Default::default()
5713    }
5714
5715    /// Sets the value of [code][crate::model::QuotaError::code].
5716    pub fn set_code<T: std::convert::Into<crate::model::quota_error::Code>>(
5717        mut self,
5718        v: T,
5719    ) -> Self {
5720        self.code = v.into();
5721        self
5722    }
5723
5724    /// Sets the value of [subject][crate::model::QuotaError::subject].
5725    pub fn set_subject<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5726        self.subject = v.into();
5727        self
5728    }
5729
5730    /// Sets the value of [description][crate::model::QuotaError::description].
5731    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5732        self.description = v.into();
5733        self
5734    }
5735
5736    /// Sets the value of [status][crate::model::QuotaError::status].
5737    pub fn set_status<T>(mut self, v: T) -> Self
5738    where
5739        T: std::convert::Into<rpc::model::Status>,
5740    {
5741        self.status = std::option::Option::Some(v.into());
5742        self
5743    }
5744
5745    /// Sets or clears the value of [status][crate::model::QuotaError::status].
5746    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
5747    where
5748        T: std::convert::Into<rpc::model::Status>,
5749    {
5750        self.status = v.map(|x| x.into());
5751        self
5752    }
5753}
5754
5755impl wkt::message::Message for QuotaError {
5756    fn typename() -> &'static str {
5757        "type.googleapis.com/google.api.servicecontrol.v1.QuotaError"
5758    }
5759}
5760
5761#[doc(hidden)]
5762impl<'de> serde::de::Deserialize<'de> for QuotaError {
5763    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5764    where
5765        D: serde::Deserializer<'de>,
5766    {
5767        #[allow(non_camel_case_types)]
5768        #[doc(hidden)]
5769        #[derive(PartialEq, Eq, Hash)]
5770        enum __FieldTag {
5771            __code,
5772            __subject,
5773            __description,
5774            __status,
5775            Unknown(std::string::String),
5776        }
5777        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
5778            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5779            where
5780                D: serde::Deserializer<'de>,
5781            {
5782                struct Visitor;
5783                impl<'de> serde::de::Visitor<'de> for Visitor {
5784                    type Value = __FieldTag;
5785                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5786                        formatter.write_str("a field name for QuotaError")
5787                    }
5788                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
5789                    where
5790                        E: serde::de::Error,
5791                    {
5792                        use std::result::Result::Ok;
5793                        use std::string::ToString;
5794                        match value {
5795                            "code" => Ok(__FieldTag::__code),
5796                            "subject" => Ok(__FieldTag::__subject),
5797                            "description" => Ok(__FieldTag::__description),
5798                            "status" => Ok(__FieldTag::__status),
5799                            _ => Ok(__FieldTag::Unknown(value.to_string())),
5800                        }
5801                    }
5802                }
5803                deserializer.deserialize_identifier(Visitor)
5804            }
5805        }
5806        struct Visitor;
5807        impl<'de> serde::de::Visitor<'de> for Visitor {
5808            type Value = QuotaError;
5809            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
5810                formatter.write_str("struct QuotaError")
5811            }
5812            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
5813            where
5814                A: serde::de::MapAccess<'de>,
5815            {
5816                #[allow(unused_imports)]
5817                use serde::de::Error;
5818                use std::option::Option::Some;
5819                let mut fields = std::collections::HashSet::new();
5820                let mut result = Self::Value::new();
5821                while let Some(tag) = map.next_key::<__FieldTag>()? {
5822                    #[allow(clippy::match_single_binding)]
5823                    match tag {
5824                        __FieldTag::__code => {
5825                            if !fields.insert(__FieldTag::__code) {
5826                                return std::result::Result::Err(A::Error::duplicate_field(
5827                                    "multiple values for code",
5828                                ));
5829                            }
5830                            result.code = map
5831                                .next_value::<std::option::Option<crate::model::quota_error::Code>>(
5832                                )?
5833                                .unwrap_or_default();
5834                        }
5835                        __FieldTag::__subject => {
5836                            if !fields.insert(__FieldTag::__subject) {
5837                                return std::result::Result::Err(A::Error::duplicate_field(
5838                                    "multiple values for subject",
5839                                ));
5840                            }
5841                            result.subject = map
5842                                .next_value::<std::option::Option<std::string::String>>()?
5843                                .unwrap_or_default();
5844                        }
5845                        __FieldTag::__description => {
5846                            if !fields.insert(__FieldTag::__description) {
5847                                return std::result::Result::Err(A::Error::duplicate_field(
5848                                    "multiple values for description",
5849                                ));
5850                            }
5851                            result.description = map
5852                                .next_value::<std::option::Option<std::string::String>>()?
5853                                .unwrap_or_default();
5854                        }
5855                        __FieldTag::__status => {
5856                            if !fields.insert(__FieldTag::__status) {
5857                                return std::result::Result::Err(A::Error::duplicate_field(
5858                                    "multiple values for status",
5859                                ));
5860                            }
5861                            result.status =
5862                                map.next_value::<std::option::Option<rpc::model::Status>>()?;
5863                        }
5864                        __FieldTag::Unknown(key) => {
5865                            let value = map.next_value::<serde_json::Value>()?;
5866                            result._unknown_fields.insert(key, value);
5867                        }
5868                    }
5869                }
5870                std::result::Result::Ok(result)
5871            }
5872        }
5873        deserializer.deserialize_any(Visitor)
5874    }
5875}
5876
5877#[doc(hidden)]
5878impl serde::ser::Serialize for QuotaError {
5879    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5880    where
5881        S: serde::ser::Serializer,
5882    {
5883        use serde::ser::SerializeMap;
5884        #[allow(unused_imports)]
5885        use std::option::Option::Some;
5886        let mut state = serializer.serialize_map(std::option::Option::None)?;
5887        if !wkt::internal::is_default(&self.code) {
5888            state.serialize_entry("code", &self.code)?;
5889        }
5890        if !self.subject.is_empty() {
5891            state.serialize_entry("subject", &self.subject)?;
5892        }
5893        if !self.description.is_empty() {
5894            state.serialize_entry("description", &self.description)?;
5895        }
5896        if self.status.is_some() {
5897            state.serialize_entry("status", &self.status)?;
5898        }
5899        if !self._unknown_fields.is_empty() {
5900            for (key, value) in self._unknown_fields.iter() {
5901                state.serialize_entry(key, &value)?;
5902            }
5903        }
5904        state.end()
5905    }
5906}
5907
5908/// Defines additional types related to [QuotaError].
5909pub mod quota_error {
5910    #[allow(unused_imports)]
5911    use super::*;
5912
5913    /// Error codes related to project config validations are deprecated since the
5914    /// quota controller methods do not perform these validations. Instead services
5915    /// have to call the Check method, without quota_properties field, to perform
5916    /// these validations before calling the quota controller methods. These
5917    /// methods check only for project deletion to be wipe out compliant.
5918    ///
5919    /// # Working with unknown values
5920    ///
5921    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5922    /// additional enum variants at any time. Adding new variants is not considered
5923    /// a breaking change. Applications should write their code in anticipation of:
5924    ///
5925    /// - New values appearing in future releases of the client library, **and**
5926    /// - New values received dynamically, without application changes.
5927    ///
5928    /// Please consult the [Working with enums] section in the user guide for some
5929    /// guidelines.
5930    ///
5931    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
5932    #[derive(Clone, Debug, PartialEq)]
5933    #[non_exhaustive]
5934    pub enum Code {
5935        /// This is never used.
5936        Unspecified,
5937        /// Quota allocation failed.
5938        /// Same as [google.rpc.Code.RESOURCE_EXHAUSTED][google.rpc.Code.RESOURCE_EXHAUSTED].
5939        ResourceExhausted,
5940        /// Consumer cannot access the service because the service requires active
5941        /// billing.
5942        BillingNotActive,
5943        /// Consumer's project has been marked as deleted (soft deletion).
5944        ProjectDeleted,
5945        /// Specified API key is invalid.
5946        ApiKeyInvalid,
5947        /// Specified API Key has expired.
5948        ApiKeyExpired,
5949        /// If set, the enum was initialized with an unknown value.
5950        ///
5951        /// Applications can examine the value using [Code::value] or
5952        /// [Code::name].
5953        UnknownValue(code::UnknownValue),
5954    }
5955
5956    #[doc(hidden)]
5957    pub mod code {
5958        #[allow(unused_imports)]
5959        use super::*;
5960        #[derive(Clone, Debug, PartialEq)]
5961        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5962    }
5963
5964    impl Code {
5965        /// Gets the enum value.
5966        ///
5967        /// Returns `None` if the enum contains an unknown value deserialized from
5968        /// the string representation of enums.
5969        pub fn value(&self) -> std::option::Option<i32> {
5970            match self {
5971                Self::Unspecified => std::option::Option::Some(0),
5972                Self::ResourceExhausted => std::option::Option::Some(8),
5973                Self::BillingNotActive => std::option::Option::Some(107),
5974                Self::ProjectDeleted => std::option::Option::Some(108),
5975                Self::ApiKeyInvalid => std::option::Option::Some(105),
5976                Self::ApiKeyExpired => std::option::Option::Some(112),
5977                Self::UnknownValue(u) => u.0.value(),
5978            }
5979        }
5980
5981        /// Gets the enum value as a string.
5982        ///
5983        /// Returns `None` if the enum contains an unknown value deserialized from
5984        /// the integer representation of enums.
5985        pub fn name(&self) -> std::option::Option<&str> {
5986            match self {
5987                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
5988                Self::ResourceExhausted => std::option::Option::Some("RESOURCE_EXHAUSTED"),
5989                Self::BillingNotActive => std::option::Option::Some("BILLING_NOT_ACTIVE"),
5990                Self::ProjectDeleted => std::option::Option::Some("PROJECT_DELETED"),
5991                Self::ApiKeyInvalid => std::option::Option::Some("API_KEY_INVALID"),
5992                Self::ApiKeyExpired => std::option::Option::Some("API_KEY_EXPIRED"),
5993                Self::UnknownValue(u) => u.0.name(),
5994            }
5995        }
5996    }
5997
5998    impl std::default::Default for Code {
5999        fn default() -> Self {
6000            use std::convert::From;
6001            Self::from(0)
6002        }
6003    }
6004
6005    impl std::fmt::Display for Code {
6006        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6007            wkt::internal::display_enum(f, self.name(), self.value())
6008        }
6009    }
6010
6011    impl std::convert::From<i32> for Code {
6012        fn from(value: i32) -> Self {
6013            match value {
6014                0 => Self::Unspecified,
6015                8 => Self::ResourceExhausted,
6016                105 => Self::ApiKeyInvalid,
6017                107 => Self::BillingNotActive,
6018                108 => Self::ProjectDeleted,
6019                112 => Self::ApiKeyExpired,
6020                _ => Self::UnknownValue(code::UnknownValue(
6021                    wkt::internal::UnknownEnumValue::Integer(value),
6022                )),
6023            }
6024        }
6025    }
6026
6027    impl std::convert::From<&str> for Code {
6028        fn from(value: &str) -> Self {
6029            use std::string::ToString;
6030            match value {
6031                "UNSPECIFIED" => Self::Unspecified,
6032                "RESOURCE_EXHAUSTED" => Self::ResourceExhausted,
6033                "BILLING_NOT_ACTIVE" => Self::BillingNotActive,
6034                "PROJECT_DELETED" => Self::ProjectDeleted,
6035                "API_KEY_INVALID" => Self::ApiKeyInvalid,
6036                "API_KEY_EXPIRED" => Self::ApiKeyExpired,
6037                _ => Self::UnknownValue(code::UnknownValue(
6038                    wkt::internal::UnknownEnumValue::String(value.to_string()),
6039                )),
6040            }
6041        }
6042    }
6043
6044    impl serde::ser::Serialize for Code {
6045        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6046        where
6047            S: serde::Serializer,
6048        {
6049            match self {
6050                Self::Unspecified => serializer.serialize_i32(0),
6051                Self::ResourceExhausted => serializer.serialize_i32(8),
6052                Self::BillingNotActive => serializer.serialize_i32(107),
6053                Self::ProjectDeleted => serializer.serialize_i32(108),
6054                Self::ApiKeyInvalid => serializer.serialize_i32(105),
6055                Self::ApiKeyExpired => serializer.serialize_i32(112),
6056                Self::UnknownValue(u) => u.0.serialize(serializer),
6057            }
6058        }
6059    }
6060
6061    impl<'de> serde::de::Deserialize<'de> for Code {
6062        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6063        where
6064            D: serde::Deserializer<'de>,
6065        {
6066            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Code>::new(
6067                ".google.api.servicecontrol.v1.QuotaError.Code",
6068            ))
6069        }
6070    }
6071}
6072
6073/// Request message for the Check method.
6074#[derive(Clone, Debug, Default, PartialEq)]
6075#[non_exhaustive]
6076pub struct CheckRequest {
6077    /// The service name as specified in its service configuration. For example,
6078    /// `"pubsub.googleapis.com"`.
6079    ///
6080    /// See
6081    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
6082    /// for the definition of a service name.
6083    pub service_name: std::string::String,
6084
6085    /// The operation to be checked.
6086    pub operation: std::option::Option<crate::model::Operation>,
6087
6088    /// Specifies which version of service configuration should be used to process
6089    /// the request.
6090    ///
6091    /// If unspecified or no matching version can be found, the
6092    /// latest one will be used.
6093    pub service_config_id: std::string::String,
6094
6095    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6096}
6097
6098impl CheckRequest {
6099    pub fn new() -> Self {
6100        std::default::Default::default()
6101    }
6102
6103    /// Sets the value of [service_name][crate::model::CheckRequest::service_name].
6104    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6105        self.service_name = v.into();
6106        self
6107    }
6108
6109    /// Sets the value of [operation][crate::model::CheckRequest::operation].
6110    pub fn set_operation<T>(mut self, v: T) -> Self
6111    where
6112        T: std::convert::Into<crate::model::Operation>,
6113    {
6114        self.operation = std::option::Option::Some(v.into());
6115        self
6116    }
6117
6118    /// Sets or clears the value of [operation][crate::model::CheckRequest::operation].
6119    pub fn set_or_clear_operation<T>(mut self, v: std::option::Option<T>) -> Self
6120    where
6121        T: std::convert::Into<crate::model::Operation>,
6122    {
6123        self.operation = v.map(|x| x.into());
6124        self
6125    }
6126
6127    /// Sets the value of [service_config_id][crate::model::CheckRequest::service_config_id].
6128    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
6129        mut self,
6130        v: T,
6131    ) -> Self {
6132        self.service_config_id = v.into();
6133        self
6134    }
6135}
6136
6137impl wkt::message::Message for CheckRequest {
6138    fn typename() -> &'static str {
6139        "type.googleapis.com/google.api.servicecontrol.v1.CheckRequest"
6140    }
6141}
6142
6143#[doc(hidden)]
6144impl<'de> serde::de::Deserialize<'de> for CheckRequest {
6145    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6146    where
6147        D: serde::Deserializer<'de>,
6148    {
6149        #[allow(non_camel_case_types)]
6150        #[doc(hidden)]
6151        #[derive(PartialEq, Eq, Hash)]
6152        enum __FieldTag {
6153            __service_name,
6154            __operation,
6155            __service_config_id,
6156            Unknown(std::string::String),
6157        }
6158        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6159            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6160            where
6161                D: serde::Deserializer<'de>,
6162            {
6163                struct Visitor;
6164                impl<'de> serde::de::Visitor<'de> for Visitor {
6165                    type Value = __FieldTag;
6166                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6167                        formatter.write_str("a field name for CheckRequest")
6168                    }
6169                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6170                    where
6171                        E: serde::de::Error,
6172                    {
6173                        use std::result::Result::Ok;
6174                        use std::string::ToString;
6175                        match value {
6176                            "serviceName" => Ok(__FieldTag::__service_name),
6177                            "service_name" => Ok(__FieldTag::__service_name),
6178                            "operation" => Ok(__FieldTag::__operation),
6179                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
6180                            "service_config_id" => Ok(__FieldTag::__service_config_id),
6181                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6182                        }
6183                    }
6184                }
6185                deserializer.deserialize_identifier(Visitor)
6186            }
6187        }
6188        struct Visitor;
6189        impl<'de> serde::de::Visitor<'de> for Visitor {
6190            type Value = CheckRequest;
6191            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6192                formatter.write_str("struct CheckRequest")
6193            }
6194            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6195            where
6196                A: serde::de::MapAccess<'de>,
6197            {
6198                #[allow(unused_imports)]
6199                use serde::de::Error;
6200                use std::option::Option::Some;
6201                let mut fields = std::collections::HashSet::new();
6202                let mut result = Self::Value::new();
6203                while let Some(tag) = map.next_key::<__FieldTag>()? {
6204                    #[allow(clippy::match_single_binding)]
6205                    match tag {
6206                        __FieldTag::__service_name => {
6207                            if !fields.insert(__FieldTag::__service_name) {
6208                                return std::result::Result::Err(A::Error::duplicate_field(
6209                                    "multiple values for service_name",
6210                                ));
6211                            }
6212                            result.service_name = map
6213                                .next_value::<std::option::Option<std::string::String>>()?
6214                                .unwrap_or_default();
6215                        }
6216                        __FieldTag::__operation => {
6217                            if !fields.insert(__FieldTag::__operation) {
6218                                return std::result::Result::Err(A::Error::duplicate_field(
6219                                    "multiple values for operation",
6220                                ));
6221                            }
6222                            result.operation =
6223                                map.next_value::<std::option::Option<crate::model::Operation>>()?;
6224                        }
6225                        __FieldTag::__service_config_id => {
6226                            if !fields.insert(__FieldTag::__service_config_id) {
6227                                return std::result::Result::Err(A::Error::duplicate_field(
6228                                    "multiple values for service_config_id",
6229                                ));
6230                            }
6231                            result.service_config_id = map
6232                                .next_value::<std::option::Option<std::string::String>>()?
6233                                .unwrap_or_default();
6234                        }
6235                        __FieldTag::Unknown(key) => {
6236                            let value = map.next_value::<serde_json::Value>()?;
6237                            result._unknown_fields.insert(key, value);
6238                        }
6239                    }
6240                }
6241                std::result::Result::Ok(result)
6242            }
6243        }
6244        deserializer.deserialize_any(Visitor)
6245    }
6246}
6247
6248#[doc(hidden)]
6249impl serde::ser::Serialize for CheckRequest {
6250    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6251    where
6252        S: serde::ser::Serializer,
6253    {
6254        use serde::ser::SerializeMap;
6255        #[allow(unused_imports)]
6256        use std::option::Option::Some;
6257        let mut state = serializer.serialize_map(std::option::Option::None)?;
6258        if !self.service_name.is_empty() {
6259            state.serialize_entry("serviceName", &self.service_name)?;
6260        }
6261        if self.operation.is_some() {
6262            state.serialize_entry("operation", &self.operation)?;
6263        }
6264        if !self.service_config_id.is_empty() {
6265            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
6266        }
6267        if !self._unknown_fields.is_empty() {
6268            for (key, value) in self._unknown_fields.iter() {
6269                state.serialize_entry(key, &value)?;
6270            }
6271        }
6272        state.end()
6273    }
6274}
6275
6276/// Response message for the Check method.
6277#[derive(Clone, Debug, Default, PartialEq)]
6278#[non_exhaustive]
6279pub struct CheckResponse {
6280    /// The same operation_id value used in the
6281    /// [CheckRequest][google.api.servicecontrol.v1.CheckRequest]. Used for logging
6282    /// and diagnostics purposes.
6283    ///
6284    /// [google.api.servicecontrol.v1.CheckRequest]: crate::model::CheckRequest
6285    pub operation_id: std::string::String,
6286
6287    /// Indicate the decision of the check.
6288    ///
6289    /// If no check errors are present, the service should process the operation.
6290    /// Otherwise the service should use the list of errors to determine the
6291    /// appropriate action.
6292    pub check_errors: std::vec::Vec<crate::model::CheckError>,
6293
6294    /// The actual config id used to process the request.
6295    pub service_config_id: std::string::String,
6296
6297    /// The current service rollout id used to process the request.
6298    pub service_rollout_id: std::string::String,
6299
6300    /// Feedback data returned from the server during processing a Check request.
6301    pub check_info: std::option::Option<crate::model::check_response::CheckInfo>,
6302
6303    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6304}
6305
6306impl CheckResponse {
6307    pub fn new() -> Self {
6308        std::default::Default::default()
6309    }
6310
6311    /// Sets the value of [operation_id][crate::model::CheckResponse::operation_id].
6312    pub fn set_operation_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6313        self.operation_id = v.into();
6314        self
6315    }
6316
6317    /// Sets the value of [check_errors][crate::model::CheckResponse::check_errors].
6318    pub fn set_check_errors<T, V>(mut self, v: T) -> Self
6319    where
6320        T: std::iter::IntoIterator<Item = V>,
6321        V: std::convert::Into<crate::model::CheckError>,
6322    {
6323        use std::iter::Iterator;
6324        self.check_errors = v.into_iter().map(|i| i.into()).collect();
6325        self
6326    }
6327
6328    /// Sets the value of [service_config_id][crate::model::CheckResponse::service_config_id].
6329    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
6330        mut self,
6331        v: T,
6332    ) -> Self {
6333        self.service_config_id = v.into();
6334        self
6335    }
6336
6337    /// Sets the value of [service_rollout_id][crate::model::CheckResponse::service_rollout_id].
6338    pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
6339        mut self,
6340        v: T,
6341    ) -> Self {
6342        self.service_rollout_id = v.into();
6343        self
6344    }
6345
6346    /// Sets the value of [check_info][crate::model::CheckResponse::check_info].
6347    pub fn set_check_info<T>(mut self, v: T) -> Self
6348    where
6349        T: std::convert::Into<crate::model::check_response::CheckInfo>,
6350    {
6351        self.check_info = std::option::Option::Some(v.into());
6352        self
6353    }
6354
6355    /// Sets or clears the value of [check_info][crate::model::CheckResponse::check_info].
6356    pub fn set_or_clear_check_info<T>(mut self, v: std::option::Option<T>) -> Self
6357    where
6358        T: std::convert::Into<crate::model::check_response::CheckInfo>,
6359    {
6360        self.check_info = v.map(|x| x.into());
6361        self
6362    }
6363}
6364
6365impl wkt::message::Message for CheckResponse {
6366    fn typename() -> &'static str {
6367        "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse"
6368    }
6369}
6370
6371#[doc(hidden)]
6372impl<'de> serde::de::Deserialize<'de> for CheckResponse {
6373    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6374    where
6375        D: serde::Deserializer<'de>,
6376    {
6377        #[allow(non_camel_case_types)]
6378        #[doc(hidden)]
6379        #[derive(PartialEq, Eq, Hash)]
6380        enum __FieldTag {
6381            __operation_id,
6382            __check_errors,
6383            __service_config_id,
6384            __service_rollout_id,
6385            __check_info,
6386            Unknown(std::string::String),
6387        }
6388        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6389            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6390            where
6391                D: serde::Deserializer<'de>,
6392            {
6393                struct Visitor;
6394                impl<'de> serde::de::Visitor<'de> for Visitor {
6395                    type Value = __FieldTag;
6396                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6397                        formatter.write_str("a field name for CheckResponse")
6398                    }
6399                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6400                    where
6401                        E: serde::de::Error,
6402                    {
6403                        use std::result::Result::Ok;
6404                        use std::string::ToString;
6405                        match value {
6406                            "operationId" => Ok(__FieldTag::__operation_id),
6407                            "operation_id" => Ok(__FieldTag::__operation_id),
6408                            "checkErrors" => Ok(__FieldTag::__check_errors),
6409                            "check_errors" => Ok(__FieldTag::__check_errors),
6410                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
6411                            "service_config_id" => Ok(__FieldTag::__service_config_id),
6412                            "serviceRolloutId" => Ok(__FieldTag::__service_rollout_id),
6413                            "service_rollout_id" => Ok(__FieldTag::__service_rollout_id),
6414                            "checkInfo" => Ok(__FieldTag::__check_info),
6415                            "check_info" => Ok(__FieldTag::__check_info),
6416                            _ => Ok(__FieldTag::Unknown(value.to_string())),
6417                        }
6418                    }
6419                }
6420                deserializer.deserialize_identifier(Visitor)
6421            }
6422        }
6423        struct Visitor;
6424        impl<'de> serde::de::Visitor<'de> for Visitor {
6425            type Value = CheckResponse;
6426            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6427                formatter.write_str("struct CheckResponse")
6428            }
6429            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6430            where
6431                A: serde::de::MapAccess<'de>,
6432            {
6433                #[allow(unused_imports)]
6434                use serde::de::Error;
6435                use std::option::Option::Some;
6436                let mut fields = std::collections::HashSet::new();
6437                let mut result = Self::Value::new();
6438                while let Some(tag) = map.next_key::<__FieldTag>()? {
6439                    #[allow(clippy::match_single_binding)]
6440                    match tag {
6441                        __FieldTag::__operation_id => {
6442                            if !fields.insert(__FieldTag::__operation_id) {
6443                                return std::result::Result::Err(A::Error::duplicate_field(
6444                                    "multiple values for operation_id",
6445                                ));
6446                            }
6447                            result.operation_id = map
6448                                .next_value::<std::option::Option<std::string::String>>()?
6449                                .unwrap_or_default();
6450                        }
6451                        __FieldTag::__check_errors => {
6452                            if !fields.insert(__FieldTag::__check_errors) {
6453                                return std::result::Result::Err(A::Error::duplicate_field(
6454                                    "multiple values for check_errors",
6455                                ));
6456                            }
6457                            result.check_errors = map.next_value::<std::option::Option<std::vec::Vec<crate::model::CheckError>>>()?.unwrap_or_default();
6458                        }
6459                        __FieldTag::__service_config_id => {
6460                            if !fields.insert(__FieldTag::__service_config_id) {
6461                                return std::result::Result::Err(A::Error::duplicate_field(
6462                                    "multiple values for service_config_id",
6463                                ));
6464                            }
6465                            result.service_config_id = map
6466                                .next_value::<std::option::Option<std::string::String>>()?
6467                                .unwrap_or_default();
6468                        }
6469                        __FieldTag::__service_rollout_id => {
6470                            if !fields.insert(__FieldTag::__service_rollout_id) {
6471                                return std::result::Result::Err(A::Error::duplicate_field(
6472                                    "multiple values for service_rollout_id",
6473                                ));
6474                            }
6475                            result.service_rollout_id = map
6476                                .next_value::<std::option::Option<std::string::String>>()?
6477                                .unwrap_or_default();
6478                        }
6479                        __FieldTag::__check_info => {
6480                            if !fields.insert(__FieldTag::__check_info) {
6481                                return std::result::Result::Err(A::Error::duplicate_field(
6482                                    "multiple values for check_info",
6483                                ));
6484                            }
6485                            result.check_info = map.next_value::<std::option::Option<crate::model::check_response::CheckInfo>>()?
6486                                ;
6487                        }
6488                        __FieldTag::Unknown(key) => {
6489                            let value = map.next_value::<serde_json::Value>()?;
6490                            result._unknown_fields.insert(key, value);
6491                        }
6492                    }
6493                }
6494                std::result::Result::Ok(result)
6495            }
6496        }
6497        deserializer.deserialize_any(Visitor)
6498    }
6499}
6500
6501#[doc(hidden)]
6502impl serde::ser::Serialize for CheckResponse {
6503    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6504    where
6505        S: serde::ser::Serializer,
6506    {
6507        use serde::ser::SerializeMap;
6508        #[allow(unused_imports)]
6509        use std::option::Option::Some;
6510        let mut state = serializer.serialize_map(std::option::Option::None)?;
6511        if !self.operation_id.is_empty() {
6512            state.serialize_entry("operationId", &self.operation_id)?;
6513        }
6514        if !self.check_errors.is_empty() {
6515            state.serialize_entry("checkErrors", &self.check_errors)?;
6516        }
6517        if !self.service_config_id.is_empty() {
6518            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
6519        }
6520        if !self.service_rollout_id.is_empty() {
6521            state.serialize_entry("serviceRolloutId", &self.service_rollout_id)?;
6522        }
6523        if self.check_info.is_some() {
6524            state.serialize_entry("checkInfo", &self.check_info)?;
6525        }
6526        if !self._unknown_fields.is_empty() {
6527            for (key, value) in self._unknown_fields.iter() {
6528                state.serialize_entry(key, &value)?;
6529            }
6530        }
6531        state.end()
6532    }
6533}
6534
6535/// Defines additional types related to [CheckResponse].
6536pub mod check_response {
6537    #[allow(unused_imports)]
6538    use super::*;
6539
6540    /// Contains additional information about the check operation.
6541    #[derive(Clone, Debug, Default, PartialEq)]
6542    #[non_exhaustive]
6543    pub struct CheckInfo {
6544        /// A list of fields and label keys that are ignored by the server.
6545        /// The client doesn't need to send them for following requests to improve
6546        /// performance and allow better aggregation.
6547        pub unused_arguments: std::vec::Vec<std::string::String>,
6548
6549        /// Consumer info of this check.
6550        pub consumer_info: std::option::Option<crate::model::check_response::ConsumerInfo>,
6551
6552        /// The unique id of the api key in the format of "apikey:\<UID\>".
6553        /// This field will be populated when the consumer passed to Service Control
6554        /// is an API key and all the API key related validations are successful.
6555        pub api_key_uid: std::string::String,
6556
6557        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6558    }
6559
6560    impl CheckInfo {
6561        pub fn new() -> Self {
6562            std::default::Default::default()
6563        }
6564
6565        /// Sets the value of [unused_arguments][crate::model::check_response::CheckInfo::unused_arguments].
6566        pub fn set_unused_arguments<T, V>(mut self, v: T) -> Self
6567        where
6568            T: std::iter::IntoIterator<Item = V>,
6569            V: std::convert::Into<std::string::String>,
6570        {
6571            use std::iter::Iterator;
6572            self.unused_arguments = v.into_iter().map(|i| i.into()).collect();
6573            self
6574        }
6575
6576        /// Sets the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
6577        pub fn set_consumer_info<T>(mut self, v: T) -> Self
6578        where
6579            T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
6580        {
6581            self.consumer_info = std::option::Option::Some(v.into());
6582            self
6583        }
6584
6585        /// Sets or clears the value of [consumer_info][crate::model::check_response::CheckInfo::consumer_info].
6586        pub fn set_or_clear_consumer_info<T>(mut self, v: std::option::Option<T>) -> Self
6587        where
6588            T: std::convert::Into<crate::model::check_response::ConsumerInfo>,
6589        {
6590            self.consumer_info = v.map(|x| x.into());
6591            self
6592        }
6593
6594        /// Sets the value of [api_key_uid][crate::model::check_response::CheckInfo::api_key_uid].
6595        pub fn set_api_key_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6596            self.api_key_uid = v.into();
6597            self
6598        }
6599    }
6600
6601    impl wkt::message::Message for CheckInfo {
6602        fn typename() -> &'static str {
6603            "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.CheckInfo"
6604        }
6605    }
6606
6607    #[doc(hidden)]
6608    impl<'de> serde::de::Deserialize<'de> for CheckInfo {
6609        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6610        where
6611            D: serde::Deserializer<'de>,
6612        {
6613            #[allow(non_camel_case_types)]
6614            #[doc(hidden)]
6615            #[derive(PartialEq, Eq, Hash)]
6616            enum __FieldTag {
6617                __unused_arguments,
6618                __consumer_info,
6619                __api_key_uid,
6620                Unknown(std::string::String),
6621            }
6622            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6623                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6624                where
6625                    D: serde::Deserializer<'de>,
6626                {
6627                    struct Visitor;
6628                    impl<'de> serde::de::Visitor<'de> for Visitor {
6629                        type Value = __FieldTag;
6630                        fn expecting(
6631                            &self,
6632                            formatter: &mut std::fmt::Formatter,
6633                        ) -> std::fmt::Result {
6634                            formatter.write_str("a field name for CheckInfo")
6635                        }
6636                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6637                        where
6638                            E: serde::de::Error,
6639                        {
6640                            use std::result::Result::Ok;
6641                            use std::string::ToString;
6642                            match value {
6643                                "unusedArguments" => Ok(__FieldTag::__unused_arguments),
6644                                "unused_arguments" => Ok(__FieldTag::__unused_arguments),
6645                                "consumerInfo" => Ok(__FieldTag::__consumer_info),
6646                                "consumer_info" => Ok(__FieldTag::__consumer_info),
6647                                "apiKeyUid" => Ok(__FieldTag::__api_key_uid),
6648                                "api_key_uid" => Ok(__FieldTag::__api_key_uid),
6649                                _ => Ok(__FieldTag::Unknown(value.to_string())),
6650                            }
6651                        }
6652                    }
6653                    deserializer.deserialize_identifier(Visitor)
6654                }
6655            }
6656            struct Visitor;
6657            impl<'de> serde::de::Visitor<'de> for Visitor {
6658                type Value = CheckInfo;
6659                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6660                    formatter.write_str("struct CheckInfo")
6661                }
6662                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6663                where
6664                    A: serde::de::MapAccess<'de>,
6665                {
6666                    #[allow(unused_imports)]
6667                    use serde::de::Error;
6668                    use std::option::Option::Some;
6669                    let mut fields = std::collections::HashSet::new();
6670                    let mut result = Self::Value::new();
6671                    while let Some(tag) = map.next_key::<__FieldTag>()? {
6672                        #[allow(clippy::match_single_binding)]
6673                        match tag {
6674                            __FieldTag::__unused_arguments => {
6675                                if !fields.insert(__FieldTag::__unused_arguments) {
6676                                    return std::result::Result::Err(A::Error::duplicate_field(
6677                                        "multiple values for unused_arguments",
6678                                    ));
6679                                }
6680                                result.unused_arguments = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
6681                            }
6682                            __FieldTag::__consumer_info => {
6683                                if !fields.insert(__FieldTag::__consumer_info) {
6684                                    return std::result::Result::Err(A::Error::duplicate_field(
6685                                        "multiple values for consumer_info",
6686                                    ));
6687                                }
6688                                result.consumer_info = map.next_value::<std::option::Option<
6689                                    crate::model::check_response::ConsumerInfo,
6690                                >>()?;
6691                            }
6692                            __FieldTag::__api_key_uid => {
6693                                if !fields.insert(__FieldTag::__api_key_uid) {
6694                                    return std::result::Result::Err(A::Error::duplicate_field(
6695                                        "multiple values for api_key_uid",
6696                                    ));
6697                                }
6698                                result.api_key_uid = map
6699                                    .next_value::<std::option::Option<std::string::String>>()?
6700                                    .unwrap_or_default();
6701                            }
6702                            __FieldTag::Unknown(key) => {
6703                                let value = map.next_value::<serde_json::Value>()?;
6704                                result._unknown_fields.insert(key, value);
6705                            }
6706                        }
6707                    }
6708                    std::result::Result::Ok(result)
6709                }
6710            }
6711            deserializer.deserialize_any(Visitor)
6712        }
6713    }
6714
6715    #[doc(hidden)]
6716    impl serde::ser::Serialize for CheckInfo {
6717        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6718        where
6719            S: serde::ser::Serializer,
6720        {
6721            use serde::ser::SerializeMap;
6722            #[allow(unused_imports)]
6723            use std::option::Option::Some;
6724            let mut state = serializer.serialize_map(std::option::Option::None)?;
6725            if !self.unused_arguments.is_empty() {
6726                state.serialize_entry("unusedArguments", &self.unused_arguments)?;
6727            }
6728            if self.consumer_info.is_some() {
6729                state.serialize_entry("consumerInfo", &self.consumer_info)?;
6730            }
6731            if !self.api_key_uid.is_empty() {
6732                state.serialize_entry("apiKeyUid", &self.api_key_uid)?;
6733            }
6734            if !self._unknown_fields.is_empty() {
6735                for (key, value) in self._unknown_fields.iter() {
6736                    state.serialize_entry(key, &value)?;
6737                }
6738            }
6739            state.end()
6740        }
6741    }
6742
6743    /// `ConsumerInfo` provides information about the consumer.
6744    #[derive(Clone, Debug, Default, PartialEq)]
6745    #[non_exhaustive]
6746    pub struct ConsumerInfo {
6747        /// The Google cloud project number, e.g. 1234567890. A value of 0 indicates
6748        /// no project number is found.
6749        ///
6750        /// NOTE: This field is deprecated after we support flexible consumer
6751        /// id. New code should not depend on this field anymore.
6752        pub project_number: i64,
6753
6754        /// The type of the consumer which should have been defined in
6755        /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
6756        pub r#type: crate::model::check_response::consumer_info::ConsumerType,
6757
6758        /// The consumer identity number, can be Google cloud project number, folder
6759        /// number or organization number e.g. 1234567890. A value of 0 indicates no
6760        /// consumer number is found.
6761        pub consumer_number: i64,
6762
6763        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6764    }
6765
6766    impl ConsumerInfo {
6767        pub fn new() -> Self {
6768            std::default::Default::default()
6769        }
6770
6771        /// Sets the value of [project_number][crate::model::check_response::ConsumerInfo::project_number].
6772        pub fn set_project_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6773            self.project_number = v.into();
6774            self
6775        }
6776
6777        /// Sets the value of [r#type][crate::model::check_response::ConsumerInfo::type].
6778        pub fn set_type<
6779            T: std::convert::Into<crate::model::check_response::consumer_info::ConsumerType>,
6780        >(
6781            mut self,
6782            v: T,
6783        ) -> Self {
6784            self.r#type = v.into();
6785            self
6786        }
6787
6788        /// Sets the value of [consumer_number][crate::model::check_response::ConsumerInfo::consumer_number].
6789        pub fn set_consumer_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6790            self.consumer_number = v.into();
6791            self
6792        }
6793    }
6794
6795    impl wkt::message::Message for ConsumerInfo {
6796        fn typename() -> &'static str {
6797            "type.googleapis.com/google.api.servicecontrol.v1.CheckResponse.ConsumerInfo"
6798        }
6799    }
6800
6801    #[doc(hidden)]
6802    impl<'de> serde::de::Deserialize<'de> for ConsumerInfo {
6803        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6804        where
6805            D: serde::Deserializer<'de>,
6806        {
6807            #[allow(non_camel_case_types)]
6808            #[doc(hidden)]
6809            #[derive(PartialEq, Eq, Hash)]
6810            enum __FieldTag {
6811                __project_number,
6812                __type,
6813                __consumer_number,
6814                Unknown(std::string::String),
6815            }
6816            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
6817                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6818                where
6819                    D: serde::Deserializer<'de>,
6820                {
6821                    struct Visitor;
6822                    impl<'de> serde::de::Visitor<'de> for Visitor {
6823                        type Value = __FieldTag;
6824                        fn expecting(
6825                            &self,
6826                            formatter: &mut std::fmt::Formatter,
6827                        ) -> std::fmt::Result {
6828                            formatter.write_str("a field name for ConsumerInfo")
6829                        }
6830                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
6831                        where
6832                            E: serde::de::Error,
6833                        {
6834                            use std::result::Result::Ok;
6835                            use std::string::ToString;
6836                            match value {
6837                                "projectNumber" => Ok(__FieldTag::__project_number),
6838                                "project_number" => Ok(__FieldTag::__project_number),
6839                                "type" => Ok(__FieldTag::__type),
6840                                "consumerNumber" => Ok(__FieldTag::__consumer_number),
6841                                "consumer_number" => Ok(__FieldTag::__consumer_number),
6842                                _ => Ok(__FieldTag::Unknown(value.to_string())),
6843                            }
6844                        }
6845                    }
6846                    deserializer.deserialize_identifier(Visitor)
6847                }
6848            }
6849            struct Visitor;
6850            impl<'de> serde::de::Visitor<'de> for Visitor {
6851                type Value = ConsumerInfo;
6852                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
6853                    formatter.write_str("struct ConsumerInfo")
6854                }
6855                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
6856                where
6857                    A: serde::de::MapAccess<'de>,
6858                {
6859                    #[allow(unused_imports)]
6860                    use serde::de::Error;
6861                    use std::option::Option::Some;
6862                    let mut fields = std::collections::HashSet::new();
6863                    let mut result = Self::Value::new();
6864                    while let Some(tag) = map.next_key::<__FieldTag>()? {
6865                        #[allow(clippy::match_single_binding)]
6866                        match tag {
6867                            __FieldTag::__project_number => {
6868                                if !fields.insert(__FieldTag::__project_number) {
6869                                    return std::result::Result::Err(A::Error::duplicate_field(
6870                                        "multiple values for project_number",
6871                                    ));
6872                                }
6873                                struct __With(std::option::Option<i64>);
6874                                impl<'de> serde::de::Deserialize<'de> for __With {
6875                                    fn deserialize<D>(
6876                                        deserializer: D,
6877                                    ) -> std::result::Result<Self, D::Error>
6878                                    where
6879                                        D: serde::de::Deserializer<'de>,
6880                                    {
6881                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
6882                                    }
6883                                }
6884                                result.project_number =
6885                                    map.next_value::<__With>()?.0.unwrap_or_default();
6886                            }
6887                            __FieldTag::__type => {
6888                                if !fields.insert(__FieldTag::__type) {
6889                                    return std::result::Result::Err(A::Error::duplicate_field(
6890                                        "multiple values for type",
6891                                    ));
6892                                }
6893                                result.r#type = map
6894                                    .next_value::<std::option::Option<
6895                                        crate::model::check_response::consumer_info::ConsumerType,
6896                                    >>()?
6897                                    .unwrap_or_default();
6898                            }
6899                            __FieldTag::__consumer_number => {
6900                                if !fields.insert(__FieldTag::__consumer_number) {
6901                                    return std::result::Result::Err(A::Error::duplicate_field(
6902                                        "multiple values for consumer_number",
6903                                    ));
6904                                }
6905                                struct __With(std::option::Option<i64>);
6906                                impl<'de> serde::de::Deserialize<'de> for __With {
6907                                    fn deserialize<D>(
6908                                        deserializer: D,
6909                                    ) -> std::result::Result<Self, D::Error>
6910                                    where
6911                                        D: serde::de::Deserializer<'de>,
6912                                    {
6913                                        serde_with::As::< std::option::Option<wkt::internal::I64> >::deserialize(deserializer).map(__With)
6914                                    }
6915                                }
6916                                result.consumer_number =
6917                                    map.next_value::<__With>()?.0.unwrap_or_default();
6918                            }
6919                            __FieldTag::Unknown(key) => {
6920                                let value = map.next_value::<serde_json::Value>()?;
6921                                result._unknown_fields.insert(key, value);
6922                            }
6923                        }
6924                    }
6925                    std::result::Result::Ok(result)
6926                }
6927            }
6928            deserializer.deserialize_any(Visitor)
6929        }
6930    }
6931
6932    #[doc(hidden)]
6933    impl serde::ser::Serialize for ConsumerInfo {
6934        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6935        where
6936            S: serde::ser::Serializer,
6937        {
6938            use serde::ser::SerializeMap;
6939            #[allow(unused_imports)]
6940            use std::option::Option::Some;
6941            let mut state = serializer.serialize_map(std::option::Option::None)?;
6942            if !wkt::internal::is_default(&self.project_number) {
6943                struct __With<'a>(&'a i64);
6944                impl<'a> serde::ser::Serialize for __With<'a> {
6945                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6946                    where
6947                        S: serde::ser::Serializer,
6948                    {
6949                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
6950                    }
6951                }
6952                state.serialize_entry("projectNumber", &__With(&self.project_number))?;
6953            }
6954            if !wkt::internal::is_default(&self.r#type) {
6955                state.serialize_entry("type", &self.r#type)?;
6956            }
6957            if !wkt::internal::is_default(&self.consumer_number) {
6958                struct __With<'a>(&'a i64);
6959                impl<'a> serde::ser::Serialize for __With<'a> {
6960                    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6961                    where
6962                        S: serde::ser::Serializer,
6963                    {
6964                        serde_with::As::<wkt::internal::I64>::serialize(self.0, serializer)
6965                    }
6966                }
6967                state.serialize_entry("consumerNumber", &__With(&self.consumer_number))?;
6968            }
6969            if !self._unknown_fields.is_empty() {
6970                for (key, value) in self._unknown_fields.iter() {
6971                    state.serialize_entry(key, &value)?;
6972                }
6973            }
6974            state.end()
6975        }
6976    }
6977
6978    /// Defines additional types related to [ConsumerInfo].
6979    pub mod consumer_info {
6980        #[allow(unused_imports)]
6981        use super::*;
6982
6983        /// The type of the consumer as defined in
6984        /// [Google Resource Manager](https://cloud.google.com/resource-manager/).
6985        ///
6986        /// # Working with unknown values
6987        ///
6988        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6989        /// additional enum variants at any time. Adding new variants is not considered
6990        /// a breaking change. Applications should write their code in anticipation of:
6991        ///
6992        /// - New values appearing in future releases of the client library, **and**
6993        /// - New values received dynamically, without application changes.
6994        ///
6995        /// Please consult the [Working with enums] section in the user guide for some
6996        /// guidelines.
6997        ///
6998        /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
6999        #[derive(Clone, Debug, PartialEq)]
7000        #[non_exhaustive]
7001        pub enum ConsumerType {
7002            /// This is never used.
7003            Unspecified,
7004            /// The consumer is a Google Cloud Project.
7005            Project,
7006            /// The consumer is a Google Cloud Folder.
7007            Folder,
7008            /// The consumer is a Google Cloud Organization.
7009            Organization,
7010            /// Service-specific resource container which is defined by the service
7011            /// producer to offer their users the ability to manage service control
7012            /// functionalities at a finer level of granularity than the PROJECT.
7013            ServiceSpecific,
7014            /// If set, the enum was initialized with an unknown value.
7015            ///
7016            /// Applications can examine the value using [ConsumerType::value] or
7017            /// [ConsumerType::name].
7018            UnknownValue(consumer_type::UnknownValue),
7019        }
7020
7021        #[doc(hidden)]
7022        pub mod consumer_type {
7023            #[allow(unused_imports)]
7024            use super::*;
7025            #[derive(Clone, Debug, PartialEq)]
7026            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7027        }
7028
7029        impl ConsumerType {
7030            /// Gets the enum value.
7031            ///
7032            /// Returns `None` if the enum contains an unknown value deserialized from
7033            /// the string representation of enums.
7034            pub fn value(&self) -> std::option::Option<i32> {
7035                match self {
7036                    Self::Unspecified => std::option::Option::Some(0),
7037                    Self::Project => std::option::Option::Some(1),
7038                    Self::Folder => std::option::Option::Some(2),
7039                    Self::Organization => std::option::Option::Some(3),
7040                    Self::ServiceSpecific => std::option::Option::Some(4),
7041                    Self::UnknownValue(u) => u.0.value(),
7042                }
7043            }
7044
7045            /// Gets the enum value as a string.
7046            ///
7047            /// Returns `None` if the enum contains an unknown value deserialized from
7048            /// the integer representation of enums.
7049            pub fn name(&self) -> std::option::Option<&str> {
7050                match self {
7051                    Self::Unspecified => std::option::Option::Some("CONSUMER_TYPE_UNSPECIFIED"),
7052                    Self::Project => std::option::Option::Some("PROJECT"),
7053                    Self::Folder => std::option::Option::Some("FOLDER"),
7054                    Self::Organization => std::option::Option::Some("ORGANIZATION"),
7055                    Self::ServiceSpecific => std::option::Option::Some("SERVICE_SPECIFIC"),
7056                    Self::UnknownValue(u) => u.0.name(),
7057                }
7058            }
7059        }
7060
7061        impl std::default::Default for ConsumerType {
7062            fn default() -> Self {
7063                use std::convert::From;
7064                Self::from(0)
7065            }
7066        }
7067
7068        impl std::fmt::Display for ConsumerType {
7069            fn fmt(
7070                &self,
7071                f: &mut std::fmt::Formatter<'_>,
7072            ) -> std::result::Result<(), std::fmt::Error> {
7073                wkt::internal::display_enum(f, self.name(), self.value())
7074            }
7075        }
7076
7077        impl std::convert::From<i32> for ConsumerType {
7078            fn from(value: i32) -> Self {
7079                match value {
7080                    0 => Self::Unspecified,
7081                    1 => Self::Project,
7082                    2 => Self::Folder,
7083                    3 => Self::Organization,
7084                    4 => Self::ServiceSpecific,
7085                    _ => Self::UnknownValue(consumer_type::UnknownValue(
7086                        wkt::internal::UnknownEnumValue::Integer(value),
7087                    )),
7088                }
7089            }
7090        }
7091
7092        impl std::convert::From<&str> for ConsumerType {
7093            fn from(value: &str) -> Self {
7094                use std::string::ToString;
7095                match value {
7096                    "CONSUMER_TYPE_UNSPECIFIED" => Self::Unspecified,
7097                    "PROJECT" => Self::Project,
7098                    "FOLDER" => Self::Folder,
7099                    "ORGANIZATION" => Self::Organization,
7100                    "SERVICE_SPECIFIC" => Self::ServiceSpecific,
7101                    _ => Self::UnknownValue(consumer_type::UnknownValue(
7102                        wkt::internal::UnknownEnumValue::String(value.to_string()),
7103                    )),
7104                }
7105            }
7106        }
7107
7108        impl serde::ser::Serialize for ConsumerType {
7109            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7110            where
7111                S: serde::Serializer,
7112            {
7113                match self {
7114                    Self::Unspecified => serializer.serialize_i32(0),
7115                    Self::Project => serializer.serialize_i32(1),
7116                    Self::Folder => serializer.serialize_i32(2),
7117                    Self::Organization => serializer.serialize_i32(3),
7118                    Self::ServiceSpecific => serializer.serialize_i32(4),
7119                    Self::UnknownValue(u) => u.0.serialize(serializer),
7120                }
7121            }
7122        }
7123
7124        impl<'de> serde::de::Deserialize<'de> for ConsumerType {
7125            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7126            where
7127                D: serde::Deserializer<'de>,
7128            {
7129                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConsumerType>::new(
7130                    ".google.api.servicecontrol.v1.CheckResponse.ConsumerInfo.ConsumerType",
7131                ))
7132            }
7133        }
7134    }
7135}
7136
7137/// Request message for the Report method.
7138#[derive(Clone, Debug, Default, PartialEq)]
7139#[non_exhaustive]
7140pub struct ReportRequest {
7141    /// The service name as specified in its service configuration. For example,
7142    /// `"pubsub.googleapis.com"`.
7143    ///
7144    /// See
7145    /// [google.api.Service](https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
7146    /// for the definition of a service name.
7147    pub service_name: std::string::String,
7148
7149    /// Operations to be reported.
7150    ///
7151    /// Typically the service should report one operation per request.
7152    /// Putting multiple operations into a single request is allowed, but should
7153    /// be used only when multiple operations are natually available at the time
7154    /// of the report.
7155    ///
7156    /// There is no limit on the number of operations in the same ReportRequest,
7157    /// however the ReportRequest size should be no larger than 1MB. See
7158    /// [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors]
7159    /// for partial failure behavior.
7160    ///
7161    /// [google.api.servicecontrol.v1.ReportResponse.report_errors]: crate::model::ReportResponse::report_errors
7162    pub operations: std::vec::Vec<crate::model::Operation>,
7163
7164    /// Specifies which version of service config should be used to process the
7165    /// request.
7166    ///
7167    /// If unspecified or no matching version can be found, the
7168    /// latest one will be used.
7169    pub service_config_id: std::string::String,
7170
7171    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7172}
7173
7174impl ReportRequest {
7175    pub fn new() -> Self {
7176        std::default::Default::default()
7177    }
7178
7179    /// Sets the value of [service_name][crate::model::ReportRequest::service_name].
7180    pub fn set_service_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7181        self.service_name = v.into();
7182        self
7183    }
7184
7185    /// Sets the value of [operations][crate::model::ReportRequest::operations].
7186    pub fn set_operations<T, V>(mut self, v: T) -> Self
7187    where
7188        T: std::iter::IntoIterator<Item = V>,
7189        V: std::convert::Into<crate::model::Operation>,
7190    {
7191        use std::iter::Iterator;
7192        self.operations = v.into_iter().map(|i| i.into()).collect();
7193        self
7194    }
7195
7196    /// Sets the value of [service_config_id][crate::model::ReportRequest::service_config_id].
7197    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
7198        mut self,
7199        v: T,
7200    ) -> Self {
7201        self.service_config_id = v.into();
7202        self
7203    }
7204}
7205
7206impl wkt::message::Message for ReportRequest {
7207    fn typename() -> &'static str {
7208        "type.googleapis.com/google.api.servicecontrol.v1.ReportRequest"
7209    }
7210}
7211
7212#[doc(hidden)]
7213impl<'de> serde::de::Deserialize<'de> for ReportRequest {
7214    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7215    where
7216        D: serde::Deserializer<'de>,
7217    {
7218        #[allow(non_camel_case_types)]
7219        #[doc(hidden)]
7220        #[derive(PartialEq, Eq, Hash)]
7221        enum __FieldTag {
7222            __service_name,
7223            __operations,
7224            __service_config_id,
7225            Unknown(std::string::String),
7226        }
7227        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7228            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7229            where
7230                D: serde::Deserializer<'de>,
7231            {
7232                struct Visitor;
7233                impl<'de> serde::de::Visitor<'de> for Visitor {
7234                    type Value = __FieldTag;
7235                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7236                        formatter.write_str("a field name for ReportRequest")
7237                    }
7238                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7239                    where
7240                        E: serde::de::Error,
7241                    {
7242                        use std::result::Result::Ok;
7243                        use std::string::ToString;
7244                        match value {
7245                            "serviceName" => Ok(__FieldTag::__service_name),
7246                            "service_name" => Ok(__FieldTag::__service_name),
7247                            "operations" => Ok(__FieldTag::__operations),
7248                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
7249                            "service_config_id" => Ok(__FieldTag::__service_config_id),
7250                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7251                        }
7252                    }
7253                }
7254                deserializer.deserialize_identifier(Visitor)
7255            }
7256        }
7257        struct Visitor;
7258        impl<'de> serde::de::Visitor<'de> for Visitor {
7259            type Value = ReportRequest;
7260            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7261                formatter.write_str("struct ReportRequest")
7262            }
7263            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7264            where
7265                A: serde::de::MapAccess<'de>,
7266            {
7267                #[allow(unused_imports)]
7268                use serde::de::Error;
7269                use std::option::Option::Some;
7270                let mut fields = std::collections::HashSet::new();
7271                let mut result = Self::Value::new();
7272                while let Some(tag) = map.next_key::<__FieldTag>()? {
7273                    #[allow(clippy::match_single_binding)]
7274                    match tag {
7275                        __FieldTag::__service_name => {
7276                            if !fields.insert(__FieldTag::__service_name) {
7277                                return std::result::Result::Err(A::Error::duplicate_field(
7278                                    "multiple values for service_name",
7279                                ));
7280                            }
7281                            result.service_name = map
7282                                .next_value::<std::option::Option<std::string::String>>()?
7283                                .unwrap_or_default();
7284                        }
7285                        __FieldTag::__operations => {
7286                            if !fields.insert(__FieldTag::__operations) {
7287                                return std::result::Result::Err(A::Error::duplicate_field(
7288                                    "multiple values for operations",
7289                                ));
7290                            }
7291                            result.operations = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Operation>>>()?.unwrap_or_default();
7292                        }
7293                        __FieldTag::__service_config_id => {
7294                            if !fields.insert(__FieldTag::__service_config_id) {
7295                                return std::result::Result::Err(A::Error::duplicate_field(
7296                                    "multiple values for service_config_id",
7297                                ));
7298                            }
7299                            result.service_config_id = map
7300                                .next_value::<std::option::Option<std::string::String>>()?
7301                                .unwrap_or_default();
7302                        }
7303                        __FieldTag::Unknown(key) => {
7304                            let value = map.next_value::<serde_json::Value>()?;
7305                            result._unknown_fields.insert(key, value);
7306                        }
7307                    }
7308                }
7309                std::result::Result::Ok(result)
7310            }
7311        }
7312        deserializer.deserialize_any(Visitor)
7313    }
7314}
7315
7316#[doc(hidden)]
7317impl serde::ser::Serialize for ReportRequest {
7318    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7319    where
7320        S: serde::ser::Serializer,
7321    {
7322        use serde::ser::SerializeMap;
7323        #[allow(unused_imports)]
7324        use std::option::Option::Some;
7325        let mut state = serializer.serialize_map(std::option::Option::None)?;
7326        if !self.service_name.is_empty() {
7327            state.serialize_entry("serviceName", &self.service_name)?;
7328        }
7329        if !self.operations.is_empty() {
7330            state.serialize_entry("operations", &self.operations)?;
7331        }
7332        if !self.service_config_id.is_empty() {
7333            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
7334        }
7335        if !self._unknown_fields.is_empty() {
7336            for (key, value) in self._unknown_fields.iter() {
7337                state.serialize_entry(key, &value)?;
7338            }
7339        }
7340        state.end()
7341    }
7342}
7343
7344/// Response message for the Report method.
7345#[derive(Clone, Debug, Default, PartialEq)]
7346#[non_exhaustive]
7347pub struct ReportResponse {
7348    /// Partial failures, one for each `Operation` in the request that failed
7349    /// processing. There are three possible combinations of the RPC status:
7350    ///
7351    /// 1. The combination of a successful RPC status and an empty `report_errors`
7352    ///    list indicates a complete success where all `Operations` in the
7353    ///    request are processed successfully.
7354    /// 1. The combination of a successful RPC status and a non-empty
7355    ///    `report_errors` list indicates a partial success where some
7356    ///    `Operations` in the request succeeded. Each
7357    ///    `Operation` that failed processing has a corresponding item
7358    ///    in this list.
7359    /// 1. A failed RPC status indicates a general non-deterministic failure.
7360    ///    When this happens, it's impossible to know which of the
7361    ///    'Operations' in the request succeeded or failed.
7362    pub report_errors: std::vec::Vec<crate::model::report_response::ReportError>,
7363
7364    /// The actual config id used to process the request.
7365    pub service_config_id: std::string::String,
7366
7367    /// The current service rollout id used to process the request.
7368    pub service_rollout_id: std::string::String,
7369
7370    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7371}
7372
7373impl ReportResponse {
7374    pub fn new() -> Self {
7375        std::default::Default::default()
7376    }
7377
7378    /// Sets the value of [report_errors][crate::model::ReportResponse::report_errors].
7379    pub fn set_report_errors<T, V>(mut self, v: T) -> Self
7380    where
7381        T: std::iter::IntoIterator<Item = V>,
7382        V: std::convert::Into<crate::model::report_response::ReportError>,
7383    {
7384        use std::iter::Iterator;
7385        self.report_errors = v.into_iter().map(|i| i.into()).collect();
7386        self
7387    }
7388
7389    /// Sets the value of [service_config_id][crate::model::ReportResponse::service_config_id].
7390    pub fn set_service_config_id<T: std::convert::Into<std::string::String>>(
7391        mut self,
7392        v: T,
7393    ) -> Self {
7394        self.service_config_id = v.into();
7395        self
7396    }
7397
7398    /// Sets the value of [service_rollout_id][crate::model::ReportResponse::service_rollout_id].
7399    pub fn set_service_rollout_id<T: std::convert::Into<std::string::String>>(
7400        mut self,
7401        v: T,
7402    ) -> Self {
7403        self.service_rollout_id = v.into();
7404        self
7405    }
7406}
7407
7408impl wkt::message::Message for ReportResponse {
7409    fn typename() -> &'static str {
7410        "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse"
7411    }
7412}
7413
7414#[doc(hidden)]
7415impl<'de> serde::de::Deserialize<'de> for ReportResponse {
7416    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7417    where
7418        D: serde::Deserializer<'de>,
7419    {
7420        #[allow(non_camel_case_types)]
7421        #[doc(hidden)]
7422        #[derive(PartialEq, Eq, Hash)]
7423        enum __FieldTag {
7424            __report_errors,
7425            __service_config_id,
7426            __service_rollout_id,
7427            Unknown(std::string::String),
7428        }
7429        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7430            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7431            where
7432                D: serde::Deserializer<'de>,
7433            {
7434                struct Visitor;
7435                impl<'de> serde::de::Visitor<'de> for Visitor {
7436                    type Value = __FieldTag;
7437                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7438                        formatter.write_str("a field name for ReportResponse")
7439                    }
7440                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7441                    where
7442                        E: serde::de::Error,
7443                    {
7444                        use std::result::Result::Ok;
7445                        use std::string::ToString;
7446                        match value {
7447                            "reportErrors" => Ok(__FieldTag::__report_errors),
7448                            "report_errors" => Ok(__FieldTag::__report_errors),
7449                            "serviceConfigId" => Ok(__FieldTag::__service_config_id),
7450                            "service_config_id" => Ok(__FieldTag::__service_config_id),
7451                            "serviceRolloutId" => Ok(__FieldTag::__service_rollout_id),
7452                            "service_rollout_id" => Ok(__FieldTag::__service_rollout_id),
7453                            _ => Ok(__FieldTag::Unknown(value.to_string())),
7454                        }
7455                    }
7456                }
7457                deserializer.deserialize_identifier(Visitor)
7458            }
7459        }
7460        struct Visitor;
7461        impl<'de> serde::de::Visitor<'de> for Visitor {
7462            type Value = ReportResponse;
7463            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7464                formatter.write_str("struct ReportResponse")
7465            }
7466            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7467            where
7468                A: serde::de::MapAccess<'de>,
7469            {
7470                #[allow(unused_imports)]
7471                use serde::de::Error;
7472                use std::option::Option::Some;
7473                let mut fields = std::collections::HashSet::new();
7474                let mut result = Self::Value::new();
7475                while let Some(tag) = map.next_key::<__FieldTag>()? {
7476                    #[allow(clippy::match_single_binding)]
7477                    match tag {
7478                        __FieldTag::__report_errors => {
7479                            if !fields.insert(__FieldTag::__report_errors) {
7480                                return std::result::Result::Err(A::Error::duplicate_field(
7481                                    "multiple values for report_errors",
7482                                ));
7483                            }
7484                            result.report_errors = map
7485                                .next_value::<std::option::Option<
7486                                    std::vec::Vec<crate::model::report_response::ReportError>,
7487                                >>()?
7488                                .unwrap_or_default();
7489                        }
7490                        __FieldTag::__service_config_id => {
7491                            if !fields.insert(__FieldTag::__service_config_id) {
7492                                return std::result::Result::Err(A::Error::duplicate_field(
7493                                    "multiple values for service_config_id",
7494                                ));
7495                            }
7496                            result.service_config_id = map
7497                                .next_value::<std::option::Option<std::string::String>>()?
7498                                .unwrap_or_default();
7499                        }
7500                        __FieldTag::__service_rollout_id => {
7501                            if !fields.insert(__FieldTag::__service_rollout_id) {
7502                                return std::result::Result::Err(A::Error::duplicate_field(
7503                                    "multiple values for service_rollout_id",
7504                                ));
7505                            }
7506                            result.service_rollout_id = map
7507                                .next_value::<std::option::Option<std::string::String>>()?
7508                                .unwrap_or_default();
7509                        }
7510                        __FieldTag::Unknown(key) => {
7511                            let value = map.next_value::<serde_json::Value>()?;
7512                            result._unknown_fields.insert(key, value);
7513                        }
7514                    }
7515                }
7516                std::result::Result::Ok(result)
7517            }
7518        }
7519        deserializer.deserialize_any(Visitor)
7520    }
7521}
7522
7523#[doc(hidden)]
7524impl serde::ser::Serialize for ReportResponse {
7525    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7526    where
7527        S: serde::ser::Serializer,
7528    {
7529        use serde::ser::SerializeMap;
7530        #[allow(unused_imports)]
7531        use std::option::Option::Some;
7532        let mut state = serializer.serialize_map(std::option::Option::None)?;
7533        if !self.report_errors.is_empty() {
7534            state.serialize_entry("reportErrors", &self.report_errors)?;
7535        }
7536        if !self.service_config_id.is_empty() {
7537            state.serialize_entry("serviceConfigId", &self.service_config_id)?;
7538        }
7539        if !self.service_rollout_id.is_empty() {
7540            state.serialize_entry("serviceRolloutId", &self.service_rollout_id)?;
7541        }
7542        if !self._unknown_fields.is_empty() {
7543            for (key, value) in self._unknown_fields.iter() {
7544                state.serialize_entry(key, &value)?;
7545            }
7546        }
7547        state.end()
7548    }
7549}
7550
7551/// Defines additional types related to [ReportResponse].
7552pub mod report_response {
7553    #[allow(unused_imports)]
7554    use super::*;
7555
7556    /// Represents the processing error of one
7557    /// [Operation][google.api.servicecontrol.v1.Operation] in the request.
7558    ///
7559    /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
7560    #[derive(Clone, Debug, Default, PartialEq)]
7561    #[non_exhaustive]
7562    pub struct ReportError {
7563        /// The
7564        /// [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id]
7565        /// value from the request.
7566        ///
7567        /// [google.api.servicecontrol.v1.Operation.operation_id]: crate::model::Operation::operation_id
7568        pub operation_id: std::string::String,
7569
7570        /// Details of the error when processing the
7571        /// [Operation][google.api.servicecontrol.v1.Operation].
7572        ///
7573        /// [google.api.servicecontrol.v1.Operation]: crate::model::Operation
7574        pub status: std::option::Option<rpc::model::Status>,
7575
7576        _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7577    }
7578
7579    impl ReportError {
7580        pub fn new() -> Self {
7581            std::default::Default::default()
7582        }
7583
7584        /// Sets the value of [operation_id][crate::model::report_response::ReportError::operation_id].
7585        pub fn set_operation_id<T: std::convert::Into<std::string::String>>(
7586            mut self,
7587            v: T,
7588        ) -> Self {
7589            self.operation_id = v.into();
7590            self
7591        }
7592
7593        /// Sets the value of [status][crate::model::report_response::ReportError::status].
7594        pub fn set_status<T>(mut self, v: T) -> Self
7595        where
7596            T: std::convert::Into<rpc::model::Status>,
7597        {
7598            self.status = std::option::Option::Some(v.into());
7599            self
7600        }
7601
7602        /// Sets or clears the value of [status][crate::model::report_response::ReportError::status].
7603        pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
7604        where
7605            T: std::convert::Into<rpc::model::Status>,
7606        {
7607            self.status = v.map(|x| x.into());
7608            self
7609        }
7610    }
7611
7612    impl wkt::message::Message for ReportError {
7613        fn typename() -> &'static str {
7614            "type.googleapis.com/google.api.servicecontrol.v1.ReportResponse.ReportError"
7615        }
7616    }
7617
7618    #[doc(hidden)]
7619    impl<'de> serde::de::Deserialize<'de> for ReportError {
7620        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7621        where
7622            D: serde::Deserializer<'de>,
7623        {
7624            #[allow(non_camel_case_types)]
7625            #[doc(hidden)]
7626            #[derive(PartialEq, Eq, Hash)]
7627            enum __FieldTag {
7628                __operation_id,
7629                __status,
7630                Unknown(std::string::String),
7631            }
7632            impl<'de> serde::de::Deserialize<'de> for __FieldTag {
7633                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7634                where
7635                    D: serde::Deserializer<'de>,
7636                {
7637                    struct Visitor;
7638                    impl<'de> serde::de::Visitor<'de> for Visitor {
7639                        type Value = __FieldTag;
7640                        fn expecting(
7641                            &self,
7642                            formatter: &mut std::fmt::Formatter,
7643                        ) -> std::fmt::Result {
7644                            formatter.write_str("a field name for ReportError")
7645                        }
7646                        fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
7647                        where
7648                            E: serde::de::Error,
7649                        {
7650                            use std::result::Result::Ok;
7651                            use std::string::ToString;
7652                            match value {
7653                                "operationId" => Ok(__FieldTag::__operation_id),
7654                                "operation_id" => Ok(__FieldTag::__operation_id),
7655                                "status" => Ok(__FieldTag::__status),
7656                                _ => Ok(__FieldTag::Unknown(value.to_string())),
7657                            }
7658                        }
7659                    }
7660                    deserializer.deserialize_identifier(Visitor)
7661                }
7662            }
7663            struct Visitor;
7664            impl<'de> serde::de::Visitor<'de> for Visitor {
7665                type Value = ReportError;
7666                fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
7667                    formatter.write_str("struct ReportError")
7668                }
7669                fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
7670                where
7671                    A: serde::de::MapAccess<'de>,
7672                {
7673                    #[allow(unused_imports)]
7674                    use serde::de::Error;
7675                    use std::option::Option::Some;
7676                    let mut fields = std::collections::HashSet::new();
7677                    let mut result = Self::Value::new();
7678                    while let Some(tag) = map.next_key::<__FieldTag>()? {
7679                        #[allow(clippy::match_single_binding)]
7680                        match tag {
7681                            __FieldTag::__operation_id => {
7682                                if !fields.insert(__FieldTag::__operation_id) {
7683                                    return std::result::Result::Err(A::Error::duplicate_field(
7684                                        "multiple values for operation_id",
7685                                    ));
7686                                }
7687                                result.operation_id = map
7688                                    .next_value::<std::option::Option<std::string::String>>()?
7689                                    .unwrap_or_default();
7690                            }
7691                            __FieldTag::__status => {
7692                                if !fields.insert(__FieldTag::__status) {
7693                                    return std::result::Result::Err(A::Error::duplicate_field(
7694                                        "multiple values for status",
7695                                    ));
7696                                }
7697                                result.status =
7698                                    map.next_value::<std::option::Option<rpc::model::Status>>()?;
7699                            }
7700                            __FieldTag::Unknown(key) => {
7701                                let value = map.next_value::<serde_json::Value>()?;
7702                                result._unknown_fields.insert(key, value);
7703                            }
7704                        }
7705                    }
7706                    std::result::Result::Ok(result)
7707                }
7708            }
7709            deserializer.deserialize_any(Visitor)
7710        }
7711    }
7712
7713    #[doc(hidden)]
7714    impl serde::ser::Serialize for ReportError {
7715        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7716        where
7717            S: serde::ser::Serializer,
7718        {
7719            use serde::ser::SerializeMap;
7720            #[allow(unused_imports)]
7721            use std::option::Option::Some;
7722            let mut state = serializer.serialize_map(std::option::Option::None)?;
7723            if !self.operation_id.is_empty() {
7724                state.serialize_entry("operationId", &self.operation_id)?;
7725            }
7726            if self.status.is_some() {
7727                state.serialize_entry("status", &self.status)?;
7728            }
7729            if !self._unknown_fields.is_empty() {
7730                for (key, value) in self._unknown_fields.iter() {
7731                    state.serialize_entry(key, &value)?;
7732                }
7733            }
7734            state.end()
7735        }
7736    }
7737}