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