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