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