Skip to main content

google_cloud_orgpolicy_v2/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_type;
25extern crate serde;
26extern crate serde_json;
27extern crate serde_with;
28extern crate std;
29extern crate tracing;
30extern crate wkt;
31
32mod debug;
33mod deserialize;
34mod serialize;
35
36/// A constraint describes a way to restrict resource's configuration. For
37/// example, you could enforce a constraint that controls which Google Cloud
38/// services can be activated across an organization, or whether a Compute Engine
39/// instance can have serial port connections established. Constraints can be
40/// configured by the organization policy administrator to fit the needs of the
41/// organization by setting a policy that includes constraints at different
42/// locations in the organization's resource hierarchy. Policies are inherited
43/// down the resource hierarchy from higher levels, but can also be overridden.
44/// For details about the inheritance rules, see
45/// [`Policy`][google.cloud.orgpolicy.v2.Policy].
46///
47/// Constraints have a default behavior determined by the `constraint_default`
48/// field, which is the enforcement behavior that is used in the absence of a
49/// policy being defined or inherited for the resource in question.
50///
51/// [google.cloud.orgpolicy.v2.Policy]: crate::model::Policy
52#[derive(Clone, Default, PartialEq)]
53#[non_exhaustive]
54pub struct Constraint {
55    /// Immutable. The resource name of the constraint. Must be in one of
56    /// the following forms:
57    ///
58    /// * `projects/{project_number}/constraints/{constraint_name}`
59    /// * `folders/{folder_id}/constraints/{constraint_name}`
60    /// * `organizations/{organization_id}/constraints/{constraint_name}`
61    ///
62    /// For example, "/projects/123/constraints/compute.disableSerialPortAccess".
63    pub name: std::string::String,
64
65    /// The human readable name.
66    ///
67    /// Mutable.
68    pub display_name: std::string::String,
69
70    /// Detailed description of what this constraint controls as well as how and
71    /// where it is enforced.
72    ///
73    /// Mutable.
74    pub description: std::string::String,
75
76    /// The evaluation behavior of this constraint in the absence of a policy.
77    pub constraint_default: crate::model::constraint::ConstraintDefault,
78
79    /// Shows if dry run is supported for this constraint or not.
80    pub supports_dry_run: bool,
81
82    /// Managed constraint and canned constraint sometimes can have
83    /// equivalents. This field is used to store the equivalent constraint name.
84    pub equivalent_constraint: std::string::String,
85
86    /// Shows if simulation is supported for this constraint or not.
87    pub supports_simulation: bool,
88
89    /// The type of restrictions for this `Constraint`.
90    ///
91    /// Immutable after creation.
92    pub constraint_type: std::option::Option<crate::model::constraint::ConstraintType>,
93
94    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
95}
96
97impl Constraint {
98    pub fn new() -> Self {
99        std::default::Default::default()
100    }
101
102    /// Sets the value of [name][crate::model::Constraint::name].
103    ///
104    /// # Example
105    /// ```ignore,no_run
106    /// # use google_cloud_orgpolicy_v2::model::Constraint;
107    /// let x = Constraint::new().set_name("example");
108    /// ```
109    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
110        self.name = v.into();
111        self
112    }
113
114    /// Sets the value of [display_name][crate::model::Constraint::display_name].
115    ///
116    /// # Example
117    /// ```ignore,no_run
118    /// # use google_cloud_orgpolicy_v2::model::Constraint;
119    /// let x = Constraint::new().set_display_name("example");
120    /// ```
121    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
122        self.display_name = v.into();
123        self
124    }
125
126    /// Sets the value of [description][crate::model::Constraint::description].
127    ///
128    /// # Example
129    /// ```ignore,no_run
130    /// # use google_cloud_orgpolicy_v2::model::Constraint;
131    /// let x = Constraint::new().set_description("example");
132    /// ```
133    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
134        self.description = v.into();
135        self
136    }
137
138    /// Sets the value of [constraint_default][crate::model::Constraint::constraint_default].
139    ///
140    /// # Example
141    /// ```ignore,no_run
142    /// # use google_cloud_orgpolicy_v2::model::Constraint;
143    /// use google_cloud_orgpolicy_v2::model::constraint::ConstraintDefault;
144    /// let x0 = Constraint::new().set_constraint_default(ConstraintDefault::Allow);
145    /// let x1 = Constraint::new().set_constraint_default(ConstraintDefault::Deny);
146    /// ```
147    pub fn set_constraint_default<
148        T: std::convert::Into<crate::model::constraint::ConstraintDefault>,
149    >(
150        mut self,
151        v: T,
152    ) -> Self {
153        self.constraint_default = v.into();
154        self
155    }
156
157    /// Sets the value of [supports_dry_run][crate::model::Constraint::supports_dry_run].
158    ///
159    /// # Example
160    /// ```ignore,no_run
161    /// # use google_cloud_orgpolicy_v2::model::Constraint;
162    /// let x = Constraint::new().set_supports_dry_run(true);
163    /// ```
164    pub fn set_supports_dry_run<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
165        self.supports_dry_run = v.into();
166        self
167    }
168
169    /// Sets the value of [equivalent_constraint][crate::model::Constraint::equivalent_constraint].
170    ///
171    /// # Example
172    /// ```ignore,no_run
173    /// # use google_cloud_orgpolicy_v2::model::Constraint;
174    /// let x = Constraint::new().set_equivalent_constraint("example");
175    /// ```
176    pub fn set_equivalent_constraint<T: std::convert::Into<std::string::String>>(
177        mut self,
178        v: T,
179    ) -> Self {
180        self.equivalent_constraint = v.into();
181        self
182    }
183
184    /// Sets the value of [supports_simulation][crate::model::Constraint::supports_simulation].
185    ///
186    /// # Example
187    /// ```ignore,no_run
188    /// # use google_cloud_orgpolicy_v2::model::Constraint;
189    /// let x = Constraint::new().set_supports_simulation(true);
190    /// ```
191    pub fn set_supports_simulation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
192        self.supports_simulation = v.into();
193        self
194    }
195
196    /// Sets the value of [constraint_type][crate::model::Constraint::constraint_type].
197    ///
198    /// Note that all the setters affecting `constraint_type` are mutually
199    /// exclusive.
200    ///
201    /// # Example
202    /// ```ignore,no_run
203    /// # use google_cloud_orgpolicy_v2::model::Constraint;
204    /// use google_cloud_orgpolicy_v2::model::constraint::ListConstraint;
205    /// let x = Constraint::new().set_constraint_type(Some(
206    ///     google_cloud_orgpolicy_v2::model::constraint::ConstraintType::ListConstraint(ListConstraint::default().into())));
207    /// ```
208    pub fn set_constraint_type<
209        T: std::convert::Into<std::option::Option<crate::model::constraint::ConstraintType>>,
210    >(
211        mut self,
212        v: T,
213    ) -> Self {
214        self.constraint_type = v.into();
215        self
216    }
217
218    /// The value of [constraint_type][crate::model::Constraint::constraint_type]
219    /// if it holds a `ListConstraint`, `None` if the field is not set or
220    /// holds a different branch.
221    pub fn list_constraint(
222        &self,
223    ) -> std::option::Option<&std::boxed::Box<crate::model::constraint::ListConstraint>> {
224        #[allow(unreachable_patterns)]
225        self.constraint_type.as_ref().and_then(|v| match v {
226            crate::model::constraint::ConstraintType::ListConstraint(v) => {
227                std::option::Option::Some(v)
228            }
229            _ => std::option::Option::None,
230        })
231    }
232
233    /// Sets the value of [constraint_type][crate::model::Constraint::constraint_type]
234    /// to hold a `ListConstraint`.
235    ///
236    /// Note that all the setters affecting `constraint_type` are
237    /// mutually exclusive.
238    ///
239    /// # Example
240    /// ```ignore,no_run
241    /// # use google_cloud_orgpolicy_v2::model::Constraint;
242    /// use google_cloud_orgpolicy_v2::model::constraint::ListConstraint;
243    /// let x = Constraint::new().set_list_constraint(ListConstraint::default()/* use setters */);
244    /// assert!(x.list_constraint().is_some());
245    /// assert!(x.boolean_constraint().is_none());
246    /// ```
247    pub fn set_list_constraint<
248        T: std::convert::Into<std::boxed::Box<crate::model::constraint::ListConstraint>>,
249    >(
250        mut self,
251        v: T,
252    ) -> Self {
253        self.constraint_type = std::option::Option::Some(
254            crate::model::constraint::ConstraintType::ListConstraint(v.into()),
255        );
256        self
257    }
258
259    /// The value of [constraint_type][crate::model::Constraint::constraint_type]
260    /// if it holds a `BooleanConstraint`, `None` if the field is not set or
261    /// holds a different branch.
262    pub fn boolean_constraint(
263        &self,
264    ) -> std::option::Option<&std::boxed::Box<crate::model::constraint::BooleanConstraint>> {
265        #[allow(unreachable_patterns)]
266        self.constraint_type.as_ref().and_then(|v| match v {
267            crate::model::constraint::ConstraintType::BooleanConstraint(v) => {
268                std::option::Option::Some(v)
269            }
270            _ => std::option::Option::None,
271        })
272    }
273
274    /// Sets the value of [constraint_type][crate::model::Constraint::constraint_type]
275    /// to hold a `BooleanConstraint`.
276    ///
277    /// Note that all the setters affecting `constraint_type` are
278    /// mutually exclusive.
279    ///
280    /// # Example
281    /// ```ignore,no_run
282    /// # use google_cloud_orgpolicy_v2::model::Constraint;
283    /// use google_cloud_orgpolicy_v2::model::constraint::BooleanConstraint;
284    /// let x = Constraint::new().set_boolean_constraint(BooleanConstraint::default()/* use setters */);
285    /// assert!(x.boolean_constraint().is_some());
286    /// assert!(x.list_constraint().is_none());
287    /// ```
288    pub fn set_boolean_constraint<
289        T: std::convert::Into<std::boxed::Box<crate::model::constraint::BooleanConstraint>>,
290    >(
291        mut self,
292        v: T,
293    ) -> Self {
294        self.constraint_type = std::option::Option::Some(
295            crate::model::constraint::ConstraintType::BooleanConstraint(v.into()),
296        );
297        self
298    }
299}
300
301impl wkt::message::Message for Constraint {
302    fn typename() -> &'static str {
303        "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint"
304    }
305}
306
307/// Defines additional types related to [Constraint].
308pub mod constraint {
309    #[allow(unused_imports)]
310    use super::*;
311
312    /// A constraint type that allows or disallows a list of string values, which
313    /// are configured in the
314    /// [`PolicyRule`][google.cloud.orgpolicy.v2.PolicySpec.PolicyRule].
315    ///
316    /// [google.cloud.orgpolicy.v2.PolicySpec.PolicyRule]: crate::model::policy_spec::PolicyRule
317    #[derive(Clone, Default, PartialEq)]
318    #[non_exhaustive]
319    pub struct ListConstraint {
320        /// Indicates whether values grouped into categories can be used in
321        /// `Policy.allowed_values` and `Policy.denied_values`. For example,
322        /// `"in:Python"` would match any value in the 'Python' group.
323        pub supports_in: bool,
324
325        /// Indicates whether subtrees of the Resource Manager resource hierarchy
326        /// can be used in `Policy.allowed_values` and `Policy.denied_values`. For
327        /// example, `"under:folders/123"` would match any resource under the
328        /// 'folders/123' folder.
329        pub supports_under: bool,
330
331        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
332    }
333
334    impl ListConstraint {
335        pub fn new() -> Self {
336            std::default::Default::default()
337        }
338
339        /// Sets the value of [supports_in][crate::model::constraint::ListConstraint::supports_in].
340        ///
341        /// # Example
342        /// ```ignore,no_run
343        /// # use google_cloud_orgpolicy_v2::model::constraint::ListConstraint;
344        /// let x = ListConstraint::new().set_supports_in(true);
345        /// ```
346        pub fn set_supports_in<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
347            self.supports_in = v.into();
348            self
349        }
350
351        /// Sets the value of [supports_under][crate::model::constraint::ListConstraint::supports_under].
352        ///
353        /// # Example
354        /// ```ignore,no_run
355        /// # use google_cloud_orgpolicy_v2::model::constraint::ListConstraint;
356        /// let x = ListConstraint::new().set_supports_under(true);
357        /// ```
358        pub fn set_supports_under<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
359            self.supports_under = v.into();
360            self
361        }
362    }
363
364    impl wkt::message::Message for ListConstraint {
365        fn typename() -> &'static str {
366            "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint.ListConstraint"
367        }
368    }
369
370    /// Custom constraint definition. Defines this as a managed constraint.
371    #[derive(Clone, Default, PartialEq)]
372    #[non_exhaustive]
373    pub struct CustomConstraintDefinition {
374        /// The resource instance type on which this policy applies. Format will be
375        /// of the form : `<service name>/<type>` Example:
376        ///
377        /// * `compute.googleapis.com/Instance`.
378        pub resource_types: std::vec::Vec<std::string::String>,
379
380        /// All the operations being applied for this constraint.
381        pub method_types:
382            std::vec::Vec<crate::model::constraint::custom_constraint_definition::MethodType>,
383
384        /// Org policy condition/expression. For example:
385        /// `resource.instanceName.matches("[production|test]_.*_(\d)+")` or,
386        /// `resource.management.auto_upgrade == true`
387        ///
388        /// The max length of the condition is 1000 characters.
389        pub condition: std::string::String,
390
391        /// Allow or deny type.
392        pub action_type: crate::model::constraint::custom_constraint_definition::ActionType,
393
394        /// Stores the structure of
395        /// [`Parameters`][google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.Parameter]
396        /// used by the constraint condition. The key of `map` represents the name of
397        /// the parameter.
398        ///
399        /// [google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.Parameter]: crate::model::constraint::custom_constraint_definition::Parameter
400        pub parameters: std::collections::HashMap<
401            std::string::String,
402            crate::model::constraint::custom_constraint_definition::Parameter,
403        >,
404
405        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
406    }
407
408    impl CustomConstraintDefinition {
409        pub fn new() -> Self {
410            std::default::Default::default()
411        }
412
413        /// Sets the value of [resource_types][crate::model::constraint::CustomConstraintDefinition::resource_types].
414        ///
415        /// # Example
416        /// ```ignore,no_run
417        /// # use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
418        /// let x = CustomConstraintDefinition::new().set_resource_types(["a", "b", "c"]);
419        /// ```
420        pub fn set_resource_types<T, V>(mut self, v: T) -> Self
421        where
422            T: std::iter::IntoIterator<Item = V>,
423            V: std::convert::Into<std::string::String>,
424        {
425            use std::iter::Iterator;
426            self.resource_types = v.into_iter().map(|i| i.into()).collect();
427            self
428        }
429
430        /// Sets the value of [method_types][crate::model::constraint::CustomConstraintDefinition::method_types].
431        ///
432        /// # Example
433        /// ```ignore,no_run
434        /// # use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
435        /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::MethodType;
436        /// let x = CustomConstraintDefinition::new().set_method_types([
437        ///     MethodType::Create,
438        ///     MethodType::Update,
439        ///     MethodType::Delete,
440        /// ]);
441        /// ```
442        pub fn set_method_types<T, V>(mut self, v: T) -> Self
443        where
444            T: std::iter::IntoIterator<Item = V>,
445            V: std::convert::Into<
446                    crate::model::constraint::custom_constraint_definition::MethodType,
447                >,
448        {
449            use std::iter::Iterator;
450            self.method_types = v.into_iter().map(|i| i.into()).collect();
451            self
452        }
453
454        /// Sets the value of [condition][crate::model::constraint::CustomConstraintDefinition::condition].
455        ///
456        /// # Example
457        /// ```ignore,no_run
458        /// # use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
459        /// let x = CustomConstraintDefinition::new().set_condition("example");
460        /// ```
461        pub fn set_condition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
462            self.condition = v.into();
463            self
464        }
465
466        /// Sets the value of [action_type][crate::model::constraint::CustomConstraintDefinition::action_type].
467        ///
468        /// # Example
469        /// ```ignore,no_run
470        /// # use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
471        /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::ActionType;
472        /// let x0 = CustomConstraintDefinition::new().set_action_type(ActionType::Allow);
473        /// let x1 = CustomConstraintDefinition::new().set_action_type(ActionType::Deny);
474        /// ```
475        pub fn set_action_type<
476            T: std::convert::Into<crate::model::constraint::custom_constraint_definition::ActionType>,
477        >(
478            mut self,
479            v: T,
480        ) -> Self {
481            self.action_type = v.into();
482            self
483        }
484
485        /// Sets the value of [parameters][crate::model::constraint::CustomConstraintDefinition::parameters].
486        ///
487        /// # Example
488        /// ```ignore,no_run
489        /// # use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
490        /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
491        /// let x = CustomConstraintDefinition::new().set_parameters([
492        ///     ("key0", Parameter::default()/* use setters */),
493        ///     ("key1", Parameter::default()/* use (different) setters */),
494        /// ]);
495        /// ```
496        pub fn set_parameters<T, K, V>(mut self, v: T) -> Self
497        where
498            T: std::iter::IntoIterator<Item = (K, V)>,
499            K: std::convert::Into<std::string::String>,
500            V: std::convert::Into<
501                    crate::model::constraint::custom_constraint_definition::Parameter,
502                >,
503        {
504            use std::iter::Iterator;
505            self.parameters = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
506            self
507        }
508    }
509
510    impl wkt::message::Message for CustomConstraintDefinition {
511        fn typename() -> &'static str {
512            "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition"
513        }
514    }
515
516    /// Defines additional types related to [CustomConstraintDefinition].
517    pub mod custom_constraint_definition {
518        #[allow(unused_imports)]
519        use super::*;
520
521        /// Defines a parameter structure.
522        #[derive(Clone, Default, PartialEq)]
523        #[non_exhaustive]
524        pub struct Parameter {
525            /// Type of the parameter.
526            pub r#type: crate::model::constraint::custom_constraint_definition::parameter::Type,
527
528            /// Sets the value of the parameter in an assignment if no value is given.
529            pub default_value: std::option::Option<wkt::Value>,
530
531            /// Provides a CEL expression to specify the acceptable parameter values
532            /// during assignment.
533            /// For example, parameterName in ("parameterValue1", "parameterValue2")
534            pub valid_values_expr: std::string::String,
535
536            /// Defines subproperties primarily used by the UI to display user-friendly
537            /// information.
538            pub metadata: std::option::Option<
539                crate::model::constraint::custom_constraint_definition::parameter::Metadata,
540            >,
541
542            /// Determines the parameter's value structure.
543            /// For example, `LIST<STRING>` can be specified by defining `type: LIST`,
544            /// and `item: STRING`.
545            pub item: crate::model::constraint::custom_constraint_definition::parameter::Type,
546
547            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
548        }
549
550        impl Parameter {
551            pub fn new() -> Self {
552                std::default::Default::default()
553            }
554
555            /// Sets the value of [r#type][crate::model::constraint::custom_constraint_definition::Parameter::type].
556            ///
557            /// # Example
558            /// ```ignore,no_run
559            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
560            /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::parameter::Type;
561            /// let x0 = Parameter::new().set_type(Type::List);
562            /// let x1 = Parameter::new().set_type(Type::String);
563            /// let x2 = Parameter::new().set_type(Type::Boolean);
564            /// ```
565            pub fn set_type<
566                T: std::convert::Into<
567                        crate::model::constraint::custom_constraint_definition::parameter::Type,
568                    >,
569            >(
570                mut self,
571                v: T,
572            ) -> Self {
573                self.r#type = v.into();
574                self
575            }
576
577            /// Sets the value of [default_value][crate::model::constraint::custom_constraint_definition::Parameter::default_value].
578            ///
579            /// # Example
580            /// ```ignore,no_run
581            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
582            /// use wkt::Value;
583            /// let x = Parameter::new().set_default_value(Value::default()/* use setters */);
584            /// ```
585            pub fn set_default_value<T>(mut self, v: T) -> Self
586            where
587                T: std::convert::Into<wkt::Value>,
588            {
589                self.default_value = std::option::Option::Some(v.into());
590                self
591            }
592
593            /// Sets or clears the value of [default_value][crate::model::constraint::custom_constraint_definition::Parameter::default_value].
594            ///
595            /// # Example
596            /// ```ignore,no_run
597            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
598            /// use wkt::Value;
599            /// let x = Parameter::new().set_or_clear_default_value(Some(Value::default()/* use setters */));
600            /// let x = Parameter::new().set_or_clear_default_value(None::<Value>);
601            /// ```
602            pub fn set_or_clear_default_value<T>(mut self, v: std::option::Option<T>) -> Self
603            where
604                T: std::convert::Into<wkt::Value>,
605            {
606                self.default_value = v.map(|x| x.into());
607                self
608            }
609
610            /// Sets the value of [valid_values_expr][crate::model::constraint::custom_constraint_definition::Parameter::valid_values_expr].
611            ///
612            /// # Example
613            /// ```ignore,no_run
614            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
615            /// let x = Parameter::new().set_valid_values_expr("example");
616            /// ```
617            pub fn set_valid_values_expr<T: std::convert::Into<std::string::String>>(
618                mut self,
619                v: T,
620            ) -> Self {
621                self.valid_values_expr = v.into();
622                self
623            }
624
625            /// Sets the value of [metadata][crate::model::constraint::custom_constraint_definition::Parameter::metadata].
626            ///
627            /// # Example
628            /// ```ignore,no_run
629            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
630            /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::parameter::Metadata;
631            /// let x = Parameter::new().set_metadata(Metadata::default()/* use setters */);
632            /// ```
633            pub fn set_metadata<T>(mut self, v: T) -> Self
634            where
635                T: std::convert::Into<
636                        crate::model::constraint::custom_constraint_definition::parameter::Metadata,
637                    >,
638            {
639                self.metadata = std::option::Option::Some(v.into());
640                self
641            }
642
643            /// Sets or clears the value of [metadata][crate::model::constraint::custom_constraint_definition::Parameter::metadata].
644            ///
645            /// # Example
646            /// ```ignore,no_run
647            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
648            /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::parameter::Metadata;
649            /// let x = Parameter::new().set_or_clear_metadata(Some(Metadata::default()/* use setters */));
650            /// let x = Parameter::new().set_or_clear_metadata(None::<Metadata>);
651            /// ```
652            pub fn set_or_clear_metadata<T>(mut self, v: std::option::Option<T>) -> Self
653            where
654                T: std::convert::Into<
655                        crate::model::constraint::custom_constraint_definition::parameter::Metadata,
656                    >,
657            {
658                self.metadata = v.map(|x| x.into());
659                self
660            }
661
662            /// Sets the value of [item][crate::model::constraint::custom_constraint_definition::Parameter::item].
663            ///
664            /// # Example
665            /// ```ignore,no_run
666            /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::Parameter;
667            /// use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::parameter::Type;
668            /// let x0 = Parameter::new().set_item(Type::List);
669            /// let x1 = Parameter::new().set_item(Type::String);
670            /// let x2 = Parameter::new().set_item(Type::Boolean);
671            /// ```
672            pub fn set_item<
673                T: std::convert::Into<
674                        crate::model::constraint::custom_constraint_definition::parameter::Type,
675                    >,
676            >(
677                mut self,
678                v: T,
679            ) -> Self {
680                self.item = v.into();
681                self
682            }
683        }
684
685        impl wkt::message::Message for Parameter {
686            fn typename() -> &'static str {
687                "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.Parameter"
688            }
689        }
690
691        /// Defines additional types related to [Parameter].
692        pub mod parameter {
693            #[allow(unused_imports)]
694            use super::*;
695
696            /// Defines Metadata structure.
697            #[derive(Clone, Default, PartialEq)]
698            #[non_exhaustive]
699            pub struct Metadata {
700                /// Detailed description of what this `parameter` is and use of it.
701                /// Mutable.
702                pub description: std::string::String,
703
704                pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
705            }
706
707            impl Metadata {
708                pub fn new() -> Self {
709                    std::default::Default::default()
710                }
711
712                /// Sets the value of [description][crate::model::constraint::custom_constraint_definition::parameter::Metadata::description].
713                ///
714                /// # Example
715                /// ```ignore,no_run
716                /// # use google_cloud_orgpolicy_v2::model::constraint::custom_constraint_definition::parameter::Metadata;
717                /// let x = Metadata::new().set_description("example");
718                /// ```
719                pub fn set_description<T: std::convert::Into<std::string::String>>(
720                    mut self,
721                    v: T,
722                ) -> Self {
723                    self.description = v.into();
724                    self
725                }
726            }
727
728            impl wkt::message::Message for Metadata {
729                fn typename() -> &'static str {
730                    "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.Parameter.Metadata"
731                }
732            }
733
734            /// All valid types of parameter.
735            ///
736            /// # Working with unknown values
737            ///
738            /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
739            /// additional enum variants at any time. Adding new variants is not considered
740            /// a breaking change. Applications should write their code in anticipation of:
741            ///
742            /// - New values appearing in future releases of the client library, **and**
743            /// - New values received dynamically, without application changes.
744            ///
745            /// Please consult the [Working with enums] section in the user guide for some
746            /// guidelines.
747            ///
748            /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
749            #[derive(Clone, Debug, PartialEq)]
750            #[non_exhaustive]
751            pub enum Type {
752                /// This is only used for distinguishing unset values and should never be
753                /// used. Results in an error.
754                Unspecified,
755                /// List parameter type.
756                List,
757                /// String parameter type.
758                String,
759                /// Boolean parameter type.
760                Boolean,
761                /// If set, the enum was initialized with an unknown value.
762                ///
763                /// Applications can examine the value using [Type::value] or
764                /// [Type::name].
765                UnknownValue(r#type::UnknownValue),
766            }
767
768            #[doc(hidden)]
769            pub mod r#type {
770                #[allow(unused_imports)]
771                use super::*;
772                #[derive(Clone, Debug, PartialEq)]
773                pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
774            }
775
776            impl Type {
777                /// Gets the enum value.
778                ///
779                /// Returns `None` if the enum contains an unknown value deserialized from
780                /// the string representation of enums.
781                pub fn value(&self) -> std::option::Option<i32> {
782                    match self {
783                        Self::Unspecified => std::option::Option::Some(0),
784                        Self::List => std::option::Option::Some(1),
785                        Self::String => std::option::Option::Some(2),
786                        Self::Boolean => std::option::Option::Some(3),
787                        Self::UnknownValue(u) => u.0.value(),
788                    }
789                }
790
791                /// Gets the enum value as a string.
792                ///
793                /// Returns `None` if the enum contains an unknown value deserialized from
794                /// the integer representation of enums.
795                pub fn name(&self) -> std::option::Option<&str> {
796                    match self {
797                        Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
798                        Self::List => std::option::Option::Some("LIST"),
799                        Self::String => std::option::Option::Some("STRING"),
800                        Self::Boolean => std::option::Option::Some("BOOLEAN"),
801                        Self::UnknownValue(u) => u.0.name(),
802                    }
803                }
804            }
805
806            impl std::default::Default for Type {
807                fn default() -> Self {
808                    use std::convert::From;
809                    Self::from(0)
810                }
811            }
812
813            impl std::fmt::Display for Type {
814                fn fmt(
815                    &self,
816                    f: &mut std::fmt::Formatter<'_>,
817                ) -> std::result::Result<(), std::fmt::Error> {
818                    wkt::internal::display_enum(f, self.name(), self.value())
819                }
820            }
821
822            impl std::convert::From<i32> for Type {
823                fn from(value: i32) -> Self {
824                    match value {
825                        0 => Self::Unspecified,
826                        1 => Self::List,
827                        2 => Self::String,
828                        3 => Self::Boolean,
829                        _ => Self::UnknownValue(r#type::UnknownValue(
830                            wkt::internal::UnknownEnumValue::Integer(value),
831                        )),
832                    }
833                }
834            }
835
836            impl std::convert::From<&str> for Type {
837                fn from(value: &str) -> Self {
838                    use std::string::ToString;
839                    match value {
840                        "TYPE_UNSPECIFIED" => Self::Unspecified,
841                        "LIST" => Self::List,
842                        "STRING" => Self::String,
843                        "BOOLEAN" => Self::Boolean,
844                        _ => Self::UnknownValue(r#type::UnknownValue(
845                            wkt::internal::UnknownEnumValue::String(value.to_string()),
846                        )),
847                    }
848                }
849            }
850
851            impl serde::ser::Serialize for Type {
852                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
853                where
854                    S: serde::Serializer,
855                {
856                    match self {
857                        Self::Unspecified => serializer.serialize_i32(0),
858                        Self::List => serializer.serialize_i32(1),
859                        Self::String => serializer.serialize_i32(2),
860                        Self::Boolean => serializer.serialize_i32(3),
861                        Self::UnknownValue(u) => u.0.serialize(serializer),
862                    }
863                }
864            }
865
866            impl<'de> serde::de::Deserialize<'de> for Type {
867                fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
868                where
869                    D: serde::Deserializer<'de>,
870                {
871                    deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
872                        ".google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.Parameter.Type"))
873                }
874            }
875        }
876
877        /// The operation for which this constraint will be applied. To apply this
878        /// constraint only when creating new resources, the `method_types` should be
879        /// `CREATE` only. To apply this constraint when creating or deleting
880        /// resources, the `method_types` should be `CREATE` and `DELETE`.
881        ///
882        /// `UPDATE`-only custom constraints are not supported. Use `CREATE` or
883        /// `CREATE, UPDATE`.
884        ///
885        /// # Working with unknown values
886        ///
887        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
888        /// additional enum variants at any time. Adding new variants is not considered
889        /// a breaking change. Applications should write their code in anticipation of:
890        ///
891        /// - New values appearing in future releases of the client library, **and**
892        /// - New values received dynamically, without application changes.
893        ///
894        /// Please consult the [Working with enums] section in the user guide for some
895        /// guidelines.
896        ///
897        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
898        #[derive(Clone, Debug, PartialEq)]
899        #[non_exhaustive]
900        pub enum MethodType {
901            /// This is only used for distinguishing unset values and should never be
902            /// used. Results in an error.
903            Unspecified,
904            /// Constraint applied when creating the resource.
905            Create,
906            /// Constraint applied when updating the resource.
907            Update,
908            /// Constraint applied when deleting the resource.
909            /// Not currently supported.
910            Delete,
911            /// Constraint applied when removing an IAM grant.
912            RemoveGrant,
913            /// Constraint applied when enforcing forced tagging.
914            GovernTags,
915            /// If set, the enum was initialized with an unknown value.
916            ///
917            /// Applications can examine the value using [MethodType::value] or
918            /// [MethodType::name].
919            UnknownValue(method_type::UnknownValue),
920        }
921
922        #[doc(hidden)]
923        pub mod method_type {
924            #[allow(unused_imports)]
925            use super::*;
926            #[derive(Clone, Debug, PartialEq)]
927            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
928        }
929
930        impl MethodType {
931            /// Gets the enum value.
932            ///
933            /// Returns `None` if the enum contains an unknown value deserialized from
934            /// the string representation of enums.
935            pub fn value(&self) -> std::option::Option<i32> {
936                match self {
937                    Self::Unspecified => std::option::Option::Some(0),
938                    Self::Create => std::option::Option::Some(1),
939                    Self::Update => std::option::Option::Some(2),
940                    Self::Delete => std::option::Option::Some(3),
941                    Self::RemoveGrant => std::option::Option::Some(4),
942                    Self::GovernTags => std::option::Option::Some(5),
943                    Self::UnknownValue(u) => u.0.value(),
944                }
945            }
946
947            /// Gets the enum value as a string.
948            ///
949            /// Returns `None` if the enum contains an unknown value deserialized from
950            /// the integer representation of enums.
951            pub fn name(&self) -> std::option::Option<&str> {
952                match self {
953                    Self::Unspecified => std::option::Option::Some("METHOD_TYPE_UNSPECIFIED"),
954                    Self::Create => std::option::Option::Some("CREATE"),
955                    Self::Update => std::option::Option::Some("UPDATE"),
956                    Self::Delete => std::option::Option::Some("DELETE"),
957                    Self::RemoveGrant => std::option::Option::Some("REMOVE_GRANT"),
958                    Self::GovernTags => std::option::Option::Some("GOVERN_TAGS"),
959                    Self::UnknownValue(u) => u.0.name(),
960                }
961            }
962        }
963
964        impl std::default::Default for MethodType {
965            fn default() -> Self {
966                use std::convert::From;
967                Self::from(0)
968            }
969        }
970
971        impl std::fmt::Display for MethodType {
972            fn fmt(
973                &self,
974                f: &mut std::fmt::Formatter<'_>,
975            ) -> std::result::Result<(), std::fmt::Error> {
976                wkt::internal::display_enum(f, self.name(), self.value())
977            }
978        }
979
980        impl std::convert::From<i32> for MethodType {
981            fn from(value: i32) -> Self {
982                match value {
983                    0 => Self::Unspecified,
984                    1 => Self::Create,
985                    2 => Self::Update,
986                    3 => Self::Delete,
987                    4 => Self::RemoveGrant,
988                    5 => Self::GovernTags,
989                    _ => Self::UnknownValue(method_type::UnknownValue(
990                        wkt::internal::UnknownEnumValue::Integer(value),
991                    )),
992                }
993            }
994        }
995
996        impl std::convert::From<&str> for MethodType {
997            fn from(value: &str) -> Self {
998                use std::string::ToString;
999                match value {
1000                    "METHOD_TYPE_UNSPECIFIED" => Self::Unspecified,
1001                    "CREATE" => Self::Create,
1002                    "UPDATE" => Self::Update,
1003                    "DELETE" => Self::Delete,
1004                    "REMOVE_GRANT" => Self::RemoveGrant,
1005                    "GOVERN_TAGS" => Self::GovernTags,
1006                    _ => Self::UnknownValue(method_type::UnknownValue(
1007                        wkt::internal::UnknownEnumValue::String(value.to_string()),
1008                    )),
1009                }
1010            }
1011        }
1012
1013        impl serde::ser::Serialize for MethodType {
1014            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1015            where
1016                S: serde::Serializer,
1017            {
1018                match self {
1019                    Self::Unspecified => serializer.serialize_i32(0),
1020                    Self::Create => serializer.serialize_i32(1),
1021                    Self::Update => serializer.serialize_i32(2),
1022                    Self::Delete => serializer.serialize_i32(3),
1023                    Self::RemoveGrant => serializer.serialize_i32(4),
1024                    Self::GovernTags => serializer.serialize_i32(5),
1025                    Self::UnknownValue(u) => u.0.serialize(serializer),
1026                }
1027            }
1028        }
1029
1030        impl<'de> serde::de::Deserialize<'de> for MethodType {
1031            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1032            where
1033                D: serde::Deserializer<'de>,
1034            {
1035                deserializer.deserialize_any(wkt::internal::EnumVisitor::<MethodType>::new(
1036                    ".google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.MethodType",
1037                ))
1038            }
1039        }
1040
1041        /// Allow or deny type.
1042        ///
1043        /// # Working with unknown values
1044        ///
1045        /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1046        /// additional enum variants at any time. Adding new variants is not considered
1047        /// a breaking change. Applications should write their code in anticipation of:
1048        ///
1049        /// - New values appearing in future releases of the client library, **and**
1050        /// - New values received dynamically, without application changes.
1051        ///
1052        /// Please consult the [Working with enums] section in the user guide for some
1053        /// guidelines.
1054        ///
1055        /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1056        #[derive(Clone, Debug, PartialEq)]
1057        #[non_exhaustive]
1058        pub enum ActionType {
1059            /// This is only used for distinguishing unset values and should never be
1060            /// used. Results in an error.
1061            Unspecified,
1062            /// Allowed action type.
1063            Allow,
1064            /// Deny action type.
1065            Deny,
1066            /// If set, the enum was initialized with an unknown value.
1067            ///
1068            /// Applications can examine the value using [ActionType::value] or
1069            /// [ActionType::name].
1070            UnknownValue(action_type::UnknownValue),
1071        }
1072
1073        #[doc(hidden)]
1074        pub mod action_type {
1075            #[allow(unused_imports)]
1076            use super::*;
1077            #[derive(Clone, Debug, PartialEq)]
1078            pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1079        }
1080
1081        impl ActionType {
1082            /// Gets the enum value.
1083            ///
1084            /// Returns `None` if the enum contains an unknown value deserialized from
1085            /// the string representation of enums.
1086            pub fn value(&self) -> std::option::Option<i32> {
1087                match self {
1088                    Self::Unspecified => std::option::Option::Some(0),
1089                    Self::Allow => std::option::Option::Some(1),
1090                    Self::Deny => std::option::Option::Some(2),
1091                    Self::UnknownValue(u) => u.0.value(),
1092                }
1093            }
1094
1095            /// Gets the enum value as a string.
1096            ///
1097            /// Returns `None` if the enum contains an unknown value deserialized from
1098            /// the integer representation of enums.
1099            pub fn name(&self) -> std::option::Option<&str> {
1100                match self {
1101                    Self::Unspecified => std::option::Option::Some("ACTION_TYPE_UNSPECIFIED"),
1102                    Self::Allow => std::option::Option::Some("ALLOW"),
1103                    Self::Deny => std::option::Option::Some("DENY"),
1104                    Self::UnknownValue(u) => u.0.name(),
1105                }
1106            }
1107        }
1108
1109        impl std::default::Default for ActionType {
1110            fn default() -> Self {
1111                use std::convert::From;
1112                Self::from(0)
1113            }
1114        }
1115
1116        impl std::fmt::Display for ActionType {
1117            fn fmt(
1118                &self,
1119                f: &mut std::fmt::Formatter<'_>,
1120            ) -> std::result::Result<(), std::fmt::Error> {
1121                wkt::internal::display_enum(f, self.name(), self.value())
1122            }
1123        }
1124
1125        impl std::convert::From<i32> for ActionType {
1126            fn from(value: i32) -> Self {
1127                match value {
1128                    0 => Self::Unspecified,
1129                    1 => Self::Allow,
1130                    2 => Self::Deny,
1131                    _ => Self::UnknownValue(action_type::UnknownValue(
1132                        wkt::internal::UnknownEnumValue::Integer(value),
1133                    )),
1134                }
1135            }
1136        }
1137
1138        impl std::convert::From<&str> for ActionType {
1139            fn from(value: &str) -> Self {
1140                use std::string::ToString;
1141                match value {
1142                    "ACTION_TYPE_UNSPECIFIED" => Self::Unspecified,
1143                    "ALLOW" => Self::Allow,
1144                    "DENY" => Self::Deny,
1145                    _ => Self::UnknownValue(action_type::UnknownValue(
1146                        wkt::internal::UnknownEnumValue::String(value.to_string()),
1147                    )),
1148                }
1149            }
1150        }
1151
1152        impl serde::ser::Serialize for ActionType {
1153            fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1154            where
1155                S: serde::Serializer,
1156            {
1157                match self {
1158                    Self::Unspecified => serializer.serialize_i32(0),
1159                    Self::Allow => serializer.serialize_i32(1),
1160                    Self::Deny => serializer.serialize_i32(2),
1161                    Self::UnknownValue(u) => u.0.serialize(serializer),
1162                }
1163            }
1164        }
1165
1166        impl<'de> serde::de::Deserialize<'de> for ActionType {
1167            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1168            where
1169                D: serde::Deserializer<'de>,
1170            {
1171                deserializer.deserialize_any(wkt::internal::EnumVisitor::<ActionType>::new(
1172                    ".google.cloud.orgpolicy.v2.Constraint.CustomConstraintDefinition.ActionType",
1173                ))
1174            }
1175        }
1176    }
1177
1178    /// A constraint type is enforced or not enforced, which is configured in the
1179    /// [`PolicyRule`][google.cloud.orgpolicy.v2.PolicySpec.PolicyRule].
1180    ///
1181    /// If `customConstraintDefinition` is defined, this constraint is a managed
1182    /// constraint.
1183    ///
1184    /// [google.cloud.orgpolicy.v2.PolicySpec.PolicyRule]: crate::model::policy_spec::PolicyRule
1185    #[derive(Clone, Default, PartialEq)]
1186    #[non_exhaustive]
1187    pub struct BooleanConstraint {
1188        /// Custom constraint definition. Defines this as a managed constraint.
1189        pub custom_constraint_definition:
1190            std::option::Option<crate::model::constraint::CustomConstraintDefinition>,
1191
1192        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1193    }
1194
1195    impl BooleanConstraint {
1196        pub fn new() -> Self {
1197            std::default::Default::default()
1198        }
1199
1200        /// Sets the value of [custom_constraint_definition][crate::model::constraint::BooleanConstraint::custom_constraint_definition].
1201        ///
1202        /// # Example
1203        /// ```ignore,no_run
1204        /// # use google_cloud_orgpolicy_v2::model::constraint::BooleanConstraint;
1205        /// use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
1206        /// let x = BooleanConstraint::new().set_custom_constraint_definition(CustomConstraintDefinition::default()/* use setters */);
1207        /// ```
1208        pub fn set_custom_constraint_definition<T>(mut self, v: T) -> Self
1209        where
1210            T: std::convert::Into<crate::model::constraint::CustomConstraintDefinition>,
1211        {
1212            self.custom_constraint_definition = std::option::Option::Some(v.into());
1213            self
1214        }
1215
1216        /// Sets or clears the value of [custom_constraint_definition][crate::model::constraint::BooleanConstraint::custom_constraint_definition].
1217        ///
1218        /// # Example
1219        /// ```ignore,no_run
1220        /// # use google_cloud_orgpolicy_v2::model::constraint::BooleanConstraint;
1221        /// use google_cloud_orgpolicy_v2::model::constraint::CustomConstraintDefinition;
1222        /// let x = BooleanConstraint::new().set_or_clear_custom_constraint_definition(Some(CustomConstraintDefinition::default()/* use setters */));
1223        /// let x = BooleanConstraint::new().set_or_clear_custom_constraint_definition(None::<CustomConstraintDefinition>);
1224        /// ```
1225        pub fn set_or_clear_custom_constraint_definition<T>(
1226            mut self,
1227            v: std::option::Option<T>,
1228        ) -> Self
1229        where
1230            T: std::convert::Into<crate::model::constraint::CustomConstraintDefinition>,
1231        {
1232            self.custom_constraint_definition = v.map(|x| x.into());
1233            self
1234        }
1235    }
1236
1237    impl wkt::message::Message for BooleanConstraint {
1238        fn typename() -> &'static str {
1239            "type.googleapis.com/google.cloud.orgpolicy.v2.Constraint.BooleanConstraint"
1240        }
1241    }
1242
1243    /// Specifies the default behavior in the absence of any policy for the
1244    /// constraint. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`.
1245    ///
1246    /// Immutable after creation.
1247    ///
1248    /// # Working with unknown values
1249    ///
1250    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1251    /// additional enum variants at any time. Adding new variants is not considered
1252    /// a breaking change. Applications should write their code in anticipation of:
1253    ///
1254    /// - New values appearing in future releases of the client library, **and**
1255    /// - New values received dynamically, without application changes.
1256    ///
1257    /// Please consult the [Working with enums] section in the user guide for some
1258    /// guidelines.
1259    ///
1260    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1261    #[derive(Clone, Debug, PartialEq)]
1262    #[non_exhaustive]
1263    pub enum ConstraintDefault {
1264        /// This is only used for distinguishing unset values and should never be
1265        /// used. Results in an error.
1266        Unspecified,
1267        /// Indicate that all values are allowed for list constraints.
1268        /// Indicate that enforcement is off for boolean constraints.
1269        Allow,
1270        /// Indicate that all values are denied for list constraints.
1271        /// Indicate that enforcement is on for boolean constraints.
1272        Deny,
1273        /// If set, the enum was initialized with an unknown value.
1274        ///
1275        /// Applications can examine the value using [ConstraintDefault::value] or
1276        /// [ConstraintDefault::name].
1277        UnknownValue(constraint_default::UnknownValue),
1278    }
1279
1280    #[doc(hidden)]
1281    pub mod constraint_default {
1282        #[allow(unused_imports)]
1283        use super::*;
1284        #[derive(Clone, Debug, PartialEq)]
1285        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1286    }
1287
1288    impl ConstraintDefault {
1289        /// Gets the enum value.
1290        ///
1291        /// Returns `None` if the enum contains an unknown value deserialized from
1292        /// the string representation of enums.
1293        pub fn value(&self) -> std::option::Option<i32> {
1294            match self {
1295                Self::Unspecified => std::option::Option::Some(0),
1296                Self::Allow => std::option::Option::Some(1),
1297                Self::Deny => std::option::Option::Some(2),
1298                Self::UnknownValue(u) => u.0.value(),
1299            }
1300        }
1301
1302        /// Gets the enum value as a string.
1303        ///
1304        /// Returns `None` if the enum contains an unknown value deserialized from
1305        /// the integer representation of enums.
1306        pub fn name(&self) -> std::option::Option<&str> {
1307            match self {
1308                Self::Unspecified => std::option::Option::Some("CONSTRAINT_DEFAULT_UNSPECIFIED"),
1309                Self::Allow => std::option::Option::Some("ALLOW"),
1310                Self::Deny => std::option::Option::Some("DENY"),
1311                Self::UnknownValue(u) => u.0.name(),
1312            }
1313        }
1314    }
1315
1316    impl std::default::Default for ConstraintDefault {
1317        fn default() -> Self {
1318            use std::convert::From;
1319            Self::from(0)
1320        }
1321    }
1322
1323    impl std::fmt::Display for ConstraintDefault {
1324        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1325            wkt::internal::display_enum(f, self.name(), self.value())
1326        }
1327    }
1328
1329    impl std::convert::From<i32> for ConstraintDefault {
1330        fn from(value: i32) -> Self {
1331            match value {
1332                0 => Self::Unspecified,
1333                1 => Self::Allow,
1334                2 => Self::Deny,
1335                _ => Self::UnknownValue(constraint_default::UnknownValue(
1336                    wkt::internal::UnknownEnumValue::Integer(value),
1337                )),
1338            }
1339        }
1340    }
1341
1342    impl std::convert::From<&str> for ConstraintDefault {
1343        fn from(value: &str) -> Self {
1344            use std::string::ToString;
1345            match value {
1346                "CONSTRAINT_DEFAULT_UNSPECIFIED" => Self::Unspecified,
1347                "ALLOW" => Self::Allow,
1348                "DENY" => Self::Deny,
1349                _ => Self::UnknownValue(constraint_default::UnknownValue(
1350                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1351                )),
1352            }
1353        }
1354    }
1355
1356    impl serde::ser::Serialize for ConstraintDefault {
1357        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1358        where
1359            S: serde::Serializer,
1360        {
1361            match self {
1362                Self::Unspecified => serializer.serialize_i32(0),
1363                Self::Allow => serializer.serialize_i32(1),
1364                Self::Deny => serializer.serialize_i32(2),
1365                Self::UnknownValue(u) => u.0.serialize(serializer),
1366            }
1367        }
1368    }
1369
1370    impl<'de> serde::de::Deserialize<'de> for ConstraintDefault {
1371        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1372        where
1373            D: serde::Deserializer<'de>,
1374        {
1375            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ConstraintDefault>::new(
1376                ".google.cloud.orgpolicy.v2.Constraint.ConstraintDefault",
1377            ))
1378        }
1379    }
1380
1381    /// The type of restrictions for this `Constraint`.
1382    ///
1383    /// Immutable after creation.
1384    #[derive(Clone, Debug, PartialEq)]
1385    #[non_exhaustive]
1386    pub enum ConstraintType {
1387        /// Defines this constraint as being a list constraint.
1388        ListConstraint(std::boxed::Box<crate::model::constraint::ListConstraint>),
1389        /// Defines this constraint as being a boolean constraint.
1390        BooleanConstraint(std::boxed::Box<crate::model::constraint::BooleanConstraint>),
1391    }
1392}
1393
1394/// A custom constraint defined by customers which can *only* be applied to the
1395/// given resource types and organization.
1396///
1397/// By creating a custom constraint, customers can apply policies of this
1398/// custom constraint. *Creating a custom constraint itself does NOT apply any
1399/// policy enforcement*.
1400#[derive(Clone, Default, PartialEq)]
1401#[non_exhaustive]
1402pub struct CustomConstraint {
1403    /// Immutable. Name of the constraint. This is unique within the organization.
1404    /// Format of the name should be
1405    ///
1406    /// * `organizations/{organization_id}/customConstraints/{custom_constraint_id}`
1407    ///
1408    /// Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`
1409    ///
1410    /// The max length is 70 characters and the minimum length is 1. Note that the
1411    /// prefix `organizations/{organization_id}/customConstraints/` is not counted.
1412    pub name: std::string::String,
1413
1414    /// Immutable. The resource instance type on which this policy applies. Format
1415    /// will be of the form : `<service name>/<type>` Example:
1416    ///
1417    /// * `compute.googleapis.com/Instance`.
1418    pub resource_types: std::vec::Vec<std::string::String>,
1419
1420    /// All the operations being applied for this constraint.
1421    pub method_types: std::vec::Vec<crate::model::custom_constraint::MethodType>,
1422
1423    /// A Common Expression Language (CEL) condition which is used in the
1424    /// evaluation of the constraint. For example:
1425    /// `resource.instanceName.matches("[production|test]_.*_(\d)+")` or,
1426    /// `resource.management.auto_upgrade == true`
1427    ///
1428    /// The max length of the condition is 1000 characters.
1429    pub condition: std::string::String,
1430
1431    /// Allow or deny type.
1432    pub action_type: crate::model::custom_constraint::ActionType,
1433
1434    /// One line display name for the UI.
1435    /// The max length of the display_name is 200 characters.
1436    pub display_name: std::string::String,
1437
1438    /// Detailed information about this custom policy constraint.
1439    /// The max length of the description is 2000 characters.
1440    pub description: std::string::String,
1441
1442    /// Output only. The last time this custom constraint was updated. This
1443    /// represents the last time that the `CreateCustomConstraint` or
1444    /// `UpdateCustomConstraint` methods were called.
1445    pub update_time: std::option::Option<wkt::Timestamp>,
1446
1447    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1448}
1449
1450impl CustomConstraint {
1451    pub fn new() -> Self {
1452        std::default::Default::default()
1453    }
1454
1455    /// Sets the value of [name][crate::model::CustomConstraint::name].
1456    ///
1457    /// # Example
1458    /// ```ignore,no_run
1459    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1460    /// let x = CustomConstraint::new().set_name("example");
1461    /// ```
1462    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1463        self.name = v.into();
1464        self
1465    }
1466
1467    /// Sets the value of [resource_types][crate::model::CustomConstraint::resource_types].
1468    ///
1469    /// # Example
1470    /// ```ignore,no_run
1471    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1472    /// let x = CustomConstraint::new().set_resource_types(["a", "b", "c"]);
1473    /// ```
1474    pub fn set_resource_types<T, V>(mut self, v: T) -> Self
1475    where
1476        T: std::iter::IntoIterator<Item = V>,
1477        V: std::convert::Into<std::string::String>,
1478    {
1479        use std::iter::Iterator;
1480        self.resource_types = v.into_iter().map(|i| i.into()).collect();
1481        self
1482    }
1483
1484    /// Sets the value of [method_types][crate::model::CustomConstraint::method_types].
1485    ///
1486    /// # Example
1487    /// ```ignore,no_run
1488    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1489    /// use google_cloud_orgpolicy_v2::model::custom_constraint::MethodType;
1490    /// let x = CustomConstraint::new().set_method_types([
1491    ///     MethodType::Create,
1492    ///     MethodType::Update,
1493    ///     MethodType::Delete,
1494    /// ]);
1495    /// ```
1496    pub fn set_method_types<T, V>(mut self, v: T) -> Self
1497    where
1498        T: std::iter::IntoIterator<Item = V>,
1499        V: std::convert::Into<crate::model::custom_constraint::MethodType>,
1500    {
1501        use std::iter::Iterator;
1502        self.method_types = v.into_iter().map(|i| i.into()).collect();
1503        self
1504    }
1505
1506    /// Sets the value of [condition][crate::model::CustomConstraint::condition].
1507    ///
1508    /// # Example
1509    /// ```ignore,no_run
1510    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1511    /// let x = CustomConstraint::new().set_condition("example");
1512    /// ```
1513    pub fn set_condition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1514        self.condition = v.into();
1515        self
1516    }
1517
1518    /// Sets the value of [action_type][crate::model::CustomConstraint::action_type].
1519    ///
1520    /// # Example
1521    /// ```ignore,no_run
1522    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1523    /// use google_cloud_orgpolicy_v2::model::custom_constraint::ActionType;
1524    /// let x0 = CustomConstraint::new().set_action_type(ActionType::Allow);
1525    /// let x1 = CustomConstraint::new().set_action_type(ActionType::Deny);
1526    /// ```
1527    pub fn set_action_type<T: std::convert::Into<crate::model::custom_constraint::ActionType>>(
1528        mut self,
1529        v: T,
1530    ) -> Self {
1531        self.action_type = v.into();
1532        self
1533    }
1534
1535    /// Sets the value of [display_name][crate::model::CustomConstraint::display_name].
1536    ///
1537    /// # Example
1538    /// ```ignore,no_run
1539    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1540    /// let x = CustomConstraint::new().set_display_name("example");
1541    /// ```
1542    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1543        self.display_name = v.into();
1544        self
1545    }
1546
1547    /// Sets the value of [description][crate::model::CustomConstraint::description].
1548    ///
1549    /// # Example
1550    /// ```ignore,no_run
1551    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1552    /// let x = CustomConstraint::new().set_description("example");
1553    /// ```
1554    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1555        self.description = v.into();
1556        self
1557    }
1558
1559    /// Sets the value of [update_time][crate::model::CustomConstraint::update_time].
1560    ///
1561    /// # Example
1562    /// ```ignore,no_run
1563    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1564    /// use wkt::Timestamp;
1565    /// let x = CustomConstraint::new().set_update_time(Timestamp::default()/* use setters */);
1566    /// ```
1567    pub fn set_update_time<T>(mut self, v: T) -> Self
1568    where
1569        T: std::convert::Into<wkt::Timestamp>,
1570    {
1571        self.update_time = std::option::Option::Some(v.into());
1572        self
1573    }
1574
1575    /// Sets or clears the value of [update_time][crate::model::CustomConstraint::update_time].
1576    ///
1577    /// # Example
1578    /// ```ignore,no_run
1579    /// # use google_cloud_orgpolicy_v2::model::CustomConstraint;
1580    /// use wkt::Timestamp;
1581    /// let x = CustomConstraint::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
1582    /// let x = CustomConstraint::new().set_or_clear_update_time(None::<Timestamp>);
1583    /// ```
1584    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
1585    where
1586        T: std::convert::Into<wkt::Timestamp>,
1587    {
1588        self.update_time = v.map(|x| x.into());
1589        self
1590    }
1591}
1592
1593impl wkt::message::Message for CustomConstraint {
1594    fn typename() -> &'static str {
1595        "type.googleapis.com/google.cloud.orgpolicy.v2.CustomConstraint"
1596    }
1597}
1598
1599/// Defines additional types related to [CustomConstraint].
1600pub mod custom_constraint {
1601    #[allow(unused_imports)]
1602    use super::*;
1603
1604    /// The operation for which this constraint will be applied. To apply this
1605    /// constraint only when creating new resources, the `method_types` should be
1606    /// `CREATE` only. To apply this constraint when creating or deleting
1607    /// resources, the `method_types` should be `CREATE` and `DELETE`.
1608    ///
1609    /// `UPDATE` only custom constraints are not supported. Use `CREATE` or
1610    /// `CREATE, UPDATE`.
1611    ///
1612    /// # Working with unknown values
1613    ///
1614    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1615    /// additional enum variants at any time. Adding new variants is not considered
1616    /// a breaking change. Applications should write their code in anticipation of:
1617    ///
1618    /// - New values appearing in future releases of the client library, **and**
1619    /// - New values received dynamically, without application changes.
1620    ///
1621    /// Please consult the [Working with enums] section in the user guide for some
1622    /// guidelines.
1623    ///
1624    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1625    #[derive(Clone, Debug, PartialEq)]
1626    #[non_exhaustive]
1627    pub enum MethodType {
1628        /// This is only used for distinguishing unset values and should never be
1629        /// used. Results in an error.
1630        Unspecified,
1631        /// Constraint applied when creating the resource.
1632        Create,
1633        /// Constraint applied when updating the resource.
1634        Update,
1635        /// Constraint applied when deleting the resource.
1636        /// Not currently supported.
1637        Delete,
1638        /// Constraint applied when removing an IAM grant.
1639        RemoveGrant,
1640        /// Constraint applied when enforcing forced tagging.
1641        GovernTags,
1642        /// If set, the enum was initialized with an unknown value.
1643        ///
1644        /// Applications can examine the value using [MethodType::value] or
1645        /// [MethodType::name].
1646        UnknownValue(method_type::UnknownValue),
1647    }
1648
1649    #[doc(hidden)]
1650    pub mod method_type {
1651        #[allow(unused_imports)]
1652        use super::*;
1653        #[derive(Clone, Debug, PartialEq)]
1654        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1655    }
1656
1657    impl MethodType {
1658        /// Gets the enum value.
1659        ///
1660        /// Returns `None` if the enum contains an unknown value deserialized from
1661        /// the string representation of enums.
1662        pub fn value(&self) -> std::option::Option<i32> {
1663            match self {
1664                Self::Unspecified => std::option::Option::Some(0),
1665                Self::Create => std::option::Option::Some(1),
1666                Self::Update => std::option::Option::Some(2),
1667                Self::Delete => std::option::Option::Some(3),
1668                Self::RemoveGrant => std::option::Option::Some(4),
1669                Self::GovernTags => std::option::Option::Some(5),
1670                Self::UnknownValue(u) => u.0.value(),
1671            }
1672        }
1673
1674        /// Gets the enum value as a string.
1675        ///
1676        /// Returns `None` if the enum contains an unknown value deserialized from
1677        /// the integer representation of enums.
1678        pub fn name(&self) -> std::option::Option<&str> {
1679            match self {
1680                Self::Unspecified => std::option::Option::Some("METHOD_TYPE_UNSPECIFIED"),
1681                Self::Create => std::option::Option::Some("CREATE"),
1682                Self::Update => std::option::Option::Some("UPDATE"),
1683                Self::Delete => std::option::Option::Some("DELETE"),
1684                Self::RemoveGrant => std::option::Option::Some("REMOVE_GRANT"),
1685                Self::GovernTags => std::option::Option::Some("GOVERN_TAGS"),
1686                Self::UnknownValue(u) => u.0.name(),
1687            }
1688        }
1689    }
1690
1691    impl std::default::Default for MethodType {
1692        fn default() -> Self {
1693            use std::convert::From;
1694            Self::from(0)
1695        }
1696    }
1697
1698    impl std::fmt::Display for MethodType {
1699        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1700            wkt::internal::display_enum(f, self.name(), self.value())
1701        }
1702    }
1703
1704    impl std::convert::From<i32> for MethodType {
1705        fn from(value: i32) -> Self {
1706            match value {
1707                0 => Self::Unspecified,
1708                1 => Self::Create,
1709                2 => Self::Update,
1710                3 => Self::Delete,
1711                4 => Self::RemoveGrant,
1712                5 => Self::GovernTags,
1713                _ => Self::UnknownValue(method_type::UnknownValue(
1714                    wkt::internal::UnknownEnumValue::Integer(value),
1715                )),
1716            }
1717        }
1718    }
1719
1720    impl std::convert::From<&str> for MethodType {
1721        fn from(value: &str) -> Self {
1722            use std::string::ToString;
1723            match value {
1724                "METHOD_TYPE_UNSPECIFIED" => Self::Unspecified,
1725                "CREATE" => Self::Create,
1726                "UPDATE" => Self::Update,
1727                "DELETE" => Self::Delete,
1728                "REMOVE_GRANT" => Self::RemoveGrant,
1729                "GOVERN_TAGS" => Self::GovernTags,
1730                _ => Self::UnknownValue(method_type::UnknownValue(
1731                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1732                )),
1733            }
1734        }
1735    }
1736
1737    impl serde::ser::Serialize for MethodType {
1738        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1739        where
1740            S: serde::Serializer,
1741        {
1742            match self {
1743                Self::Unspecified => serializer.serialize_i32(0),
1744                Self::Create => serializer.serialize_i32(1),
1745                Self::Update => serializer.serialize_i32(2),
1746                Self::Delete => serializer.serialize_i32(3),
1747                Self::RemoveGrant => serializer.serialize_i32(4),
1748                Self::GovernTags => serializer.serialize_i32(5),
1749                Self::UnknownValue(u) => u.0.serialize(serializer),
1750            }
1751        }
1752    }
1753
1754    impl<'de> serde::de::Deserialize<'de> for MethodType {
1755        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1756        where
1757            D: serde::Deserializer<'de>,
1758        {
1759            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MethodType>::new(
1760                ".google.cloud.orgpolicy.v2.CustomConstraint.MethodType",
1761            ))
1762        }
1763    }
1764
1765    /// Allow or deny type.
1766    ///
1767    /// # Working with unknown values
1768    ///
1769    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1770    /// additional enum variants at any time. Adding new variants is not considered
1771    /// a breaking change. Applications should write their code in anticipation of:
1772    ///
1773    /// - New values appearing in future releases of the client library, **and**
1774    /// - New values received dynamically, without application changes.
1775    ///
1776    /// Please consult the [Working with enums] section in the user guide for some
1777    /// guidelines.
1778    ///
1779    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1780    #[derive(Clone, Debug, PartialEq)]
1781    #[non_exhaustive]
1782    pub enum ActionType {
1783        /// This is only used for distinguishing unset values and should never be
1784        /// used. Results in an error.
1785        Unspecified,
1786        /// Allowed action type.
1787        Allow,
1788        /// Deny action type.
1789        Deny,
1790        /// If set, the enum was initialized with an unknown value.
1791        ///
1792        /// Applications can examine the value using [ActionType::value] or
1793        /// [ActionType::name].
1794        UnknownValue(action_type::UnknownValue),
1795    }
1796
1797    #[doc(hidden)]
1798    pub mod action_type {
1799        #[allow(unused_imports)]
1800        use super::*;
1801        #[derive(Clone, Debug, PartialEq)]
1802        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1803    }
1804
1805    impl ActionType {
1806        /// Gets the enum value.
1807        ///
1808        /// Returns `None` if the enum contains an unknown value deserialized from
1809        /// the string representation of enums.
1810        pub fn value(&self) -> std::option::Option<i32> {
1811            match self {
1812                Self::Unspecified => std::option::Option::Some(0),
1813                Self::Allow => std::option::Option::Some(1),
1814                Self::Deny => std::option::Option::Some(2),
1815                Self::UnknownValue(u) => u.0.value(),
1816            }
1817        }
1818
1819        /// Gets the enum value as a string.
1820        ///
1821        /// Returns `None` if the enum contains an unknown value deserialized from
1822        /// the integer representation of enums.
1823        pub fn name(&self) -> std::option::Option<&str> {
1824            match self {
1825                Self::Unspecified => std::option::Option::Some("ACTION_TYPE_UNSPECIFIED"),
1826                Self::Allow => std::option::Option::Some("ALLOW"),
1827                Self::Deny => std::option::Option::Some("DENY"),
1828                Self::UnknownValue(u) => u.0.name(),
1829            }
1830        }
1831    }
1832
1833    impl std::default::Default for ActionType {
1834        fn default() -> Self {
1835            use std::convert::From;
1836            Self::from(0)
1837        }
1838    }
1839
1840    impl std::fmt::Display for ActionType {
1841        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1842            wkt::internal::display_enum(f, self.name(), self.value())
1843        }
1844    }
1845
1846    impl std::convert::From<i32> for ActionType {
1847        fn from(value: i32) -> Self {
1848            match value {
1849                0 => Self::Unspecified,
1850                1 => Self::Allow,
1851                2 => Self::Deny,
1852                _ => Self::UnknownValue(action_type::UnknownValue(
1853                    wkt::internal::UnknownEnumValue::Integer(value),
1854                )),
1855            }
1856        }
1857    }
1858
1859    impl std::convert::From<&str> for ActionType {
1860        fn from(value: &str) -> Self {
1861            use std::string::ToString;
1862            match value {
1863                "ACTION_TYPE_UNSPECIFIED" => Self::Unspecified,
1864                "ALLOW" => Self::Allow,
1865                "DENY" => Self::Deny,
1866                _ => Self::UnknownValue(action_type::UnknownValue(
1867                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1868                )),
1869            }
1870        }
1871    }
1872
1873    impl serde::ser::Serialize for ActionType {
1874        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1875        where
1876            S: serde::Serializer,
1877        {
1878            match self {
1879                Self::Unspecified => serializer.serialize_i32(0),
1880                Self::Allow => serializer.serialize_i32(1),
1881                Self::Deny => serializer.serialize_i32(2),
1882                Self::UnknownValue(u) => u.0.serialize(serializer),
1883            }
1884        }
1885    }
1886
1887    impl<'de> serde::de::Deserialize<'de> for ActionType {
1888        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1889        where
1890            D: serde::Deserializer<'de>,
1891        {
1892            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ActionType>::new(
1893                ".google.cloud.orgpolicy.v2.CustomConstraint.ActionType",
1894            ))
1895        }
1896    }
1897}
1898
1899/// Defines an organization policy which is used to specify constraints
1900/// for configurations of Google Cloud resources.
1901#[derive(Clone, Default, PartialEq)]
1902#[non_exhaustive]
1903pub struct Policy {
1904    /// Immutable. The resource name of the policy. Must be one of the following
1905    /// forms, where `constraint_name` is the name of the constraint which this
1906    /// policy configures:
1907    ///
1908    /// * `projects/{project_number}/policies/{constraint_name}`
1909    /// * `folders/{folder_id}/policies/{constraint_name}`
1910    /// * `organizations/{organization_id}/policies/{constraint_name}`
1911    ///
1912    /// For example, `projects/123/policies/compute.disableSerialPortAccess`.
1913    ///
1914    /// Note: `projects/{project_id}/policies/{constraint_name}` is also an
1915    /// acceptable name for API requests, but responses will return the name using
1916    /// the equivalent project number.
1917    pub name: std::string::String,
1918
1919    /// Basic information about the organization policy.
1920    pub spec: std::option::Option<crate::model::PolicySpec>,
1921
1922    /// Deprecated.
1923    #[deprecated]
1924    pub alternate: std::option::Option<crate::model::AlternatePolicySpec>,
1925
1926    /// Dry-run policy.
1927    /// Audit-only policy, can be used to monitor how the policy would have
1928    /// impacted the existing and future resources if it's enforced.
1929    pub dry_run_spec: std::option::Option<crate::model::PolicySpec>,
1930
1931    /// Optional. An opaque tag indicating the current state of the policy, used
1932    /// for concurrency control. This 'etag' is computed by the server based on the
1933    /// value of other fields, and may be sent on update and delete requests to
1934    /// ensure the client has an up-to-date value before proceeding.
1935    pub etag: std::string::String,
1936
1937    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1938}
1939
1940impl Policy {
1941    pub fn new() -> Self {
1942        std::default::Default::default()
1943    }
1944
1945    /// Sets the value of [name][crate::model::Policy::name].
1946    ///
1947    /// # Example
1948    /// ```ignore,no_run
1949    /// # use google_cloud_orgpolicy_v2::model::Policy;
1950    /// let x = Policy::new().set_name("example");
1951    /// ```
1952    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1953        self.name = v.into();
1954        self
1955    }
1956
1957    /// Sets the value of [spec][crate::model::Policy::spec].
1958    ///
1959    /// # Example
1960    /// ```ignore,no_run
1961    /// # use google_cloud_orgpolicy_v2::model::Policy;
1962    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
1963    /// let x = Policy::new().set_spec(PolicySpec::default()/* use setters */);
1964    /// ```
1965    pub fn set_spec<T>(mut self, v: T) -> Self
1966    where
1967        T: std::convert::Into<crate::model::PolicySpec>,
1968    {
1969        self.spec = std::option::Option::Some(v.into());
1970        self
1971    }
1972
1973    /// Sets or clears the value of [spec][crate::model::Policy::spec].
1974    ///
1975    /// # Example
1976    /// ```ignore,no_run
1977    /// # use google_cloud_orgpolicy_v2::model::Policy;
1978    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
1979    /// let x = Policy::new().set_or_clear_spec(Some(PolicySpec::default()/* use setters */));
1980    /// let x = Policy::new().set_or_clear_spec(None::<PolicySpec>);
1981    /// ```
1982    pub fn set_or_clear_spec<T>(mut self, v: std::option::Option<T>) -> Self
1983    where
1984        T: std::convert::Into<crate::model::PolicySpec>,
1985    {
1986        self.spec = v.map(|x| x.into());
1987        self
1988    }
1989
1990    /// Sets the value of [alternate][crate::model::Policy::alternate].
1991    ///
1992    /// # Example
1993    /// ```ignore,no_run
1994    /// # use google_cloud_orgpolicy_v2::model::Policy;
1995    /// use google_cloud_orgpolicy_v2::model::AlternatePolicySpec;
1996    /// let x = Policy::new().set_alternate(AlternatePolicySpec::default()/* use setters */);
1997    /// ```
1998    #[deprecated]
1999    pub fn set_alternate<T>(mut self, v: T) -> Self
2000    where
2001        T: std::convert::Into<crate::model::AlternatePolicySpec>,
2002    {
2003        self.alternate = std::option::Option::Some(v.into());
2004        self
2005    }
2006
2007    /// Sets or clears the value of [alternate][crate::model::Policy::alternate].
2008    ///
2009    /// # Example
2010    /// ```ignore,no_run
2011    /// # use google_cloud_orgpolicy_v2::model::Policy;
2012    /// use google_cloud_orgpolicy_v2::model::AlternatePolicySpec;
2013    /// let x = Policy::new().set_or_clear_alternate(Some(AlternatePolicySpec::default()/* use setters */));
2014    /// let x = Policy::new().set_or_clear_alternate(None::<AlternatePolicySpec>);
2015    /// ```
2016    #[deprecated]
2017    pub fn set_or_clear_alternate<T>(mut self, v: std::option::Option<T>) -> Self
2018    where
2019        T: std::convert::Into<crate::model::AlternatePolicySpec>,
2020    {
2021        self.alternate = v.map(|x| x.into());
2022        self
2023    }
2024
2025    /// Sets the value of [dry_run_spec][crate::model::Policy::dry_run_spec].
2026    ///
2027    /// # Example
2028    /// ```ignore,no_run
2029    /// # use google_cloud_orgpolicy_v2::model::Policy;
2030    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
2031    /// let x = Policy::new().set_dry_run_spec(PolicySpec::default()/* use setters */);
2032    /// ```
2033    pub fn set_dry_run_spec<T>(mut self, v: T) -> Self
2034    where
2035        T: std::convert::Into<crate::model::PolicySpec>,
2036    {
2037        self.dry_run_spec = std::option::Option::Some(v.into());
2038        self
2039    }
2040
2041    /// Sets or clears the value of [dry_run_spec][crate::model::Policy::dry_run_spec].
2042    ///
2043    /// # Example
2044    /// ```ignore,no_run
2045    /// # use google_cloud_orgpolicy_v2::model::Policy;
2046    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
2047    /// let x = Policy::new().set_or_clear_dry_run_spec(Some(PolicySpec::default()/* use setters */));
2048    /// let x = Policy::new().set_or_clear_dry_run_spec(None::<PolicySpec>);
2049    /// ```
2050    pub fn set_or_clear_dry_run_spec<T>(mut self, v: std::option::Option<T>) -> Self
2051    where
2052        T: std::convert::Into<crate::model::PolicySpec>,
2053    {
2054        self.dry_run_spec = v.map(|x| x.into());
2055        self
2056    }
2057
2058    /// Sets the value of [etag][crate::model::Policy::etag].
2059    ///
2060    /// # Example
2061    /// ```ignore,no_run
2062    /// # use google_cloud_orgpolicy_v2::model::Policy;
2063    /// let x = Policy::new().set_etag("example");
2064    /// ```
2065    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2066        self.etag = v.into();
2067        self
2068    }
2069}
2070
2071impl wkt::message::Message for Policy {
2072    fn typename() -> &'static str {
2073        "type.googleapis.com/google.cloud.orgpolicy.v2.Policy"
2074    }
2075}
2076
2077/// Similar to PolicySpec but with an extra 'launch' field for launch reference.
2078/// The PolicySpec here is specific for dry-run.
2079#[derive(Clone, Default, PartialEq)]
2080#[non_exhaustive]
2081pub struct AlternatePolicySpec {
2082    /// Reference to the launch that will be used while audit logging and to
2083    /// control the launch.
2084    /// Should be set only in the alternate policy.
2085    pub launch: std::string::String,
2086
2087    /// Specify constraint for configurations of Google Cloud resources.
2088    pub spec: std::option::Option<crate::model::PolicySpec>,
2089
2090    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2091}
2092
2093impl AlternatePolicySpec {
2094    pub fn new() -> Self {
2095        std::default::Default::default()
2096    }
2097
2098    /// Sets the value of [launch][crate::model::AlternatePolicySpec::launch].
2099    ///
2100    /// # Example
2101    /// ```ignore,no_run
2102    /// # use google_cloud_orgpolicy_v2::model::AlternatePolicySpec;
2103    /// let x = AlternatePolicySpec::new().set_launch("example");
2104    /// ```
2105    pub fn set_launch<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2106        self.launch = v.into();
2107        self
2108    }
2109
2110    /// Sets the value of [spec][crate::model::AlternatePolicySpec::spec].
2111    ///
2112    /// # Example
2113    /// ```ignore,no_run
2114    /// # use google_cloud_orgpolicy_v2::model::AlternatePolicySpec;
2115    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
2116    /// let x = AlternatePolicySpec::new().set_spec(PolicySpec::default()/* use setters */);
2117    /// ```
2118    pub fn set_spec<T>(mut self, v: T) -> Self
2119    where
2120        T: std::convert::Into<crate::model::PolicySpec>,
2121    {
2122        self.spec = std::option::Option::Some(v.into());
2123        self
2124    }
2125
2126    /// Sets or clears the value of [spec][crate::model::AlternatePolicySpec::spec].
2127    ///
2128    /// # Example
2129    /// ```ignore,no_run
2130    /// # use google_cloud_orgpolicy_v2::model::AlternatePolicySpec;
2131    /// use google_cloud_orgpolicy_v2::model::PolicySpec;
2132    /// let x = AlternatePolicySpec::new().set_or_clear_spec(Some(PolicySpec::default()/* use setters */));
2133    /// let x = AlternatePolicySpec::new().set_or_clear_spec(None::<PolicySpec>);
2134    /// ```
2135    pub fn set_or_clear_spec<T>(mut self, v: std::option::Option<T>) -> Self
2136    where
2137        T: std::convert::Into<crate::model::PolicySpec>,
2138    {
2139        self.spec = v.map(|x| x.into());
2140        self
2141    }
2142}
2143
2144impl wkt::message::Message for AlternatePolicySpec {
2145    fn typename() -> &'static str {
2146        "type.googleapis.com/google.cloud.orgpolicy.v2.AlternatePolicySpec"
2147    }
2148}
2149
2150/// Defines a Google Cloud policy specification which is used to specify
2151/// constraints for configurations of Google Cloud resources.
2152#[derive(Clone, Default, PartialEq)]
2153#[non_exhaustive]
2154pub struct PolicySpec {
2155    /// An opaque tag indicating the current version of the policySpec, used for
2156    /// concurrency control.
2157    ///
2158    /// This field is ignored if used in a `CreatePolicy` request.
2159    ///
2160    /// When the policy is returned from either a `GetPolicy` or a
2161    /// `ListPolicies` request, this `etag` indicates the version of the
2162    /// current policySpec to use when executing a read-modify-write loop.
2163    ///
2164    /// When the policy is returned from a `GetEffectivePolicy` request, the
2165    /// `etag` will be unset.
2166    pub etag: std::string::String,
2167
2168    /// Output only. The time stamp this was previously updated. This
2169    /// represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
2170    /// made for that policy.
2171    pub update_time: std::option::Option<wkt::Timestamp>,
2172
2173    /// In policies for boolean constraints, the following requirements apply:
2174    ///
2175    /// - There must be one and only one policy rule where condition is unset.
2176    /// - Boolean policy rules with conditions must set `enforced` to the
2177    ///   opposite of the policy rule without a condition.
2178    /// - During policy evaluation, policy rules with conditions that are
2179    ///   true for a target resource take precedence.
2180    pub rules: std::vec::Vec<crate::model::policy_spec::PolicyRule>,
2181
2182    /// Determines the inheritance behavior for this policy.
2183    ///
2184    /// If `inherit_from_parent` is true, policy rules set higher up in the
2185    /// hierarchy (up to the closest root) are inherited and present in the
2186    /// effective policy. If it is false, then no rules are inherited, and this
2187    /// policy becomes the new root for evaluation.
2188    /// This field can be set only for policies which configure list constraints.
2189    pub inherit_from_parent: bool,
2190
2191    /// Ignores policies set above this resource and restores the
2192    /// `constraint_default` enforcement behavior of the specific constraint at
2193    /// this resource.
2194    /// This field can be set in policies for either list or boolean
2195    /// constraints. If set, `rules` must be empty and `inherit_from_parent`
2196    /// must be set to false.
2197    pub reset: bool,
2198
2199    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2200}
2201
2202impl PolicySpec {
2203    pub fn new() -> Self {
2204        std::default::Default::default()
2205    }
2206
2207    /// Sets the value of [etag][crate::model::PolicySpec::etag].
2208    ///
2209    /// # Example
2210    /// ```ignore,no_run
2211    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2212    /// let x = PolicySpec::new().set_etag("example");
2213    /// ```
2214    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2215        self.etag = v.into();
2216        self
2217    }
2218
2219    /// Sets the value of [update_time][crate::model::PolicySpec::update_time].
2220    ///
2221    /// # Example
2222    /// ```ignore,no_run
2223    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2224    /// use wkt::Timestamp;
2225    /// let x = PolicySpec::new().set_update_time(Timestamp::default()/* use setters */);
2226    /// ```
2227    pub fn set_update_time<T>(mut self, v: T) -> Self
2228    where
2229        T: std::convert::Into<wkt::Timestamp>,
2230    {
2231        self.update_time = std::option::Option::Some(v.into());
2232        self
2233    }
2234
2235    /// Sets or clears the value of [update_time][crate::model::PolicySpec::update_time].
2236    ///
2237    /// # Example
2238    /// ```ignore,no_run
2239    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2240    /// use wkt::Timestamp;
2241    /// let x = PolicySpec::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
2242    /// let x = PolicySpec::new().set_or_clear_update_time(None::<Timestamp>);
2243    /// ```
2244    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
2245    where
2246        T: std::convert::Into<wkt::Timestamp>,
2247    {
2248        self.update_time = v.map(|x| x.into());
2249        self
2250    }
2251
2252    /// Sets the value of [rules][crate::model::PolicySpec::rules].
2253    ///
2254    /// # Example
2255    /// ```ignore,no_run
2256    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2257    /// use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2258    /// let x = PolicySpec::new()
2259    ///     .set_rules([
2260    ///         PolicyRule::default()/* use setters */,
2261    ///         PolicyRule::default()/* use (different) setters */,
2262    ///     ]);
2263    /// ```
2264    pub fn set_rules<T, V>(mut self, v: T) -> Self
2265    where
2266        T: std::iter::IntoIterator<Item = V>,
2267        V: std::convert::Into<crate::model::policy_spec::PolicyRule>,
2268    {
2269        use std::iter::Iterator;
2270        self.rules = v.into_iter().map(|i| i.into()).collect();
2271        self
2272    }
2273
2274    /// Sets the value of [inherit_from_parent][crate::model::PolicySpec::inherit_from_parent].
2275    ///
2276    /// # Example
2277    /// ```ignore,no_run
2278    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2279    /// let x = PolicySpec::new().set_inherit_from_parent(true);
2280    /// ```
2281    pub fn set_inherit_from_parent<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2282        self.inherit_from_parent = v.into();
2283        self
2284    }
2285
2286    /// Sets the value of [reset][crate::model::PolicySpec::reset].
2287    ///
2288    /// # Example
2289    /// ```ignore,no_run
2290    /// # use google_cloud_orgpolicy_v2::model::PolicySpec;
2291    /// let x = PolicySpec::new().set_reset(true);
2292    /// ```
2293    pub fn set_reset<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2294        self.reset = v.into();
2295        self
2296    }
2297}
2298
2299impl wkt::message::Message for PolicySpec {
2300    fn typename() -> &'static str {
2301        "type.googleapis.com/google.cloud.orgpolicy.v2.PolicySpec"
2302    }
2303}
2304
2305/// Defines additional types related to [PolicySpec].
2306pub mod policy_spec {
2307    #[allow(unused_imports)]
2308    use super::*;
2309
2310    /// A rule used to express this policy.
2311    #[derive(Clone, Default, PartialEq)]
2312    #[non_exhaustive]
2313    pub struct PolicyRule {
2314        /// A condition which determines whether this rule is used
2315        /// in the evaluation of the policy. When set, the `expression` field in
2316        /// the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
2317        /// or "&&" operators. Each subexpression must be of the form
2318        /// "resource.matchTag('<ORG_ID>/tag_key_short_name,
2319        /// 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id',
2320        /// 'tagValues/value_id')". where key_name and value_name are the resource
2321        /// names for Label Keys and Values. These names are available from the Tag
2322        /// Manager Service. An example expression is:
2323        /// "resource.matchTag('123456789/environment,
2324        /// 'prod')". or "resource.matchTagId('tagKeys/123',
2325        /// 'tagValues/456')".
2326        pub condition: std::option::Option<google_cloud_type::model::Expr>,
2327
2328        /// Optional. Required for managed constraints if parameters are defined.
2329        /// Passes parameter values when policy enforcement is enabled. Ensure that
2330        /// parameter value types match those defined in the constraint definition.
2331        /// For example:
2332        /// {
2333        /// "allowedLocations" : ["us-east1", "us-west1"],
2334        /// "allowAll" : true
2335        /// }
2336        pub parameters: std::option::Option<wkt::Struct>,
2337
2338        pub kind: std::option::Option<crate::model::policy_spec::policy_rule::Kind>,
2339
2340        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2341    }
2342
2343    impl PolicyRule {
2344        pub fn new() -> Self {
2345            std::default::Default::default()
2346        }
2347
2348        /// Sets the value of [condition][crate::model::policy_spec::PolicyRule::condition].
2349        ///
2350        /// # Example
2351        /// ```ignore,no_run
2352        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2353        /// use google_cloud_type::model::Expr;
2354        /// let x = PolicyRule::new().set_condition(Expr::default()/* use setters */);
2355        /// ```
2356        pub fn set_condition<T>(mut self, v: T) -> Self
2357        where
2358            T: std::convert::Into<google_cloud_type::model::Expr>,
2359        {
2360            self.condition = std::option::Option::Some(v.into());
2361            self
2362        }
2363
2364        /// Sets or clears the value of [condition][crate::model::policy_spec::PolicyRule::condition].
2365        ///
2366        /// # Example
2367        /// ```ignore,no_run
2368        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2369        /// use google_cloud_type::model::Expr;
2370        /// let x = PolicyRule::new().set_or_clear_condition(Some(Expr::default()/* use setters */));
2371        /// let x = PolicyRule::new().set_or_clear_condition(None::<Expr>);
2372        /// ```
2373        pub fn set_or_clear_condition<T>(mut self, v: std::option::Option<T>) -> Self
2374        where
2375            T: std::convert::Into<google_cloud_type::model::Expr>,
2376        {
2377            self.condition = v.map(|x| x.into());
2378            self
2379        }
2380
2381        /// Sets the value of [parameters][crate::model::policy_spec::PolicyRule::parameters].
2382        ///
2383        /// # Example
2384        /// ```ignore,no_run
2385        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2386        /// use wkt::Struct;
2387        /// let x = PolicyRule::new().set_parameters(Struct::default()/* use setters */);
2388        /// ```
2389        pub fn set_parameters<T>(mut self, v: T) -> Self
2390        where
2391            T: std::convert::Into<wkt::Struct>,
2392        {
2393            self.parameters = std::option::Option::Some(v.into());
2394            self
2395        }
2396
2397        /// Sets or clears the value of [parameters][crate::model::policy_spec::PolicyRule::parameters].
2398        ///
2399        /// # Example
2400        /// ```ignore,no_run
2401        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2402        /// use wkt::Struct;
2403        /// let x = PolicyRule::new().set_or_clear_parameters(Some(Struct::default()/* use setters */));
2404        /// let x = PolicyRule::new().set_or_clear_parameters(None::<Struct>);
2405        /// ```
2406        pub fn set_or_clear_parameters<T>(mut self, v: std::option::Option<T>) -> Self
2407        where
2408            T: std::convert::Into<wkt::Struct>,
2409        {
2410            self.parameters = v.map(|x| x.into());
2411            self
2412        }
2413
2414        /// Sets the value of [kind][crate::model::policy_spec::PolicyRule::kind].
2415        ///
2416        /// Note that all the setters affecting `kind` are mutually
2417        /// exclusive.
2418        ///
2419        /// # Example
2420        /// ```ignore,no_run
2421        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2422        /// use google_cloud_orgpolicy_v2::model::policy_spec::policy_rule::Kind;
2423        /// let x = PolicyRule::new().set_kind(Some(Kind::AllowAll(true)));
2424        /// ```
2425        pub fn set_kind<
2426            T: std::convert::Into<std::option::Option<crate::model::policy_spec::policy_rule::Kind>>,
2427        >(
2428            mut self,
2429            v: T,
2430        ) -> Self {
2431            self.kind = v.into();
2432            self
2433        }
2434
2435        /// The value of [kind][crate::model::policy_spec::PolicyRule::kind]
2436        /// if it holds a `Values`, `None` if the field is not set or
2437        /// holds a different branch.
2438        pub fn values(
2439            &self,
2440        ) -> std::option::Option<
2441            &std::boxed::Box<crate::model::policy_spec::policy_rule::StringValues>,
2442        > {
2443            #[allow(unreachable_patterns)]
2444            self.kind.as_ref().and_then(|v| match v {
2445                crate::model::policy_spec::policy_rule::Kind::Values(v) => {
2446                    std::option::Option::Some(v)
2447                }
2448                _ => std::option::Option::None,
2449            })
2450        }
2451
2452        /// Sets the value of [kind][crate::model::policy_spec::PolicyRule::kind]
2453        /// to hold a `Values`.
2454        ///
2455        /// Note that all the setters affecting `kind` are
2456        /// mutually exclusive.
2457        ///
2458        /// # Example
2459        /// ```ignore,no_run
2460        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2461        /// use google_cloud_orgpolicy_v2::model::policy_spec::policy_rule::StringValues;
2462        /// let x = PolicyRule::new().set_values(StringValues::default()/* use setters */);
2463        /// assert!(x.values().is_some());
2464        /// assert!(x.allow_all().is_none());
2465        /// assert!(x.deny_all().is_none());
2466        /// assert!(x.enforce().is_none());
2467        /// ```
2468        pub fn set_values<
2469            T: std::convert::Into<
2470                    std::boxed::Box<crate::model::policy_spec::policy_rule::StringValues>,
2471                >,
2472        >(
2473            mut self,
2474            v: T,
2475        ) -> Self {
2476            self.kind = std::option::Option::Some(
2477                crate::model::policy_spec::policy_rule::Kind::Values(v.into()),
2478            );
2479            self
2480        }
2481
2482        /// The value of [kind][crate::model::policy_spec::PolicyRule::kind]
2483        /// if it holds a `AllowAll`, `None` if the field is not set or
2484        /// holds a different branch.
2485        pub fn allow_all(&self) -> std::option::Option<&bool> {
2486            #[allow(unreachable_patterns)]
2487            self.kind.as_ref().and_then(|v| match v {
2488                crate::model::policy_spec::policy_rule::Kind::AllowAll(v) => {
2489                    std::option::Option::Some(v)
2490                }
2491                _ => std::option::Option::None,
2492            })
2493        }
2494
2495        /// Sets the value of [kind][crate::model::policy_spec::PolicyRule::kind]
2496        /// to hold a `AllowAll`.
2497        ///
2498        /// Note that all the setters affecting `kind` are
2499        /// mutually exclusive.
2500        ///
2501        /// # Example
2502        /// ```ignore,no_run
2503        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2504        /// let x = PolicyRule::new().set_allow_all(true);
2505        /// assert!(x.allow_all().is_some());
2506        /// assert!(x.values().is_none());
2507        /// assert!(x.deny_all().is_none());
2508        /// assert!(x.enforce().is_none());
2509        /// ```
2510        pub fn set_allow_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2511            self.kind = std::option::Option::Some(
2512                crate::model::policy_spec::policy_rule::Kind::AllowAll(v.into()),
2513            );
2514            self
2515        }
2516
2517        /// The value of [kind][crate::model::policy_spec::PolicyRule::kind]
2518        /// if it holds a `DenyAll`, `None` if the field is not set or
2519        /// holds a different branch.
2520        pub fn deny_all(&self) -> std::option::Option<&bool> {
2521            #[allow(unreachable_patterns)]
2522            self.kind.as_ref().and_then(|v| match v {
2523                crate::model::policy_spec::policy_rule::Kind::DenyAll(v) => {
2524                    std::option::Option::Some(v)
2525                }
2526                _ => std::option::Option::None,
2527            })
2528        }
2529
2530        /// Sets the value of [kind][crate::model::policy_spec::PolicyRule::kind]
2531        /// to hold a `DenyAll`.
2532        ///
2533        /// Note that all the setters affecting `kind` are
2534        /// mutually exclusive.
2535        ///
2536        /// # Example
2537        /// ```ignore,no_run
2538        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2539        /// let x = PolicyRule::new().set_deny_all(true);
2540        /// assert!(x.deny_all().is_some());
2541        /// assert!(x.values().is_none());
2542        /// assert!(x.allow_all().is_none());
2543        /// assert!(x.enforce().is_none());
2544        /// ```
2545        pub fn set_deny_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2546            self.kind = std::option::Option::Some(
2547                crate::model::policy_spec::policy_rule::Kind::DenyAll(v.into()),
2548            );
2549            self
2550        }
2551
2552        /// The value of [kind][crate::model::policy_spec::PolicyRule::kind]
2553        /// if it holds a `Enforce`, `None` if the field is not set or
2554        /// holds a different branch.
2555        pub fn enforce(&self) -> std::option::Option<&bool> {
2556            #[allow(unreachable_patterns)]
2557            self.kind.as_ref().and_then(|v| match v {
2558                crate::model::policy_spec::policy_rule::Kind::Enforce(v) => {
2559                    std::option::Option::Some(v)
2560                }
2561                _ => std::option::Option::None,
2562            })
2563        }
2564
2565        /// Sets the value of [kind][crate::model::policy_spec::PolicyRule::kind]
2566        /// to hold a `Enforce`.
2567        ///
2568        /// Note that all the setters affecting `kind` are
2569        /// mutually exclusive.
2570        ///
2571        /// # Example
2572        /// ```ignore,no_run
2573        /// # use google_cloud_orgpolicy_v2::model::policy_spec::PolicyRule;
2574        /// let x = PolicyRule::new().set_enforce(true);
2575        /// assert!(x.enforce().is_some());
2576        /// assert!(x.values().is_none());
2577        /// assert!(x.allow_all().is_none());
2578        /// assert!(x.deny_all().is_none());
2579        /// ```
2580        pub fn set_enforce<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2581            self.kind = std::option::Option::Some(
2582                crate::model::policy_spec::policy_rule::Kind::Enforce(v.into()),
2583            );
2584            self
2585        }
2586    }
2587
2588    impl wkt::message::Message for PolicyRule {
2589        fn typename() -> &'static str {
2590            "type.googleapis.com/google.cloud.orgpolicy.v2.PolicySpec.PolicyRule"
2591        }
2592    }
2593
2594    /// Defines additional types related to [PolicyRule].
2595    pub mod policy_rule {
2596        #[allow(unused_imports)]
2597        use super::*;
2598
2599        /// A message that holds specific allowed and denied values.
2600        /// This message can define specific values and subtrees of the Resource
2601        /// Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
2602        /// are allowed or denied. This is achieved by using the `under:` and
2603        /// optional `is:` prefixes.
2604        /// The `under:` prefix is used to denote resource subtree values.
2605        /// The `is:` prefix is used to denote specific values, and is required only
2606        /// if the value contains a ":". Values prefixed with "is:" are treated the
2607        /// same as values with no prefix.
2608        /// Ancestry subtrees must be in one of the following formats:
2609        ///
2610        /// - `projects/<project-id>` (for example, `projects/tokyo-rain-123`)
2611        /// - `folders/<folder-id>` (for example, `folders/1234`)
2612        /// - `organizations/<organization-id>` (for example, `organizations/1234`)
2613        ///
2614        /// The `supports_under` field of the associated `Constraint`  defines
2615        /// whether ancestry prefixes can be used.
2616        #[derive(Clone, Default, PartialEq)]
2617        #[non_exhaustive]
2618        pub struct StringValues {
2619            /// List of values allowed at this resource.
2620            pub allowed_values: std::vec::Vec<std::string::String>,
2621
2622            /// List of values denied at this resource.
2623            pub denied_values: std::vec::Vec<std::string::String>,
2624
2625            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2626        }
2627
2628        impl StringValues {
2629            pub fn new() -> Self {
2630                std::default::Default::default()
2631            }
2632
2633            /// Sets the value of [allowed_values][crate::model::policy_spec::policy_rule::StringValues::allowed_values].
2634            ///
2635            /// # Example
2636            /// ```ignore,no_run
2637            /// # use google_cloud_orgpolicy_v2::model::policy_spec::policy_rule::StringValues;
2638            /// let x = StringValues::new().set_allowed_values(["a", "b", "c"]);
2639            /// ```
2640            pub fn set_allowed_values<T, V>(mut self, v: T) -> Self
2641            where
2642                T: std::iter::IntoIterator<Item = V>,
2643                V: std::convert::Into<std::string::String>,
2644            {
2645                use std::iter::Iterator;
2646                self.allowed_values = v.into_iter().map(|i| i.into()).collect();
2647                self
2648            }
2649
2650            /// Sets the value of [denied_values][crate::model::policy_spec::policy_rule::StringValues::denied_values].
2651            ///
2652            /// # Example
2653            /// ```ignore,no_run
2654            /// # use google_cloud_orgpolicy_v2::model::policy_spec::policy_rule::StringValues;
2655            /// let x = StringValues::new().set_denied_values(["a", "b", "c"]);
2656            /// ```
2657            pub fn set_denied_values<T, V>(mut self, v: T) -> Self
2658            where
2659                T: std::iter::IntoIterator<Item = V>,
2660                V: std::convert::Into<std::string::String>,
2661            {
2662                use std::iter::Iterator;
2663                self.denied_values = v.into_iter().map(|i| i.into()).collect();
2664                self
2665            }
2666        }
2667
2668        impl wkt::message::Message for StringValues {
2669            fn typename() -> &'static str {
2670                "type.googleapis.com/google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues"
2671            }
2672        }
2673
2674        #[derive(Clone, Debug, PartialEq)]
2675        #[non_exhaustive]
2676        pub enum Kind {
2677            /// List of values to be used for this policy rule. This field can be set
2678            /// only in policies for list constraints.
2679            Values(std::boxed::Box<crate::model::policy_spec::policy_rule::StringValues>),
2680            /// Setting this to true means that all values are allowed. This field can
2681            /// be set only in policies for list constraints.
2682            AllowAll(bool),
2683            /// Setting this to true means that all values are denied. This field can
2684            /// be set only in policies for list constraints.
2685            DenyAll(bool),
2686            /// If `true`, then the policy is enforced. If `false`, then any
2687            /// configuration is acceptable.
2688            /// This field can be set only in policies for boolean constraints.
2689            Enforce(bool),
2690        }
2691    }
2692}
2693
2694/// The request sent to the [ListConstraints]
2695/// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
2696#[derive(Clone, Default, PartialEq)]
2697#[non_exhaustive]
2698pub struct ListConstraintsRequest {
2699    /// Required. The Google Cloud resource that parents the constraint. Must be in
2700    /// one of the following forms:
2701    ///
2702    /// * `projects/{project_number}`
2703    /// * `projects/{project_id}`
2704    /// * `folders/{folder_id}`
2705    /// * `organizations/{organization_id}`
2706    pub parent: std::string::String,
2707
2708    /// Size of the pages to be returned. This is currently unsupported and will
2709    /// be ignored. The server may at any point start using this field to limit
2710    /// page size.
2711    pub page_size: i32,
2712
2713    /// Page token used to retrieve the next page. This is currently unsupported
2714    /// and will be ignored. The server may at any point start using this field.
2715    pub page_token: std::string::String,
2716
2717    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2718}
2719
2720impl ListConstraintsRequest {
2721    pub fn new() -> Self {
2722        std::default::Default::default()
2723    }
2724
2725    /// Sets the value of [parent][crate::model::ListConstraintsRequest::parent].
2726    ///
2727    /// # Example
2728    /// ```ignore,no_run
2729    /// # use google_cloud_orgpolicy_v2::model::ListConstraintsRequest;
2730    /// let x = ListConstraintsRequest::new().set_parent("example");
2731    /// ```
2732    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2733        self.parent = v.into();
2734        self
2735    }
2736
2737    /// Sets the value of [page_size][crate::model::ListConstraintsRequest::page_size].
2738    ///
2739    /// # Example
2740    /// ```ignore,no_run
2741    /// # use google_cloud_orgpolicy_v2::model::ListConstraintsRequest;
2742    /// let x = ListConstraintsRequest::new().set_page_size(42);
2743    /// ```
2744    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2745        self.page_size = v.into();
2746        self
2747    }
2748
2749    /// Sets the value of [page_token][crate::model::ListConstraintsRequest::page_token].
2750    ///
2751    /// # Example
2752    /// ```ignore,no_run
2753    /// # use google_cloud_orgpolicy_v2::model::ListConstraintsRequest;
2754    /// let x = ListConstraintsRequest::new().set_page_token("example");
2755    /// ```
2756    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2757        self.page_token = v.into();
2758        self
2759    }
2760}
2761
2762impl wkt::message::Message for ListConstraintsRequest {
2763    fn typename() -> &'static str {
2764        "type.googleapis.com/google.cloud.orgpolicy.v2.ListConstraintsRequest"
2765    }
2766}
2767
2768/// The response returned from the [ListConstraints]
2769/// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
2770#[derive(Clone, Default, PartialEq)]
2771#[non_exhaustive]
2772pub struct ListConstraintsResponse {
2773    /// The collection of constraints that are available on the targeted resource.
2774    pub constraints: std::vec::Vec<crate::model::Constraint>,
2775
2776    /// Page token used to retrieve the next page. This is currently not used.
2777    pub next_page_token: std::string::String,
2778
2779    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2780}
2781
2782impl ListConstraintsResponse {
2783    pub fn new() -> Self {
2784        std::default::Default::default()
2785    }
2786
2787    /// Sets the value of [constraints][crate::model::ListConstraintsResponse::constraints].
2788    ///
2789    /// # Example
2790    /// ```ignore,no_run
2791    /// # use google_cloud_orgpolicy_v2::model::ListConstraintsResponse;
2792    /// use google_cloud_orgpolicy_v2::model::Constraint;
2793    /// let x = ListConstraintsResponse::new()
2794    ///     .set_constraints([
2795    ///         Constraint::default()/* use setters */,
2796    ///         Constraint::default()/* use (different) setters */,
2797    ///     ]);
2798    /// ```
2799    pub fn set_constraints<T, V>(mut self, v: T) -> Self
2800    where
2801        T: std::iter::IntoIterator<Item = V>,
2802        V: std::convert::Into<crate::model::Constraint>,
2803    {
2804        use std::iter::Iterator;
2805        self.constraints = v.into_iter().map(|i| i.into()).collect();
2806        self
2807    }
2808
2809    /// Sets the value of [next_page_token][crate::model::ListConstraintsResponse::next_page_token].
2810    ///
2811    /// # Example
2812    /// ```ignore,no_run
2813    /// # use google_cloud_orgpolicy_v2::model::ListConstraintsResponse;
2814    /// let x = ListConstraintsResponse::new().set_next_page_token("example");
2815    /// ```
2816    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2817        self.next_page_token = v.into();
2818        self
2819    }
2820}
2821
2822impl wkt::message::Message for ListConstraintsResponse {
2823    fn typename() -> &'static str {
2824        "type.googleapis.com/google.cloud.orgpolicy.v2.ListConstraintsResponse"
2825    }
2826}
2827
2828#[doc(hidden)]
2829impl google_cloud_gax::paginator::internal::PageableResponse for ListConstraintsResponse {
2830    type PageItem = crate::model::Constraint;
2831
2832    fn items(self) -> std::vec::Vec<Self::PageItem> {
2833        self.constraints
2834    }
2835
2836    fn next_page_token(&self) -> std::string::String {
2837        use std::clone::Clone;
2838        self.next_page_token.clone()
2839    }
2840}
2841
2842/// The request sent to the [ListPolicies]
2843/// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method.
2844#[derive(Clone, Default, PartialEq)]
2845#[non_exhaustive]
2846pub struct ListPoliciesRequest {
2847    /// Required. The target Google Cloud resource that parents the set of
2848    /// constraints and policies that will be returned from this call. Must be in
2849    /// one of the following forms:
2850    ///
2851    /// * `projects/{project_number}`
2852    /// * `projects/{project_id}`
2853    /// * `folders/{folder_id}`
2854    /// * `organizations/{organization_id}`
2855    pub parent: std::string::String,
2856
2857    /// Size of the pages to be returned. This is currently unsupported and will
2858    /// be ignored. The server may at any point start using this field to limit
2859    /// page size.
2860    pub page_size: i32,
2861
2862    /// Page token used to retrieve the next page. This is currently unsupported
2863    /// and will be ignored. The server may at any point start using this field.
2864    pub page_token: std::string::String,
2865
2866    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2867}
2868
2869impl ListPoliciesRequest {
2870    pub fn new() -> Self {
2871        std::default::Default::default()
2872    }
2873
2874    /// Sets the value of [parent][crate::model::ListPoliciesRequest::parent].
2875    ///
2876    /// # Example
2877    /// ```ignore,no_run
2878    /// # use google_cloud_orgpolicy_v2::model::ListPoliciesRequest;
2879    /// let x = ListPoliciesRequest::new().set_parent("example");
2880    /// ```
2881    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2882        self.parent = v.into();
2883        self
2884    }
2885
2886    /// Sets the value of [page_size][crate::model::ListPoliciesRequest::page_size].
2887    ///
2888    /// # Example
2889    /// ```ignore,no_run
2890    /// # use google_cloud_orgpolicy_v2::model::ListPoliciesRequest;
2891    /// let x = ListPoliciesRequest::new().set_page_size(42);
2892    /// ```
2893    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2894        self.page_size = v.into();
2895        self
2896    }
2897
2898    /// Sets the value of [page_token][crate::model::ListPoliciesRequest::page_token].
2899    ///
2900    /// # Example
2901    /// ```ignore,no_run
2902    /// # use google_cloud_orgpolicy_v2::model::ListPoliciesRequest;
2903    /// let x = ListPoliciesRequest::new().set_page_token("example");
2904    /// ```
2905    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2906        self.page_token = v.into();
2907        self
2908    }
2909}
2910
2911impl wkt::message::Message for ListPoliciesRequest {
2912    fn typename() -> &'static str {
2913        "type.googleapis.com/google.cloud.orgpolicy.v2.ListPoliciesRequest"
2914    }
2915}
2916
2917/// The response returned from the [ListPolicies]
2918/// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty
2919/// if no policies are set on the resource.
2920#[derive(Clone, Default, PartialEq)]
2921#[non_exhaustive]
2922pub struct ListPoliciesResponse {
2923    /// All policies that exist on the resource. It will be empty if no
2924    /// policies are set.
2925    pub policies: std::vec::Vec<crate::model::Policy>,
2926
2927    /// Page token used to retrieve the next page. This is currently not used, but
2928    /// the server may at any point start supplying a valid token.
2929    pub next_page_token: std::string::String,
2930
2931    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2932}
2933
2934impl ListPoliciesResponse {
2935    pub fn new() -> Self {
2936        std::default::Default::default()
2937    }
2938
2939    /// Sets the value of [policies][crate::model::ListPoliciesResponse::policies].
2940    ///
2941    /// # Example
2942    /// ```ignore,no_run
2943    /// # use google_cloud_orgpolicy_v2::model::ListPoliciesResponse;
2944    /// use google_cloud_orgpolicy_v2::model::Policy;
2945    /// let x = ListPoliciesResponse::new()
2946    ///     .set_policies([
2947    ///         Policy::default()/* use setters */,
2948    ///         Policy::default()/* use (different) setters */,
2949    ///     ]);
2950    /// ```
2951    pub fn set_policies<T, V>(mut self, v: T) -> Self
2952    where
2953        T: std::iter::IntoIterator<Item = V>,
2954        V: std::convert::Into<crate::model::Policy>,
2955    {
2956        use std::iter::Iterator;
2957        self.policies = v.into_iter().map(|i| i.into()).collect();
2958        self
2959    }
2960
2961    /// Sets the value of [next_page_token][crate::model::ListPoliciesResponse::next_page_token].
2962    ///
2963    /// # Example
2964    /// ```ignore,no_run
2965    /// # use google_cloud_orgpolicy_v2::model::ListPoliciesResponse;
2966    /// let x = ListPoliciesResponse::new().set_next_page_token("example");
2967    /// ```
2968    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2969        self.next_page_token = v.into();
2970        self
2971    }
2972}
2973
2974impl wkt::message::Message for ListPoliciesResponse {
2975    fn typename() -> &'static str {
2976        "type.googleapis.com/google.cloud.orgpolicy.v2.ListPoliciesResponse"
2977    }
2978}
2979
2980#[doc(hidden)]
2981impl google_cloud_gax::paginator::internal::PageableResponse for ListPoliciesResponse {
2982    type PageItem = crate::model::Policy;
2983
2984    fn items(self) -> std::vec::Vec<Self::PageItem> {
2985        self.policies
2986    }
2987
2988    fn next_page_token(&self) -> std::string::String {
2989        use std::clone::Clone;
2990        self.next_page_token.clone()
2991    }
2992}
2993
2994/// The request sent to the [GetPolicy]
2995/// [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.
2996#[derive(Clone, Default, PartialEq)]
2997#[non_exhaustive]
2998pub struct GetPolicyRequest {
2999    /// Required. Resource name of the policy. See
3000    /// [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
3001    ///
3002    /// [google.cloud.orgpolicy.v2.Policy]: crate::model::Policy
3003    pub name: std::string::String,
3004
3005    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3006}
3007
3008impl GetPolicyRequest {
3009    pub fn new() -> Self {
3010        std::default::Default::default()
3011    }
3012
3013    /// Sets the value of [name][crate::model::GetPolicyRequest::name].
3014    ///
3015    /// # Example
3016    /// ```ignore,no_run
3017    /// # use google_cloud_orgpolicy_v2::model::GetPolicyRequest;
3018    /// let x = GetPolicyRequest::new().set_name("example");
3019    /// ```
3020    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3021        self.name = v.into();
3022        self
3023    }
3024}
3025
3026impl wkt::message::Message for GetPolicyRequest {
3027    fn typename() -> &'static str {
3028        "type.googleapis.com/google.cloud.orgpolicy.v2.GetPolicyRequest"
3029    }
3030}
3031
3032/// The request sent to the [GetEffectivePolicy]
3033/// [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method.
3034#[derive(Clone, Default, PartialEq)]
3035#[non_exhaustive]
3036pub struct GetEffectivePolicyRequest {
3037    /// Required. The effective policy to compute. See
3038    /// [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
3039    ///
3040    /// [google.cloud.orgpolicy.v2.Policy]: crate::model::Policy
3041    pub name: std::string::String,
3042
3043    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3044}
3045
3046impl GetEffectivePolicyRequest {
3047    pub fn new() -> Self {
3048        std::default::Default::default()
3049    }
3050
3051    /// Sets the value of [name][crate::model::GetEffectivePolicyRequest::name].
3052    ///
3053    /// # Example
3054    /// ```ignore,no_run
3055    /// # use google_cloud_orgpolicy_v2::model::GetEffectivePolicyRequest;
3056    /// let x = GetEffectivePolicyRequest::new().set_name("example");
3057    /// ```
3058    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3059        self.name = v.into();
3060        self
3061    }
3062}
3063
3064impl wkt::message::Message for GetEffectivePolicyRequest {
3065    fn typename() -> &'static str {
3066        "type.googleapis.com/google.cloud.orgpolicy.v2.GetEffectivePolicyRequest"
3067    }
3068}
3069
3070/// The request sent to the [CreatePolicyRequest]
3071/// [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method.
3072#[derive(Clone, Default, PartialEq)]
3073#[non_exhaustive]
3074pub struct CreatePolicyRequest {
3075    /// Required. The Google Cloud resource that will parent the new policy. Must
3076    /// be in one of the following forms:
3077    ///
3078    /// * `projects/{project_number}`
3079    /// * `projects/{project_id}`
3080    /// * `folders/{folder_id}`
3081    /// * `organizations/{organization_id}`
3082    pub parent: std::string::String,
3083
3084    /// Required. Policy to create.
3085    pub policy: std::option::Option<crate::model::Policy>,
3086
3087    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3088}
3089
3090impl CreatePolicyRequest {
3091    pub fn new() -> Self {
3092        std::default::Default::default()
3093    }
3094
3095    /// Sets the value of [parent][crate::model::CreatePolicyRequest::parent].
3096    ///
3097    /// # Example
3098    /// ```ignore,no_run
3099    /// # use google_cloud_orgpolicy_v2::model::CreatePolicyRequest;
3100    /// let x = CreatePolicyRequest::new().set_parent("example");
3101    /// ```
3102    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3103        self.parent = v.into();
3104        self
3105    }
3106
3107    /// Sets the value of [policy][crate::model::CreatePolicyRequest::policy].
3108    ///
3109    /// # Example
3110    /// ```ignore,no_run
3111    /// # use google_cloud_orgpolicy_v2::model::CreatePolicyRequest;
3112    /// use google_cloud_orgpolicy_v2::model::Policy;
3113    /// let x = CreatePolicyRequest::new().set_policy(Policy::default()/* use setters */);
3114    /// ```
3115    pub fn set_policy<T>(mut self, v: T) -> Self
3116    where
3117        T: std::convert::Into<crate::model::Policy>,
3118    {
3119        self.policy = std::option::Option::Some(v.into());
3120        self
3121    }
3122
3123    /// Sets or clears the value of [policy][crate::model::CreatePolicyRequest::policy].
3124    ///
3125    /// # Example
3126    /// ```ignore,no_run
3127    /// # use google_cloud_orgpolicy_v2::model::CreatePolicyRequest;
3128    /// use google_cloud_orgpolicy_v2::model::Policy;
3129    /// let x = CreatePolicyRequest::new().set_or_clear_policy(Some(Policy::default()/* use setters */));
3130    /// let x = CreatePolicyRequest::new().set_or_clear_policy(None::<Policy>);
3131    /// ```
3132    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
3133    where
3134        T: std::convert::Into<crate::model::Policy>,
3135    {
3136        self.policy = v.map(|x| x.into());
3137        self
3138    }
3139}
3140
3141impl wkt::message::Message for CreatePolicyRequest {
3142    fn typename() -> &'static str {
3143        "type.googleapis.com/google.cloud.orgpolicy.v2.CreatePolicyRequest"
3144    }
3145}
3146
3147/// The request sent to the [UpdatePolicyRequest]
3148/// [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method.
3149#[derive(Clone, Default, PartialEq)]
3150#[non_exhaustive]
3151pub struct UpdatePolicyRequest {
3152    /// Required. Policy to update.
3153    pub policy: std::option::Option<crate::model::Policy>,
3154
3155    /// Field mask used to specify the fields to be overwritten in the policy
3156    /// by the set. The fields specified in the update_mask are relative to the
3157    /// policy, not the full request.
3158    pub update_mask: std::option::Option<wkt::FieldMask>,
3159
3160    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3161}
3162
3163impl UpdatePolicyRequest {
3164    pub fn new() -> Self {
3165        std::default::Default::default()
3166    }
3167
3168    /// Sets the value of [policy][crate::model::UpdatePolicyRequest::policy].
3169    ///
3170    /// # Example
3171    /// ```ignore,no_run
3172    /// # use google_cloud_orgpolicy_v2::model::UpdatePolicyRequest;
3173    /// use google_cloud_orgpolicy_v2::model::Policy;
3174    /// let x = UpdatePolicyRequest::new().set_policy(Policy::default()/* use setters */);
3175    /// ```
3176    pub fn set_policy<T>(mut self, v: T) -> Self
3177    where
3178        T: std::convert::Into<crate::model::Policy>,
3179    {
3180        self.policy = std::option::Option::Some(v.into());
3181        self
3182    }
3183
3184    /// Sets or clears the value of [policy][crate::model::UpdatePolicyRequest::policy].
3185    ///
3186    /// # Example
3187    /// ```ignore,no_run
3188    /// # use google_cloud_orgpolicy_v2::model::UpdatePolicyRequest;
3189    /// use google_cloud_orgpolicy_v2::model::Policy;
3190    /// let x = UpdatePolicyRequest::new().set_or_clear_policy(Some(Policy::default()/* use setters */));
3191    /// let x = UpdatePolicyRequest::new().set_or_clear_policy(None::<Policy>);
3192    /// ```
3193    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
3194    where
3195        T: std::convert::Into<crate::model::Policy>,
3196    {
3197        self.policy = v.map(|x| x.into());
3198        self
3199    }
3200
3201    /// Sets the value of [update_mask][crate::model::UpdatePolicyRequest::update_mask].
3202    ///
3203    /// # Example
3204    /// ```ignore,no_run
3205    /// # use google_cloud_orgpolicy_v2::model::UpdatePolicyRequest;
3206    /// use wkt::FieldMask;
3207    /// let x = UpdatePolicyRequest::new().set_update_mask(FieldMask::default()/* use setters */);
3208    /// ```
3209    pub fn set_update_mask<T>(mut self, v: T) -> Self
3210    where
3211        T: std::convert::Into<wkt::FieldMask>,
3212    {
3213        self.update_mask = std::option::Option::Some(v.into());
3214        self
3215    }
3216
3217    /// Sets or clears the value of [update_mask][crate::model::UpdatePolicyRequest::update_mask].
3218    ///
3219    /// # Example
3220    /// ```ignore,no_run
3221    /// # use google_cloud_orgpolicy_v2::model::UpdatePolicyRequest;
3222    /// use wkt::FieldMask;
3223    /// let x = UpdatePolicyRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
3224    /// let x = UpdatePolicyRequest::new().set_or_clear_update_mask(None::<FieldMask>);
3225    /// ```
3226    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
3227    where
3228        T: std::convert::Into<wkt::FieldMask>,
3229    {
3230        self.update_mask = v.map(|x| x.into());
3231        self
3232    }
3233}
3234
3235impl wkt::message::Message for UpdatePolicyRequest {
3236    fn typename() -> &'static str {
3237        "type.googleapis.com/google.cloud.orgpolicy.v2.UpdatePolicyRequest"
3238    }
3239}
3240
3241/// The request sent to the [DeletePolicy]
3242/// [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method.
3243#[derive(Clone, Default, PartialEq)]
3244#[non_exhaustive]
3245pub struct DeletePolicyRequest {
3246    /// Required. Name of the policy to delete.
3247    /// See the policy entry for naming rules.
3248    pub name: std::string::String,
3249
3250    /// Optional. The current etag of policy. If an etag is provided and does not
3251    /// match the current etag of the policy, deletion will be blocked and an
3252    /// ABORTED error will be returned.
3253    pub etag: std::string::String,
3254
3255    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3256}
3257
3258impl DeletePolicyRequest {
3259    pub fn new() -> Self {
3260        std::default::Default::default()
3261    }
3262
3263    /// Sets the value of [name][crate::model::DeletePolicyRequest::name].
3264    ///
3265    /// # Example
3266    /// ```ignore,no_run
3267    /// # use google_cloud_orgpolicy_v2::model::DeletePolicyRequest;
3268    /// let x = DeletePolicyRequest::new().set_name("example");
3269    /// ```
3270    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3271        self.name = v.into();
3272        self
3273    }
3274
3275    /// Sets the value of [etag][crate::model::DeletePolicyRequest::etag].
3276    ///
3277    /// # Example
3278    /// ```ignore,no_run
3279    /// # use google_cloud_orgpolicy_v2::model::DeletePolicyRequest;
3280    /// let x = DeletePolicyRequest::new().set_etag("example");
3281    /// ```
3282    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3283        self.etag = v.into();
3284        self
3285    }
3286}
3287
3288impl wkt::message::Message for DeletePolicyRequest {
3289    fn typename() -> &'static str {
3290        "type.googleapis.com/google.cloud.orgpolicy.v2.DeletePolicyRequest"
3291    }
3292}
3293
3294/// The request sent to the [CreateCustomConstraintRequest]
3295/// [google.cloud.orgpolicy.v2.OrgPolicy.CreateCustomConstraint] method.
3296#[derive(Clone, Default, PartialEq)]
3297#[non_exhaustive]
3298pub struct CreateCustomConstraintRequest {
3299    /// Required. Must be in the following form:
3300    ///
3301    /// * `organizations/{organization_id}`
3302    pub parent: std::string::String,
3303
3304    /// Required. Custom constraint to create.
3305    pub custom_constraint: std::option::Option<crate::model::CustomConstraint>,
3306
3307    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3308}
3309
3310impl CreateCustomConstraintRequest {
3311    pub fn new() -> Self {
3312        std::default::Default::default()
3313    }
3314
3315    /// Sets the value of [parent][crate::model::CreateCustomConstraintRequest::parent].
3316    ///
3317    /// # Example
3318    /// ```ignore,no_run
3319    /// # use google_cloud_orgpolicy_v2::model::CreateCustomConstraintRequest;
3320    /// let x = CreateCustomConstraintRequest::new().set_parent("example");
3321    /// ```
3322    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3323        self.parent = v.into();
3324        self
3325    }
3326
3327    /// Sets the value of [custom_constraint][crate::model::CreateCustomConstraintRequest::custom_constraint].
3328    ///
3329    /// # Example
3330    /// ```ignore,no_run
3331    /// # use google_cloud_orgpolicy_v2::model::CreateCustomConstraintRequest;
3332    /// use google_cloud_orgpolicy_v2::model::CustomConstraint;
3333    /// let x = CreateCustomConstraintRequest::new().set_custom_constraint(CustomConstraint::default()/* use setters */);
3334    /// ```
3335    pub fn set_custom_constraint<T>(mut self, v: T) -> Self
3336    where
3337        T: std::convert::Into<crate::model::CustomConstraint>,
3338    {
3339        self.custom_constraint = std::option::Option::Some(v.into());
3340        self
3341    }
3342
3343    /// Sets or clears the value of [custom_constraint][crate::model::CreateCustomConstraintRequest::custom_constraint].
3344    ///
3345    /// # Example
3346    /// ```ignore,no_run
3347    /// # use google_cloud_orgpolicy_v2::model::CreateCustomConstraintRequest;
3348    /// use google_cloud_orgpolicy_v2::model::CustomConstraint;
3349    /// let x = CreateCustomConstraintRequest::new().set_or_clear_custom_constraint(Some(CustomConstraint::default()/* use setters */));
3350    /// let x = CreateCustomConstraintRequest::new().set_or_clear_custom_constraint(None::<CustomConstraint>);
3351    /// ```
3352    pub fn set_or_clear_custom_constraint<T>(mut self, v: std::option::Option<T>) -> Self
3353    where
3354        T: std::convert::Into<crate::model::CustomConstraint>,
3355    {
3356        self.custom_constraint = v.map(|x| x.into());
3357        self
3358    }
3359}
3360
3361impl wkt::message::Message for CreateCustomConstraintRequest {
3362    fn typename() -> &'static str {
3363        "type.googleapis.com/google.cloud.orgpolicy.v2.CreateCustomConstraintRequest"
3364    }
3365}
3366
3367/// The request sent to the [GetCustomConstraint]
3368/// [google.cloud.orgpolicy.v2.OrgPolicy.GetCustomConstraint] method.
3369#[derive(Clone, Default, PartialEq)]
3370#[non_exhaustive]
3371pub struct GetCustomConstraintRequest {
3372    /// Required. Resource name of the custom or managed constraint. See the custom
3373    /// constraint entry for naming requirements.
3374    pub name: std::string::String,
3375
3376    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3377}
3378
3379impl GetCustomConstraintRequest {
3380    pub fn new() -> Self {
3381        std::default::Default::default()
3382    }
3383
3384    /// Sets the value of [name][crate::model::GetCustomConstraintRequest::name].
3385    ///
3386    /// # Example
3387    /// ```ignore,no_run
3388    /// # use google_cloud_orgpolicy_v2::model::GetCustomConstraintRequest;
3389    /// let x = GetCustomConstraintRequest::new().set_name("example");
3390    /// ```
3391    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3392        self.name = v.into();
3393        self
3394    }
3395}
3396
3397impl wkt::message::Message for GetCustomConstraintRequest {
3398    fn typename() -> &'static str {
3399        "type.googleapis.com/google.cloud.orgpolicy.v2.GetCustomConstraintRequest"
3400    }
3401}
3402
3403/// The request sent to the [ListCustomConstraints]
3404/// [google.cloud.orgpolicy.v2.OrgPolicy.ListCustomConstraints] method.
3405#[derive(Clone, Default, PartialEq)]
3406#[non_exhaustive]
3407pub struct ListCustomConstraintsRequest {
3408    /// Required. The target Google Cloud resource that parents the set of custom
3409    /// constraints that will be returned from this call. Must be in one of the
3410    /// following forms:
3411    ///
3412    /// * `organizations/{organization_id}`
3413    pub parent: std::string::String,
3414
3415    /// Size of the pages to be returned. This is currently unsupported and will
3416    /// be ignored. The server may at any point start using this field to limit
3417    /// page size.
3418    pub page_size: i32,
3419
3420    /// Page token used to retrieve the next page. This is currently unsupported
3421    /// and will be ignored. The server may at any point start using this field.
3422    pub page_token: std::string::String,
3423
3424    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3425}
3426
3427impl ListCustomConstraintsRequest {
3428    pub fn new() -> Self {
3429        std::default::Default::default()
3430    }
3431
3432    /// Sets the value of [parent][crate::model::ListCustomConstraintsRequest::parent].
3433    ///
3434    /// # Example
3435    /// ```ignore,no_run
3436    /// # use google_cloud_orgpolicy_v2::model::ListCustomConstraintsRequest;
3437    /// let x = ListCustomConstraintsRequest::new().set_parent("example");
3438    /// ```
3439    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3440        self.parent = v.into();
3441        self
3442    }
3443
3444    /// Sets the value of [page_size][crate::model::ListCustomConstraintsRequest::page_size].
3445    ///
3446    /// # Example
3447    /// ```ignore,no_run
3448    /// # use google_cloud_orgpolicy_v2::model::ListCustomConstraintsRequest;
3449    /// let x = ListCustomConstraintsRequest::new().set_page_size(42);
3450    /// ```
3451    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3452        self.page_size = v.into();
3453        self
3454    }
3455
3456    /// Sets the value of [page_token][crate::model::ListCustomConstraintsRequest::page_token].
3457    ///
3458    /// # Example
3459    /// ```ignore,no_run
3460    /// # use google_cloud_orgpolicy_v2::model::ListCustomConstraintsRequest;
3461    /// let x = ListCustomConstraintsRequest::new().set_page_token("example");
3462    /// ```
3463    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3464        self.page_token = v.into();
3465        self
3466    }
3467}
3468
3469impl wkt::message::Message for ListCustomConstraintsRequest {
3470    fn typename() -> &'static str {
3471        "type.googleapis.com/google.cloud.orgpolicy.v2.ListCustomConstraintsRequest"
3472    }
3473}
3474
3475/// The response returned from the [ListCustomConstraints]
3476/// [google.cloud.orgpolicy.v2.OrgPolicy.ListCustomConstraints] method. It will
3477/// be empty if no custom or managed constraints are set on the organization
3478/// resource.
3479#[derive(Clone, Default, PartialEq)]
3480#[non_exhaustive]
3481pub struct ListCustomConstraintsResponse {
3482    /// All custom and managed constraints that exist on the organization resource.
3483    /// It will be empty if no custom constraints are set.
3484    pub custom_constraints: std::vec::Vec<crate::model::CustomConstraint>,
3485
3486    /// Page token used to retrieve the next page. This is currently not used, but
3487    /// the server may at any point start supplying a valid token.
3488    pub next_page_token: std::string::String,
3489
3490    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3491}
3492
3493impl ListCustomConstraintsResponse {
3494    pub fn new() -> Self {
3495        std::default::Default::default()
3496    }
3497
3498    /// Sets the value of [custom_constraints][crate::model::ListCustomConstraintsResponse::custom_constraints].
3499    ///
3500    /// # Example
3501    /// ```ignore,no_run
3502    /// # use google_cloud_orgpolicy_v2::model::ListCustomConstraintsResponse;
3503    /// use google_cloud_orgpolicy_v2::model::CustomConstraint;
3504    /// let x = ListCustomConstraintsResponse::new()
3505    ///     .set_custom_constraints([
3506    ///         CustomConstraint::default()/* use setters */,
3507    ///         CustomConstraint::default()/* use (different) setters */,
3508    ///     ]);
3509    /// ```
3510    pub fn set_custom_constraints<T, V>(mut self, v: T) -> Self
3511    where
3512        T: std::iter::IntoIterator<Item = V>,
3513        V: std::convert::Into<crate::model::CustomConstraint>,
3514    {
3515        use std::iter::Iterator;
3516        self.custom_constraints = v.into_iter().map(|i| i.into()).collect();
3517        self
3518    }
3519
3520    /// Sets the value of [next_page_token][crate::model::ListCustomConstraintsResponse::next_page_token].
3521    ///
3522    /// # Example
3523    /// ```ignore,no_run
3524    /// # use google_cloud_orgpolicy_v2::model::ListCustomConstraintsResponse;
3525    /// let x = ListCustomConstraintsResponse::new().set_next_page_token("example");
3526    /// ```
3527    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3528        self.next_page_token = v.into();
3529        self
3530    }
3531}
3532
3533impl wkt::message::Message for ListCustomConstraintsResponse {
3534    fn typename() -> &'static str {
3535        "type.googleapis.com/google.cloud.orgpolicy.v2.ListCustomConstraintsResponse"
3536    }
3537}
3538
3539#[doc(hidden)]
3540impl google_cloud_gax::paginator::internal::PageableResponse for ListCustomConstraintsResponse {
3541    type PageItem = crate::model::CustomConstraint;
3542
3543    fn items(self) -> std::vec::Vec<Self::PageItem> {
3544        self.custom_constraints
3545    }
3546
3547    fn next_page_token(&self) -> std::string::String {
3548        use std::clone::Clone;
3549        self.next_page_token.clone()
3550    }
3551}
3552
3553/// The request sent to the [UpdateCustomConstraintRequest]
3554/// [google.cloud.orgpolicy.v2.OrgPolicy.UpdateCustomConstraint] method.
3555#[derive(Clone, Default, PartialEq)]
3556#[non_exhaustive]
3557pub struct UpdateCustomConstraintRequest {
3558    /// Required. `CustomConstraint` to update.
3559    pub custom_constraint: std::option::Option<crate::model::CustomConstraint>,
3560
3561    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3562}
3563
3564impl UpdateCustomConstraintRequest {
3565    pub fn new() -> Self {
3566        std::default::Default::default()
3567    }
3568
3569    /// Sets the value of [custom_constraint][crate::model::UpdateCustomConstraintRequest::custom_constraint].
3570    ///
3571    /// # Example
3572    /// ```ignore,no_run
3573    /// # use google_cloud_orgpolicy_v2::model::UpdateCustomConstraintRequest;
3574    /// use google_cloud_orgpolicy_v2::model::CustomConstraint;
3575    /// let x = UpdateCustomConstraintRequest::new().set_custom_constraint(CustomConstraint::default()/* use setters */);
3576    /// ```
3577    pub fn set_custom_constraint<T>(mut self, v: T) -> Self
3578    where
3579        T: std::convert::Into<crate::model::CustomConstraint>,
3580    {
3581        self.custom_constraint = std::option::Option::Some(v.into());
3582        self
3583    }
3584
3585    /// Sets or clears the value of [custom_constraint][crate::model::UpdateCustomConstraintRequest::custom_constraint].
3586    ///
3587    /// # Example
3588    /// ```ignore,no_run
3589    /// # use google_cloud_orgpolicy_v2::model::UpdateCustomConstraintRequest;
3590    /// use google_cloud_orgpolicy_v2::model::CustomConstraint;
3591    /// let x = UpdateCustomConstraintRequest::new().set_or_clear_custom_constraint(Some(CustomConstraint::default()/* use setters */));
3592    /// let x = UpdateCustomConstraintRequest::new().set_or_clear_custom_constraint(None::<CustomConstraint>);
3593    /// ```
3594    pub fn set_or_clear_custom_constraint<T>(mut self, v: std::option::Option<T>) -> Self
3595    where
3596        T: std::convert::Into<crate::model::CustomConstraint>,
3597    {
3598        self.custom_constraint = v.map(|x| x.into());
3599        self
3600    }
3601}
3602
3603impl wkt::message::Message for UpdateCustomConstraintRequest {
3604    fn typename() -> &'static str {
3605        "type.googleapis.com/google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest"
3606    }
3607}
3608
3609/// The request sent to the [DeleteCustomConstraint]
3610/// [google.cloud.orgpolicy.v2.OrgPolicy.DeleteCustomConstraint] method.
3611#[derive(Clone, Default, PartialEq)]
3612#[non_exhaustive]
3613pub struct DeleteCustomConstraintRequest {
3614    /// Required. Name of the custom constraint to delete.
3615    /// See the custom constraint entry for naming rules.
3616    pub name: std::string::String,
3617
3618    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3619}
3620
3621impl DeleteCustomConstraintRequest {
3622    pub fn new() -> Self {
3623        std::default::Default::default()
3624    }
3625
3626    /// Sets the value of [name][crate::model::DeleteCustomConstraintRequest::name].
3627    ///
3628    /// # Example
3629    /// ```ignore,no_run
3630    /// # use google_cloud_orgpolicy_v2::model::DeleteCustomConstraintRequest;
3631    /// let x = DeleteCustomConstraintRequest::new().set_name("example");
3632    /// ```
3633    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3634        self.name = v.into();
3635        self
3636    }
3637}
3638
3639impl wkt::message::Message for DeleteCustomConstraintRequest {
3640    fn typename() -> &'static str {
3641        "type.googleapis.com/google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest"
3642    }
3643}