#[non_exhaustive]pub struct Operation {
pub action: String,
pub resource_type: String,
pub resource: String,
pub path: String,
pub source_resource: String,
pub source_path: String,
pub path_filters: HashMap<String, Value>,
pub path_value_matchers: HashMap<String, ValueMatcher>,
pub path_value: Option<PathValue>,
/* private fields */
}Expand description
Contains an operation for a resource loosely based on the JSON-PATCH format with support for:
- Custom filters for describing partial array patch.
- Extended path values for describing nested arrays.
- Custom fields for describing the resource for which the operation is being described.
- Allows extension to custom operations not natively supported by RFC6902. See https://tools.ietf.org/html/rfc6902 for details on the original RFC.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.action: StringType of this operation. Contains one of ‘add’, ‘remove’, ‘replace’, ‘move’, ‘copy’, ‘test’ and custom operations. This field is case-insensitive and always populated.
resource_type: StringType of GCP resource being modified/tested. This field is always populated. Example: cloudresourcemanager.googleapis.com/Project, compute.googleapis.com/Instance
resource: StringContains the fully qualified resource name. This field is always populated. ex: //cloudresourcemanager.googleapis.com/projects/foo.
path: StringPath to the target field being operated on. If the operation is at the resource level, then path should be “/”. This field is always populated.
source_resource: StringCan be set with action ‘copy’ to copy resource configuration across
different resources of the same type. Example: A resource clone can be
done via action = ‘copy’, path = “/”, from = “/”,
source_resource = <source> and resource_name = <target>.
This field is empty for all other values of action.
source_path: StringCan be set with action ‘copy’ or ‘move’ to indicate the source field within resource or source_resource, ignored if provided for other operation types.
path_filters: HashMap<String, Value>Set of filters to apply if path refers to array elements or nested array
elements in order to narrow down to a single unique element that is being
tested/modified.
This is intended to be an exact match per filter. To perform advanced
matching, use path_value_matchers.
- Example:
{
"/versions/*/name" : "it-123"
"/versions/*/targetSize/percent": 20
}- Example:
{
"/bindings/*/role": "roles/owner"
"/bindings/*/condition" : null
}- Example:
{
"/bindings/*/role": "roles/owner"
"/bindings/*/members/*" : ["x@example.com", "y@example.com"]
}When both path_filters and path_value_matchers are set, an implicit AND must be performed.
path_value_matchers: HashMap<String, ValueMatcher>Similar to path_filters, this contains set of filters to apply if path
field refers to array elements. This is meant to support value matching
beyond exact match. To perform exact match, use path_filters.
When both path_filters and path_value_matchers are set, an implicit AND
must be performed.
path_value: Option<PathValue>One of the fields in the following block will be set and intend to describe a value for ‘path’ field.
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn set_action<T: Into<String>>(self, v: T) -> Self
pub fn set_action<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_resource_type<T: Into<String>>(self, v: T) -> Self
pub fn set_resource_type<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_resource<T: Into<String>>(self, v: T) -> Self
pub fn set_resource<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_source_resource<T: Into<String>>(self, v: T) -> Self
pub fn set_source_resource<T: Into<String>>(self, v: T) -> Self
Sets the value of source_resource.
§Example
let x = Operation::new().set_source_resource("example");Sourcepub fn set_source_path<T: Into<String>>(self, v: T) -> Self
pub fn set_source_path<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_path_filters<T, K, V>(self, v: T) -> Self
pub fn set_path_filters<T, K, V>(self, v: T) -> Self
Sets the value of path_filters.
§Example
use wkt::Value;
let x = Operation::new().set_path_filters([
("key0", Value::default()/* use setters */),
("key1", Value::default()/* use (different) setters */),
]);Sourcepub fn set_path_value_matchers<T, K, V>(self, v: T) -> Self
pub fn set_path_value_matchers<T, K, V>(self, v: T) -> Self
Sets the value of path_value_matchers.
§Example
use google_cloud_recommender_v1::model::ValueMatcher;
let x = Operation::new().set_path_value_matchers([
("key0", ValueMatcher::default()/* use setters */),
("key1", ValueMatcher::default()/* use (different) setters */),
]);Sourcepub fn set_path_value<T: Into<Option<PathValue>>>(self, v: T) -> Self
pub fn set_path_value<T: Into<Option<PathValue>>>(self, v: T) -> Self
Sets the value of path_value.
Note that all the setters affecting path_value are mutually
exclusive.
§Example
use wkt::Value;
let x = Operation::new().set_path_value(Some(
google_cloud_recommender_v1::model::operation::PathValue::Value(Value::default().into())));Sourcepub fn value(&self) -> Option<&Box<Value>>
pub fn value(&self) -> Option<&Box<Value>>
The value of path_value
if it holds a Value, None if the field is not set or
holds a different branch.
Sourcepub fn set_value<T: Into<Box<Value>>>(self, v: T) -> Self
pub fn set_value<T: Into<Box<Value>>>(self, v: T) -> Self
Sets the value of path_value
to hold a Value.
Note that all the setters affecting path_value are
mutually exclusive.
§Example
use wkt::Value;
let x = Operation::new().set_value(Value::default()/* use setters */);
assert!(x.value().is_some());
assert!(x.value_matcher().is_none());Sourcepub fn value_matcher(&self) -> Option<&Box<ValueMatcher>>
pub fn value_matcher(&self) -> Option<&Box<ValueMatcher>>
The value of path_value
if it holds a ValueMatcher, None if the field is not set or
holds a different branch.
Sourcepub fn set_value_matcher<T: Into<Box<ValueMatcher>>>(self, v: T) -> Self
pub fn set_value_matcher<T: Into<Box<ValueMatcher>>>(self, v: T) -> Self
Sets the value of path_value
to hold a ValueMatcher.
Note that all the setters affecting path_value are
mutually exclusive.
§Example
use google_cloud_recommender_v1::model::ValueMatcher;
let x = Operation::new().set_value_matcher(ValueMatcher::default()/* use setters */);
assert!(x.value_matcher().is_some());
assert!(x.value().is_none());