google_cloud_api_serviceusage_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate api;
21extern crate async_trait;
22extern crate bytes;
23extern crate gax;
24extern crate gaxi;
25extern crate lazy_static;
26extern crate longrunning;
27extern crate lro;
28extern crate reqwest;
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/// A service that is available for use by the consumer.
41#[derive(Clone, Default, PartialEq)]
42#[non_exhaustive]
43pub struct Service {
44    /// The resource name of the consumer and service.
45    ///
46    /// A valid name would be:
47    ///
48    /// - projects/123/services/serviceusage.googleapis.com
49    pub name: std::string::String,
50
51    /// The resource name of the consumer.
52    ///
53    /// A valid name would be:
54    ///
55    /// - projects/123
56    pub parent: std::string::String,
57
58    /// The service configuration of the available service.
59    /// Some fields may be filtered out of the configuration in responses to
60    /// the `ListServices` method. These fields are present only in responses to
61    /// the `GetService` method.
62    pub config: std::option::Option<crate::model::ServiceConfig>,
63
64    /// Whether or not the service has been enabled for use by the consumer.
65    pub state: crate::model::State,
66
67    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
68}
69
70impl Service {
71    pub fn new() -> Self {
72        std::default::Default::default()
73    }
74
75    /// Sets the value of [name][crate::model::Service::name].
76    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
77        self.name = v.into();
78        self
79    }
80
81    /// Sets the value of [parent][crate::model::Service::parent].
82    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
83        self.parent = v.into();
84        self
85    }
86
87    /// Sets the value of [config][crate::model::Service::config].
88    pub fn set_config<T>(mut self, v: T) -> Self
89    where
90        T: std::convert::Into<crate::model::ServiceConfig>,
91    {
92        self.config = std::option::Option::Some(v.into());
93        self
94    }
95
96    /// Sets or clears the value of [config][crate::model::Service::config].
97    pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
98    where
99        T: std::convert::Into<crate::model::ServiceConfig>,
100    {
101        self.config = v.map(|x| x.into());
102        self
103    }
104
105    /// Sets the value of [state][crate::model::Service::state].
106    pub fn set_state<T: std::convert::Into<crate::model::State>>(mut self, v: T) -> Self {
107        self.state = v.into();
108        self
109    }
110}
111
112impl wkt::message::Message for Service {
113    fn typename() -> &'static str {
114        "type.googleapis.com/google.api.serviceusage.v1.Service"
115    }
116}
117
118/// The configuration of the service.
119#[derive(Clone, Default, PartialEq)]
120#[non_exhaustive]
121pub struct ServiceConfig {
122    /// The DNS address at which this service is available.
123    ///
124    /// An example DNS address would be:
125    /// `calendar.googleapis.com`.
126    pub name: std::string::String,
127
128    /// The product title for this service.
129    pub title: std::string::String,
130
131    /// A list of API interfaces exported by this service. Contains only the names,
132    /// versions, and method names of the interfaces.
133    pub apis: std::vec::Vec<wkt::Api>,
134
135    /// Additional API documentation. Contains only the summary and the
136    /// documentation URL.
137    pub documentation: std::option::Option<api::model::Documentation>,
138
139    /// Quota configuration.
140    pub quota: std::option::Option<api::model::Quota>,
141
142    /// Auth configuration. Contains only the OAuth rules.
143    pub authentication: std::option::Option<api::model::Authentication>,
144
145    /// Configuration controlling usage of this service.
146    pub usage: std::option::Option<api::model::Usage>,
147
148    /// Configuration for network endpoints. Contains only the names and aliases
149    /// of the endpoints.
150    pub endpoints: std::vec::Vec<api::model::Endpoint>,
151
152    /// Defines the monitored resources used by this service. This is required
153    /// by the [Service.monitoring][google.api.Service.monitoring] and
154    /// [Service.logging][google.api.Service.logging] configurations.
155    pub monitored_resources: std::vec::Vec<api::model::MonitoredResourceDescriptor>,
156
157    /// Monitoring configuration.
158    /// This should not include the 'producer_destinations' field.
159    pub monitoring: std::option::Option<api::model::Monitoring>,
160
161    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
162}
163
164impl ServiceConfig {
165    pub fn new() -> Self {
166        std::default::Default::default()
167    }
168
169    /// Sets the value of [name][crate::model::ServiceConfig::name].
170    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
171        self.name = v.into();
172        self
173    }
174
175    /// Sets the value of [title][crate::model::ServiceConfig::title].
176    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
177        self.title = v.into();
178        self
179    }
180
181    /// Sets the value of [apis][crate::model::ServiceConfig::apis].
182    pub fn set_apis<T, V>(mut self, v: T) -> Self
183    where
184        T: std::iter::IntoIterator<Item = V>,
185        V: std::convert::Into<wkt::Api>,
186    {
187        use std::iter::Iterator;
188        self.apis = v.into_iter().map(|i| i.into()).collect();
189        self
190    }
191
192    /// Sets the value of [documentation][crate::model::ServiceConfig::documentation].
193    pub fn set_documentation<T>(mut self, v: T) -> Self
194    where
195        T: std::convert::Into<api::model::Documentation>,
196    {
197        self.documentation = std::option::Option::Some(v.into());
198        self
199    }
200
201    /// Sets or clears the value of [documentation][crate::model::ServiceConfig::documentation].
202    pub fn set_or_clear_documentation<T>(mut self, v: std::option::Option<T>) -> Self
203    where
204        T: std::convert::Into<api::model::Documentation>,
205    {
206        self.documentation = v.map(|x| x.into());
207        self
208    }
209
210    /// Sets the value of [quota][crate::model::ServiceConfig::quota].
211    pub fn set_quota<T>(mut self, v: T) -> Self
212    where
213        T: std::convert::Into<api::model::Quota>,
214    {
215        self.quota = std::option::Option::Some(v.into());
216        self
217    }
218
219    /// Sets or clears the value of [quota][crate::model::ServiceConfig::quota].
220    pub fn set_or_clear_quota<T>(mut self, v: std::option::Option<T>) -> Self
221    where
222        T: std::convert::Into<api::model::Quota>,
223    {
224        self.quota = v.map(|x| x.into());
225        self
226    }
227
228    /// Sets the value of [authentication][crate::model::ServiceConfig::authentication].
229    pub fn set_authentication<T>(mut self, v: T) -> Self
230    where
231        T: std::convert::Into<api::model::Authentication>,
232    {
233        self.authentication = std::option::Option::Some(v.into());
234        self
235    }
236
237    /// Sets or clears the value of [authentication][crate::model::ServiceConfig::authentication].
238    pub fn set_or_clear_authentication<T>(mut self, v: std::option::Option<T>) -> Self
239    where
240        T: std::convert::Into<api::model::Authentication>,
241    {
242        self.authentication = v.map(|x| x.into());
243        self
244    }
245
246    /// Sets the value of [usage][crate::model::ServiceConfig::usage].
247    pub fn set_usage<T>(mut self, v: T) -> Self
248    where
249        T: std::convert::Into<api::model::Usage>,
250    {
251        self.usage = std::option::Option::Some(v.into());
252        self
253    }
254
255    /// Sets or clears the value of [usage][crate::model::ServiceConfig::usage].
256    pub fn set_or_clear_usage<T>(mut self, v: std::option::Option<T>) -> Self
257    where
258        T: std::convert::Into<api::model::Usage>,
259    {
260        self.usage = v.map(|x| x.into());
261        self
262    }
263
264    /// Sets the value of [endpoints][crate::model::ServiceConfig::endpoints].
265    pub fn set_endpoints<T, V>(mut self, v: T) -> Self
266    where
267        T: std::iter::IntoIterator<Item = V>,
268        V: std::convert::Into<api::model::Endpoint>,
269    {
270        use std::iter::Iterator;
271        self.endpoints = v.into_iter().map(|i| i.into()).collect();
272        self
273    }
274
275    /// Sets the value of [monitored_resources][crate::model::ServiceConfig::monitored_resources].
276    pub fn set_monitored_resources<T, V>(mut self, v: T) -> Self
277    where
278        T: std::iter::IntoIterator<Item = V>,
279        V: std::convert::Into<api::model::MonitoredResourceDescriptor>,
280    {
281        use std::iter::Iterator;
282        self.monitored_resources = v.into_iter().map(|i| i.into()).collect();
283        self
284    }
285
286    /// Sets the value of [monitoring][crate::model::ServiceConfig::monitoring].
287    pub fn set_monitoring<T>(mut self, v: T) -> Self
288    where
289        T: std::convert::Into<api::model::Monitoring>,
290    {
291        self.monitoring = std::option::Option::Some(v.into());
292        self
293    }
294
295    /// Sets or clears the value of [monitoring][crate::model::ServiceConfig::monitoring].
296    pub fn set_or_clear_monitoring<T>(mut self, v: std::option::Option<T>) -> Self
297    where
298        T: std::convert::Into<api::model::Monitoring>,
299    {
300        self.monitoring = v.map(|x| x.into());
301        self
302    }
303}
304
305impl wkt::message::Message for ServiceConfig {
306    fn typename() -> &'static str {
307        "type.googleapis.com/google.api.serviceusage.v1.ServiceConfig"
308    }
309}
310
311/// The operation metadata returned for the batchend services operation.
312#[derive(Clone, Default, PartialEq)]
313#[non_exhaustive]
314pub struct OperationMetadata {
315    /// The full name of the resources that this operation is directly
316    /// associated with.
317    pub resource_names: std::vec::Vec<std::string::String>,
318
319    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
320}
321
322impl OperationMetadata {
323    pub fn new() -> Self {
324        std::default::Default::default()
325    }
326
327    /// Sets the value of [resource_names][crate::model::OperationMetadata::resource_names].
328    pub fn set_resource_names<T, V>(mut self, v: T) -> Self
329    where
330        T: std::iter::IntoIterator<Item = V>,
331        V: std::convert::Into<std::string::String>,
332    {
333        use std::iter::Iterator;
334        self.resource_names = v.into_iter().map(|i| i.into()).collect();
335        self
336    }
337}
338
339impl wkt::message::Message for OperationMetadata {
340    fn typename() -> &'static str {
341        "type.googleapis.com/google.api.serviceusage.v1.OperationMetadata"
342    }
343}
344
345/// Request message for the `EnableService` method.
346#[derive(Clone, Default, PartialEq)]
347#[non_exhaustive]
348pub struct EnableServiceRequest {
349    /// Name of the consumer and service to enable the service on.
350    ///
351    /// The `EnableService` and `DisableService` methods currently only support
352    /// projects.
353    ///
354    /// Enabling a service requires that the service is public or is shared with
355    /// the user enabling the service.
356    ///
357    /// An example name would be:
358    /// `projects/123/services/serviceusage.googleapis.com` where `123` is the
359    /// project number.
360    pub name: std::string::String,
361
362    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
363}
364
365impl EnableServiceRequest {
366    pub fn new() -> Self {
367        std::default::Default::default()
368    }
369
370    /// Sets the value of [name][crate::model::EnableServiceRequest::name].
371    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
372        self.name = v.into();
373        self
374    }
375}
376
377impl wkt::message::Message for EnableServiceRequest {
378    fn typename() -> &'static str {
379        "type.googleapis.com/google.api.serviceusage.v1.EnableServiceRequest"
380    }
381}
382
383/// Response message for the `EnableService` method.
384/// This response message is assigned to the `response` field of the returned
385/// Operation when that operation is done.
386#[derive(Clone, Default, PartialEq)]
387#[non_exhaustive]
388pub struct EnableServiceResponse {
389    /// The new state of the service after enabling.
390    pub service: std::option::Option<crate::model::Service>,
391
392    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
393}
394
395impl EnableServiceResponse {
396    pub fn new() -> Self {
397        std::default::Default::default()
398    }
399
400    /// Sets the value of [service][crate::model::EnableServiceResponse::service].
401    pub fn set_service<T>(mut self, v: T) -> Self
402    where
403        T: std::convert::Into<crate::model::Service>,
404    {
405        self.service = std::option::Option::Some(v.into());
406        self
407    }
408
409    /// Sets or clears the value of [service][crate::model::EnableServiceResponse::service].
410    pub fn set_or_clear_service<T>(mut self, v: std::option::Option<T>) -> Self
411    where
412        T: std::convert::Into<crate::model::Service>,
413    {
414        self.service = v.map(|x| x.into());
415        self
416    }
417}
418
419impl wkt::message::Message for EnableServiceResponse {
420    fn typename() -> &'static str {
421        "type.googleapis.com/google.api.serviceusage.v1.EnableServiceResponse"
422    }
423}
424
425/// Request message for the `DisableService` method.
426#[derive(Clone, Default, PartialEq)]
427#[non_exhaustive]
428pub struct DisableServiceRequest {
429    /// Name of the consumer and service to disable the service on.
430    ///
431    /// The enable and disable methods currently only support projects.
432    ///
433    /// An example name would be:
434    /// `projects/123/services/serviceusage.googleapis.com` where `123` is the
435    /// project number.
436    pub name: std::string::String,
437
438    /// Indicates if services that are enabled and which depend on this service
439    /// should also be disabled. If not set, an error will be generated if any
440    /// enabled services depend on the service to be disabled. When set, the
441    /// service, and any enabled services that depend on it, will be disabled
442    /// together.
443    pub disable_dependent_services: bool,
444
445    /// Defines the behavior for checking service usage when disabling a service.
446    pub check_if_service_has_usage: crate::model::disable_service_request::CheckIfServiceHasUsage,
447
448    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
449}
450
451impl DisableServiceRequest {
452    pub fn new() -> Self {
453        std::default::Default::default()
454    }
455
456    /// Sets the value of [name][crate::model::DisableServiceRequest::name].
457    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
458        self.name = v.into();
459        self
460    }
461
462    /// Sets the value of [disable_dependent_services][crate::model::DisableServiceRequest::disable_dependent_services].
463    pub fn set_disable_dependent_services<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
464        self.disable_dependent_services = v.into();
465        self
466    }
467
468    /// Sets the value of [check_if_service_has_usage][crate::model::DisableServiceRequest::check_if_service_has_usage].
469    pub fn set_check_if_service_has_usage<
470        T: std::convert::Into<crate::model::disable_service_request::CheckIfServiceHasUsage>,
471    >(
472        mut self,
473        v: T,
474    ) -> Self {
475        self.check_if_service_has_usage = v.into();
476        self
477    }
478}
479
480impl wkt::message::Message for DisableServiceRequest {
481    fn typename() -> &'static str {
482        "type.googleapis.com/google.api.serviceusage.v1.DisableServiceRequest"
483    }
484}
485
486/// Defines additional types related to [DisableServiceRequest].
487pub mod disable_service_request {
488    #[allow(unused_imports)]
489    use super::*;
490
491    /// Enum to determine if service usage should be checked when disabling a
492    /// service.
493    ///
494    /// # Working with unknown values
495    ///
496    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
497    /// additional enum variants at any time. Adding new variants is not considered
498    /// a breaking change. Applications should write their code in anticipation of:
499    ///
500    /// - New values appearing in future releases of the client library, **and**
501    /// - New values received dynamically, without application changes.
502    ///
503    /// Please consult the [Working with enums] section in the user guide for some
504    /// guidelines.
505    ///
506    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
507    #[derive(Clone, Debug, PartialEq)]
508    #[non_exhaustive]
509    pub enum CheckIfServiceHasUsage {
510        /// When unset, the default behavior is used, which is SKIP.
511        Unspecified,
512        /// If set, skip checking service usage when disabling a service.
513        Skip,
514        /// If set, service usage is checked when disabling the service. If a
515        /// service, or its dependents, has usage in the last 30 days, the request
516        /// returns a FAILED_PRECONDITION error.
517        Check,
518        /// If set, the enum was initialized with an unknown value.
519        ///
520        /// Applications can examine the value using [CheckIfServiceHasUsage::value] or
521        /// [CheckIfServiceHasUsage::name].
522        UnknownValue(check_if_service_has_usage::UnknownValue),
523    }
524
525    #[doc(hidden)]
526    pub mod check_if_service_has_usage {
527        #[allow(unused_imports)]
528        use super::*;
529        #[derive(Clone, Debug, PartialEq)]
530        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
531    }
532
533    impl CheckIfServiceHasUsage {
534        /// Gets the enum value.
535        ///
536        /// Returns `None` if the enum contains an unknown value deserialized from
537        /// the string representation of enums.
538        pub fn value(&self) -> std::option::Option<i32> {
539            match self {
540                Self::Unspecified => std::option::Option::Some(0),
541                Self::Skip => std::option::Option::Some(1),
542                Self::Check => std::option::Option::Some(2),
543                Self::UnknownValue(u) => u.0.value(),
544            }
545        }
546
547        /// Gets the enum value as a string.
548        ///
549        /// Returns `None` if the enum contains an unknown value deserialized from
550        /// the integer representation of enums.
551        pub fn name(&self) -> std::option::Option<&str> {
552            match self {
553                Self::Unspecified => {
554                    std::option::Option::Some("CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED")
555                }
556                Self::Skip => std::option::Option::Some("SKIP"),
557                Self::Check => std::option::Option::Some("CHECK"),
558                Self::UnknownValue(u) => u.0.name(),
559            }
560        }
561    }
562
563    impl std::default::Default for CheckIfServiceHasUsage {
564        fn default() -> Self {
565            use std::convert::From;
566            Self::from(0)
567        }
568    }
569
570    impl std::fmt::Display for CheckIfServiceHasUsage {
571        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
572            wkt::internal::display_enum(f, self.name(), self.value())
573        }
574    }
575
576    impl std::convert::From<i32> for CheckIfServiceHasUsage {
577        fn from(value: i32) -> Self {
578            match value {
579                0 => Self::Unspecified,
580                1 => Self::Skip,
581                2 => Self::Check,
582                _ => Self::UnknownValue(check_if_service_has_usage::UnknownValue(
583                    wkt::internal::UnknownEnumValue::Integer(value),
584                )),
585            }
586        }
587    }
588
589    impl std::convert::From<&str> for CheckIfServiceHasUsage {
590        fn from(value: &str) -> Self {
591            use std::string::ToString;
592            match value {
593                "CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED" => Self::Unspecified,
594                "SKIP" => Self::Skip,
595                "CHECK" => Self::Check,
596                _ => Self::UnknownValue(check_if_service_has_usage::UnknownValue(
597                    wkt::internal::UnknownEnumValue::String(value.to_string()),
598                )),
599            }
600        }
601    }
602
603    impl serde::ser::Serialize for CheckIfServiceHasUsage {
604        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
605        where
606            S: serde::Serializer,
607        {
608            match self {
609                Self::Unspecified => serializer.serialize_i32(0),
610                Self::Skip => serializer.serialize_i32(1),
611                Self::Check => serializer.serialize_i32(2),
612                Self::UnknownValue(u) => u.0.serialize(serializer),
613            }
614        }
615    }
616
617    impl<'de> serde::de::Deserialize<'de> for CheckIfServiceHasUsage {
618        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
619        where
620            D: serde::Deserializer<'de>,
621        {
622            deserializer.deserialize_any(wkt::internal::EnumVisitor::<CheckIfServiceHasUsage>::new(
623                ".google.api.serviceusage.v1.DisableServiceRequest.CheckIfServiceHasUsage",
624            ))
625        }
626    }
627}
628
629/// Response message for the `DisableService` method.
630/// This response message is assigned to the `response` field of the returned
631/// Operation when that operation is done.
632#[derive(Clone, Default, PartialEq)]
633#[non_exhaustive]
634pub struct DisableServiceResponse {
635    /// The new state of the service after disabling.
636    pub service: std::option::Option<crate::model::Service>,
637
638    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
639}
640
641impl DisableServiceResponse {
642    pub fn new() -> Self {
643        std::default::Default::default()
644    }
645
646    /// Sets the value of [service][crate::model::DisableServiceResponse::service].
647    pub fn set_service<T>(mut self, v: T) -> Self
648    where
649        T: std::convert::Into<crate::model::Service>,
650    {
651        self.service = std::option::Option::Some(v.into());
652        self
653    }
654
655    /// Sets or clears the value of [service][crate::model::DisableServiceResponse::service].
656    pub fn set_or_clear_service<T>(mut self, v: std::option::Option<T>) -> Self
657    where
658        T: std::convert::Into<crate::model::Service>,
659    {
660        self.service = v.map(|x| x.into());
661        self
662    }
663}
664
665impl wkt::message::Message for DisableServiceResponse {
666    fn typename() -> &'static str {
667        "type.googleapis.com/google.api.serviceusage.v1.DisableServiceResponse"
668    }
669}
670
671/// Request message for the `GetService` method.
672#[derive(Clone, Default, PartialEq)]
673#[non_exhaustive]
674pub struct GetServiceRequest {
675    /// Name of the consumer and service to get the `ConsumerState` for.
676    ///
677    /// An example name would be:
678    /// `projects/123/services/serviceusage.googleapis.com` where `123` is the
679    /// project number.
680    pub name: std::string::String,
681
682    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
683}
684
685impl GetServiceRequest {
686    pub fn new() -> Self {
687        std::default::Default::default()
688    }
689
690    /// Sets the value of [name][crate::model::GetServiceRequest::name].
691    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
692        self.name = v.into();
693        self
694    }
695}
696
697impl wkt::message::Message for GetServiceRequest {
698    fn typename() -> &'static str {
699        "type.googleapis.com/google.api.serviceusage.v1.GetServiceRequest"
700    }
701}
702
703/// Request message for the `ListServices` method.
704#[derive(Clone, Default, PartialEq)]
705#[non_exhaustive]
706pub struct ListServicesRequest {
707    /// Parent to search for services on.
708    ///
709    /// An example name would be:
710    /// `projects/123` where `123` is the project number.
711    pub parent: std::string::String,
712
713    /// Requested size of the next page of data.
714    /// Requested page size cannot exceed 200.
715    /// If not set, the default page size is 50.
716    pub page_size: i32,
717
718    /// Token identifying which result to start with, which is returned by a
719    /// previous list call.
720    pub page_token: std::string::String,
721
722    /// Only list services that conform to the given filter.
723    /// The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
724    pub filter: std::string::String,
725
726    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
727}
728
729impl ListServicesRequest {
730    pub fn new() -> Self {
731        std::default::Default::default()
732    }
733
734    /// Sets the value of [parent][crate::model::ListServicesRequest::parent].
735    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
736        self.parent = v.into();
737        self
738    }
739
740    /// Sets the value of [page_size][crate::model::ListServicesRequest::page_size].
741    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
742        self.page_size = v.into();
743        self
744    }
745
746    /// Sets the value of [page_token][crate::model::ListServicesRequest::page_token].
747    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
748        self.page_token = v.into();
749        self
750    }
751
752    /// Sets the value of [filter][crate::model::ListServicesRequest::filter].
753    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
754        self.filter = v.into();
755        self
756    }
757}
758
759impl wkt::message::Message for ListServicesRequest {
760    fn typename() -> &'static str {
761        "type.googleapis.com/google.api.serviceusage.v1.ListServicesRequest"
762    }
763}
764
765/// Response message for the `ListServices` method.
766#[derive(Clone, Default, PartialEq)]
767#[non_exhaustive]
768pub struct ListServicesResponse {
769    /// The available services for the requested project.
770    pub services: std::vec::Vec<crate::model::Service>,
771
772    /// Token that can be passed to `ListServices` to resume a paginated
773    /// query.
774    pub next_page_token: std::string::String,
775
776    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
777}
778
779impl ListServicesResponse {
780    pub fn new() -> Self {
781        std::default::Default::default()
782    }
783
784    /// Sets the value of [services][crate::model::ListServicesResponse::services].
785    pub fn set_services<T, V>(mut self, v: T) -> Self
786    where
787        T: std::iter::IntoIterator<Item = V>,
788        V: std::convert::Into<crate::model::Service>,
789    {
790        use std::iter::Iterator;
791        self.services = v.into_iter().map(|i| i.into()).collect();
792        self
793    }
794
795    /// Sets the value of [next_page_token][crate::model::ListServicesResponse::next_page_token].
796    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
797        self.next_page_token = v.into();
798        self
799    }
800}
801
802impl wkt::message::Message for ListServicesResponse {
803    fn typename() -> &'static str {
804        "type.googleapis.com/google.api.serviceusage.v1.ListServicesResponse"
805    }
806}
807
808#[doc(hidden)]
809impl gax::paginator::internal::PageableResponse for ListServicesResponse {
810    type PageItem = crate::model::Service;
811
812    fn items(self) -> std::vec::Vec<Self::PageItem> {
813        self.services
814    }
815
816    fn next_page_token(&self) -> std::string::String {
817        use std::clone::Clone;
818        self.next_page_token.clone()
819    }
820}
821
822/// Request message for the `BatchEnableServices` method.
823#[derive(Clone, Default, PartialEq)]
824#[non_exhaustive]
825pub struct BatchEnableServicesRequest {
826    /// Parent to enable services on.
827    ///
828    /// An example name would be:
829    /// `projects/123` where `123` is the project number.
830    ///
831    /// The `BatchEnableServices` method currently only supports projects.
832    pub parent: std::string::String,
833
834    /// The identifiers of the services to enable on the project.
835    ///
836    /// A valid identifier would be:
837    /// serviceusage.googleapis.com
838    ///
839    /// Enabling services requires that each service is public or is shared with
840    /// the user enabling the service.
841    ///
842    /// A single request can enable a maximum of 20 services at a time. If more
843    /// than 20 services are specified, the request will fail, and no state changes
844    /// will occur.
845    pub service_ids: std::vec::Vec<std::string::String>,
846
847    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
848}
849
850impl BatchEnableServicesRequest {
851    pub fn new() -> Self {
852        std::default::Default::default()
853    }
854
855    /// Sets the value of [parent][crate::model::BatchEnableServicesRequest::parent].
856    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
857        self.parent = v.into();
858        self
859    }
860
861    /// Sets the value of [service_ids][crate::model::BatchEnableServicesRequest::service_ids].
862    pub fn set_service_ids<T, V>(mut self, v: T) -> Self
863    where
864        T: std::iter::IntoIterator<Item = V>,
865        V: std::convert::Into<std::string::String>,
866    {
867        use std::iter::Iterator;
868        self.service_ids = v.into_iter().map(|i| i.into()).collect();
869        self
870    }
871}
872
873impl wkt::message::Message for BatchEnableServicesRequest {
874    fn typename() -> &'static str {
875        "type.googleapis.com/google.api.serviceusage.v1.BatchEnableServicesRequest"
876    }
877}
878
879/// Response message for the `BatchEnableServices` method.
880/// This response message is assigned to the `response` field of the returned
881/// Operation when that operation is done.
882#[derive(Clone, Default, PartialEq)]
883#[non_exhaustive]
884pub struct BatchEnableServicesResponse {
885    /// The new state of the services after enabling.
886    pub services: std::vec::Vec<crate::model::Service>,
887
888    /// If allow_partial_success is true, and one or more services could not be
889    /// enabled, this field contains the details about each failure.
890    pub failures: std::vec::Vec<crate::model::batch_enable_services_response::EnableFailure>,
891
892    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
893}
894
895impl BatchEnableServicesResponse {
896    pub fn new() -> Self {
897        std::default::Default::default()
898    }
899
900    /// Sets the value of [services][crate::model::BatchEnableServicesResponse::services].
901    pub fn set_services<T, V>(mut self, v: T) -> Self
902    where
903        T: std::iter::IntoIterator<Item = V>,
904        V: std::convert::Into<crate::model::Service>,
905    {
906        use std::iter::Iterator;
907        self.services = v.into_iter().map(|i| i.into()).collect();
908        self
909    }
910
911    /// Sets the value of [failures][crate::model::BatchEnableServicesResponse::failures].
912    pub fn set_failures<T, V>(mut self, v: T) -> Self
913    where
914        T: std::iter::IntoIterator<Item = V>,
915        V: std::convert::Into<crate::model::batch_enable_services_response::EnableFailure>,
916    {
917        use std::iter::Iterator;
918        self.failures = v.into_iter().map(|i| i.into()).collect();
919        self
920    }
921}
922
923impl wkt::message::Message for BatchEnableServicesResponse {
924    fn typename() -> &'static str {
925        "type.googleapis.com/google.api.serviceusage.v1.BatchEnableServicesResponse"
926    }
927}
928
929/// Defines additional types related to [BatchEnableServicesResponse].
930pub mod batch_enable_services_response {
931    #[allow(unused_imports)]
932    use super::*;
933
934    /// Provides error messages for the failing services.
935    #[derive(Clone, Default, PartialEq)]
936    #[non_exhaustive]
937    pub struct EnableFailure {
938        /// The service id of a service that could not be enabled.
939        pub service_id: std::string::String,
940
941        /// An error message describing why the service could not be enabled.
942        pub error_message: std::string::String,
943
944        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
945    }
946
947    impl EnableFailure {
948        pub fn new() -> Self {
949            std::default::Default::default()
950        }
951
952        /// Sets the value of [service_id][crate::model::batch_enable_services_response::EnableFailure::service_id].
953        pub fn set_service_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
954            self.service_id = v.into();
955            self
956        }
957
958        /// Sets the value of [error_message][crate::model::batch_enable_services_response::EnableFailure::error_message].
959        pub fn set_error_message<T: std::convert::Into<std::string::String>>(
960            mut self,
961            v: T,
962        ) -> Self {
963            self.error_message = v.into();
964            self
965        }
966    }
967
968    impl wkt::message::Message for EnableFailure {
969        fn typename() -> &'static str {
970            "type.googleapis.com/google.api.serviceusage.v1.BatchEnableServicesResponse.EnableFailure"
971        }
972    }
973}
974
975/// Request message for the `BatchGetServices` method.
976#[derive(Clone, Default, PartialEq)]
977#[non_exhaustive]
978pub struct BatchGetServicesRequest {
979    /// Parent to retrieve services from.
980    /// If this is set, the parent of all of the services specified in `names` must
981    /// match this field. An example name would be: `projects/123` where `123` is
982    /// the project number. The `BatchGetServices` method currently only supports
983    /// projects.
984    pub parent: std::string::String,
985
986    /// Names of the services to retrieve.
987    ///
988    /// An example name would be:
989    /// `projects/123/services/serviceusage.googleapis.com` where `123` is the
990    /// project number.
991    /// A single request can get a maximum of 30 services at a time.
992    pub names: std::vec::Vec<std::string::String>,
993
994    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
995}
996
997impl BatchGetServicesRequest {
998    pub fn new() -> Self {
999        std::default::Default::default()
1000    }
1001
1002    /// Sets the value of [parent][crate::model::BatchGetServicesRequest::parent].
1003    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1004        self.parent = v.into();
1005        self
1006    }
1007
1008    /// Sets the value of [names][crate::model::BatchGetServicesRequest::names].
1009    pub fn set_names<T, V>(mut self, v: T) -> Self
1010    where
1011        T: std::iter::IntoIterator<Item = V>,
1012        V: std::convert::Into<std::string::String>,
1013    {
1014        use std::iter::Iterator;
1015        self.names = v.into_iter().map(|i| i.into()).collect();
1016        self
1017    }
1018}
1019
1020impl wkt::message::Message for BatchGetServicesRequest {
1021    fn typename() -> &'static str {
1022        "type.googleapis.com/google.api.serviceusage.v1.BatchGetServicesRequest"
1023    }
1024}
1025
1026/// Response message for the `BatchGetServices` method.
1027#[derive(Clone, Default, PartialEq)]
1028#[non_exhaustive]
1029pub struct BatchGetServicesResponse {
1030    /// The requested Service states.
1031    pub services: std::vec::Vec<crate::model::Service>,
1032
1033    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1034}
1035
1036impl BatchGetServicesResponse {
1037    pub fn new() -> Self {
1038        std::default::Default::default()
1039    }
1040
1041    /// Sets the value of [services][crate::model::BatchGetServicesResponse::services].
1042    pub fn set_services<T, V>(mut self, v: T) -> Self
1043    where
1044        T: std::iter::IntoIterator<Item = V>,
1045        V: std::convert::Into<crate::model::Service>,
1046    {
1047        use std::iter::Iterator;
1048        self.services = v.into_iter().map(|i| i.into()).collect();
1049        self
1050    }
1051}
1052
1053impl wkt::message::Message for BatchGetServicesResponse {
1054    fn typename() -> &'static str {
1055        "type.googleapis.com/google.api.serviceusage.v1.BatchGetServicesResponse"
1056    }
1057}
1058
1059/// Whether or not a service has been enabled for use by a consumer.
1060///
1061/// # Working with unknown values
1062///
1063/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1064/// additional enum variants at any time. Adding new variants is not considered
1065/// a breaking change. Applications should write their code in anticipation of:
1066///
1067/// - New values appearing in future releases of the client library, **and**
1068/// - New values received dynamically, without application changes.
1069///
1070/// Please consult the [Working with enums] section in the user guide for some
1071/// guidelines.
1072///
1073/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1074#[derive(Clone, Debug, PartialEq)]
1075#[non_exhaustive]
1076pub enum State {
1077    /// The default value, which indicates that the enabled state of the service
1078    /// is unspecified or not meaningful. Currently, all consumers other than
1079    /// projects (such as folders and organizations) are always in this state.
1080    Unspecified,
1081    /// The service cannot be used by this consumer. It has either been explicitly
1082    /// disabled, or has never been enabled.
1083    Disabled,
1084    /// The service has been explicitly enabled for use by this consumer.
1085    Enabled,
1086    /// If set, the enum was initialized with an unknown value.
1087    ///
1088    /// Applications can examine the value using [State::value] or
1089    /// [State::name].
1090    UnknownValue(state::UnknownValue),
1091}
1092
1093#[doc(hidden)]
1094pub mod state {
1095    #[allow(unused_imports)]
1096    use super::*;
1097    #[derive(Clone, Debug, PartialEq)]
1098    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1099}
1100
1101impl State {
1102    /// Gets the enum value.
1103    ///
1104    /// Returns `None` if the enum contains an unknown value deserialized from
1105    /// the string representation of enums.
1106    pub fn value(&self) -> std::option::Option<i32> {
1107        match self {
1108            Self::Unspecified => std::option::Option::Some(0),
1109            Self::Disabled => std::option::Option::Some(1),
1110            Self::Enabled => std::option::Option::Some(2),
1111            Self::UnknownValue(u) => u.0.value(),
1112        }
1113    }
1114
1115    /// Gets the enum value as a string.
1116    ///
1117    /// Returns `None` if the enum contains an unknown value deserialized from
1118    /// the integer representation of enums.
1119    pub fn name(&self) -> std::option::Option<&str> {
1120        match self {
1121            Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1122            Self::Disabled => std::option::Option::Some("DISABLED"),
1123            Self::Enabled => std::option::Option::Some("ENABLED"),
1124            Self::UnknownValue(u) => u.0.name(),
1125        }
1126    }
1127}
1128
1129impl std::default::Default for State {
1130    fn default() -> Self {
1131        use std::convert::From;
1132        Self::from(0)
1133    }
1134}
1135
1136impl std::fmt::Display for State {
1137    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1138        wkt::internal::display_enum(f, self.name(), self.value())
1139    }
1140}
1141
1142impl std::convert::From<i32> for State {
1143    fn from(value: i32) -> Self {
1144        match value {
1145            0 => Self::Unspecified,
1146            1 => Self::Disabled,
1147            2 => Self::Enabled,
1148            _ => Self::UnknownValue(state::UnknownValue(
1149                wkt::internal::UnknownEnumValue::Integer(value),
1150            )),
1151        }
1152    }
1153}
1154
1155impl std::convert::From<&str> for State {
1156    fn from(value: &str) -> Self {
1157        use std::string::ToString;
1158        match value {
1159            "STATE_UNSPECIFIED" => Self::Unspecified,
1160            "DISABLED" => Self::Disabled,
1161            "ENABLED" => Self::Enabled,
1162            _ => Self::UnknownValue(state::UnknownValue(
1163                wkt::internal::UnknownEnumValue::String(value.to_string()),
1164            )),
1165        }
1166    }
1167}
1168
1169impl serde::ser::Serialize for State {
1170    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1171    where
1172        S: serde::Serializer,
1173    {
1174        match self {
1175            Self::Unspecified => serializer.serialize_i32(0),
1176            Self::Disabled => serializer.serialize_i32(1),
1177            Self::Enabled => serializer.serialize_i32(2),
1178            Self::UnknownValue(u) => u.0.serialize(serializer),
1179        }
1180    }
1181}
1182
1183impl<'de> serde::de::Deserialize<'de> for State {
1184    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1185    where
1186        D: serde::Deserializer<'de>,
1187    {
1188        deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1189            ".google.api.serviceusage.v1.State",
1190        ))
1191    }
1192}