Class: OCI::FleetAppsManagement::Models::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/fleet_apps_management/models/rule.rb

Overview

Rule for DYNAMIC selection.

Constant Summary collapse

MATCH_CONDITION_ENUM =
[
  MATCH_CONDITION_MATCH_ALL = 'MATCH_ALL'.freeze,
  MATCH_CONDITION_ANY = 'ANY'.freeze,
  MATCH_CONDITION_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Rule

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 96

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.basis = attributes[:'basis'] if attributes[:'basis']

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.resource_compartment_id = attributes[:'resourceCompartmentId'] if attributes[:'resourceCompartmentId']

  raise 'You cannot provide both :resourceCompartmentId and :resource_compartment_id' if attributes.key?(:'resourceCompartmentId') && attributes.key?(:'resource_compartment_id')

  self.resource_compartment_id = attributes[:'resource_compartment_id'] if attributes[:'resource_compartment_id']

  self.conditions = attributes[:'conditions'] if attributes[:'conditions']

  self.match_condition = attributes[:'matchCondition'] if attributes[:'matchCondition']
  self.match_condition = "ANY" if match_condition.nil? && !attributes.key?(:'matchCondition') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :matchCondition and :match_condition' if attributes.key?(:'matchCondition') && attributes.key?(:'match_condition')

  self.match_condition = attributes[:'match_condition'] if attributes[:'match_condition']
  self.match_condition = "ANY" if match_condition.nil? && !attributes.key?(:'matchCondition') && !attributes.key?(:'match_condition') # rubocop:disable Style/StringLiterals

  self.compartment_id_in_subtree = attributes[:'compartmentIdInSubtree'] unless attributes[:'compartmentIdInSubtree'].nil?
  self.compartment_id_in_subtree = false if compartment_id_in_subtree.nil? && !attributes.key?(:'compartmentIdInSubtree') # rubocop:disable Style/StringLiterals

  raise 'You cannot provide both :compartmentIdInSubtree and :compartment_id_in_subtree' if attributes.key?(:'compartmentIdInSubtree') && attributes.key?(:'compartment_id_in_subtree')

  self.compartment_id_in_subtree = attributes[:'compartment_id_in_subtree'] unless attributes[:'compartment_id_in_subtree'].nil?
  self.compartment_id_in_subtree = false if compartment_id_in_subtree.nil? && !attributes.key?(:'compartmentIdInSubtree') && !attributes.key?(:'compartment_id_in_subtree') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#basisString

Based on what the rule is created. It can be based on a resourceProperty or a tag. If based on a tag, basis will be 'definedTagEquals' If based on a resource property, basis will be 'inventoryProperties'

Returns:

  • (String)


25
26
27
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 25

def basis
  @basis
end

#compartment_idString

[Required] Compartment Id for which the rule is created.

Returns:

  • (String)


30
31
32
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 30

def compartment_id
  @compartment_id
end

#compartment_id_in_subtreeBOOLEAN

If set to true, resources will be returned for not only the provided compartment, but all compartments which descend from it. Which resources are returned and their field contents depends on the value of accessLevel. Default value for compartmentIdInSubtree is false

Returns:

  • (BOOLEAN)


54
55
56
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 54

def compartment_id_in_subtree
  @compartment_id_in_subtree
end

#conditionsArray<OCI::FleetAppsManagement::Models::Condition>

[Required] Rule Conditions



40
41
42
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 40

def conditions
  @conditions
end

#match_conditionString

Match condition for the rule selection. Include resources that match all rules or any of the rules. Default value for matchCondition is ANY

Returns:

  • (String)


47
48
49
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 47

def match_condition
  @match_condition
end

#resource_compartment_idString

[Required] The Compartment ID to dynamically search resources. Provide the compartment ID to which the rule is applicable.

Returns:

  • (String)


36
37
38
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 36

def resource_compartment_id
  @resource_compartment_id
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 57

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'basis': :'basis',
    'compartment_id': :'compartmentId',
    'resource_compartment_id': :'resourceCompartmentId',
    'conditions': :'conditions',
    'match_condition': :'matchCondition',
    'compartment_id_in_subtree': :'compartmentIdInSubtree'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 71

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'basis': :'String',
    'compartment_id': :'String',
    'resource_compartment_id': :'String',
    'conditions': :'Array<OCI::FleetAppsManagement::Models::Condition>',
    'match_condition': :'String',
    'compartment_id_in_subtree': :'BOOLEAN'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 155

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    basis == other.basis &&
    compartment_id == other.compartment_id &&
    resource_compartment_id == other.resource_compartment_id &&
    conditions == other.conditions &&
    match_condition == other.match_condition &&
    compartment_id_in_subtree == other.compartment_id_in_subtree
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 190

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


170
171
172
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 170

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



179
180
181
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 179

def hash
  [basis, compartment_id, resource_compartment_id, conditions, match_condition, compartment_id_in_subtree].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



223
224
225
226
227
228
229
230
231
232
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 223

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



217
218
219
# File 'lib/oci/fleet_apps_management/models/rule.rb', line 217

def to_s
  to_hash.to_s
end