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