Skip to main content

google_cloud_api_servicecontrol_v1/
model.rs

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