Class: OCI::Optimizer::Models::TargetTag

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/optimizer/models/target_tag.rb

Overview

A tag key definition used in the current profile override, including the tag namespace, tag key, tag value type, and tag values. Only defined tags are supported. For more information about tagging, see [Tagging Overview](docs.cloud.oracle.com/iaas/Content/Tagging/Concepts/taggingoverview.htm)

Constant Summary collapse

TAG_VALUE_TYPE_ENUM =
[
  TAG_VALUE_TYPE_VALUE = 'VALUE'.freeze,
  TAG_VALUE_TYPE_ANY = 'ANY'.freeze,
  TAG_VALUE_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ TargetTag

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):

  • :tag_namespace_name (String)

    The value to assign to the #tag_namespace_name property

  • :tag_definition_name (String)

    The value to assign to the #tag_definition_name property

  • :tag_value_type (String)

    The value to assign to the #tag_value_type property

  • :tag_values (Array<String>)

    The value to assign to the #tag_values property



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/oci/optimizer/models/target_tag.rb', line 77

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.tag_namespace_name = attributes[:'tagNamespaceName'] if attributes[:'tagNamespaceName']

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

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

  self.tag_definition_name = attributes[:'tagDefinitionName'] if attributes[:'tagDefinitionName']

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

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

  self.tag_value_type = attributes[:'tagValueType'] if attributes[:'tagValueType']

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

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

  self.tag_values = attributes[:'tagValues'] if attributes[:'tagValues']

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

  self.tag_values = attributes[:'tag_values'] if attributes[:'tag_values']
end

Instance Attribute Details

#tag_definition_nameString

[Required] The name you use to refer to the tag, also known as the tag key.

Returns:

  • (String)


26
27
28
# File 'lib/oci/optimizer/models/target_tag.rb', line 26

def tag_definition_name
  @tag_definition_name
end

#tag_namespace_nameString

[Required] The name of the tag namespace.

Returns:

  • (String)


22
23
24
# File 'lib/oci/optimizer/models/target_tag.rb', line 22

def tag_namespace_name
  @tag_namespace_name
end

#tag_value_typeString

[Required] Specifies which tag value types in the tagValues field result in overrides of the recommendation criteria.

When the value for this field is ANY, the tagValues field should be empty, which enforces overrides to the recommendation for resources with any tag values attached to them.

When the value for this field value is VALUE, the tagValues field must include a specific value or list of values. Overrides to the recommendation criteria only occur for resources that match the values in the tagValues fields.

Returns:

  • (String)


37
38
39
# File 'lib/oci/optimizer/models/target_tag.rb', line 37

def tag_value_type
  @tag_value_type
end

#tag_valuesArray<String>

The list of tag values. The tag value is the value that the user applying the tag adds to the tag key.

Returns:

  • (Array<String>)


41
42
43
# File 'lib/oci/optimizer/models/target_tag.rb', line 41

def tag_values
  @tag_values
end

Class Method Details

.attribute_mapObject

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



44
45
46
47
48
49
50
51
52
53
# File 'lib/oci/optimizer/models/target_tag.rb', line 44

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'tag_namespace_name': :'tagNamespaceName',
    'tag_definition_name': :'tagDefinitionName',
    'tag_value_type': :'tagValueType',
    'tag_values': :'tagValues'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



56
57
58
59
60
61
62
63
64
65
# File 'lib/oci/optimizer/models/target_tag.rb', line 56

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'tag_namespace_name': :'String',
    'tag_definition_name': :'String',
    'tag_value_type': :'String',
    'tag_values': :'Array<String>'
    # 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



128
129
130
131
132
133
134
135
136
# File 'lib/oci/optimizer/models/target_tag.rb', line 128

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

  self.class == other.class &&
    tag_namespace_name == other.tag_namespace_name &&
    tag_definition_name == other.tag_definition_name &&
    tag_value_type == other.tag_value_type &&
    tag_values == other.tag_values
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



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/oci/optimizer/models/target_tag.rb', line 161

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


141
142
143
# File 'lib/oci/optimizer/models/target_tag.rb', line 141

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



150
151
152
# File 'lib/oci/optimizer/models/target_tag.rb', line 150

def hash
  [tag_namespace_name, tag_definition_name, tag_value_type, tag_values].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



194
195
196
197
198
199
200
201
202
203
# File 'lib/oci/optimizer/models/target_tag.rb', line 194

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



188
189
190
# File 'lib/oci/optimizer/models/target_tag.rb', line 188

def to_s
  to_hash.to_s
end