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