Class: OCI::ObjectStorage::Models::ObjectLifecycleRule

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/object_storage/models/object_lifecycle_rule.rb

Overview

To use any of the API operations, you must be authorized in an IAM policy. If you are not authorized, talk to an administrator. If you are an administrator who needs to write policies to give users access, see Getting Started with Policies.

Constant Summary collapse

TIME_UNIT_ENUM =
[
  TIME_UNIT_DAYS = 'DAYS'.freeze,
  TIME_UNIT_YEARS = 'YEARS'.freeze,
  TIME_UNIT_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ObjectLifecycleRule

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Options Hash (attributes):



91
92
93
94
95
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
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 91

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

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

  self.time_amount = attributes[:'timeAmount'] if attributes[:'timeAmount']

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

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

  self.time_unit = attributes[:'timeUnit'] if attributes[:'timeUnit']

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

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

  self.is_enabled = attributes[:'isEnabled'] unless attributes[:'isEnabled'].nil?

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

  self.is_enabled = attributes[:'is_enabled'] unless attributes[:'is_enabled'].nil?

  self.object_name_filter = attributes[:'objectNameFilter'] if attributes[:'objectNameFilter']

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

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

Instance Attribute Details

#actionString

[Required] The action of the object lifecycle policy rule. Rules using the action 'ARCHIVE' move objects into the Archive Storage tier. Rules using the action 'DELETE' permanently delete objects from buckets. 'ARCHIVE' and 'DELETE' are the only two supported actions at this time.

Returns:

  • (String)


30
31
32
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 30

def action
  @action
end

#is_enabledBOOLEAN

[Required] A Boolean that determines whether this rule is currently enabled.

Returns:

  • (BOOLEAN)


46
47
48
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 46

def is_enabled
  @is_enabled
end

#nameString

[Required] The name of the lifecycle rule to be applied.

Returns:

  • (String)


22
23
24
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 22

def name
  @name
end

#object_name_filterOCI::ObjectStorage::Models::ObjectNameFilter



49
50
51
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 49

def object_name_filter
  @object_name_filter
end

#time_amountInteger

[Required] Specifies the age of objects to apply the rule to. The timeAmount is interpreted in units defined by the timeUnit parameter, and is calculated in relation to each object's Last-Modified time.

Returns:

  • (Integer)


36
37
38
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 36

def time_amount
  @time_amount
end

#time_unitString

[Required] The unit that should be used to interpret timeAmount. Days are defined as starting and ending at midnight UTC. Years are defined as 365.2425 days long and likewise round up to the next midnight UTC.

Returns:

  • (String)


42
43
44
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 42

def time_unit
  @time_unit
end

Class Method Details

.attribute_mapObject

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



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 52

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'name',
    'action': :'action',
    'time_amount': :'timeAmount',
    'time_unit': :'timeUnit',
    'is_enabled': :'isEnabled',
    'object_name_filter': :'objectNameFilter'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 66

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'String',
    'action': :'String',
    'time_amount': :'Integer',
    'time_unit': :'String',
    'is_enabled': :'BOOLEAN',
    'object_name_filter': :'OCI::ObjectStorage::Models::ObjectNameFilter'
    # 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



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 146

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

  self.class == other.class &&
    name == other.name &&
    action == other.action &&
    time_amount == other.time_amount &&
    time_unit == other.time_unit &&
    is_enabled == other.is_enabled &&
    object_name_filter == other.object_name_filter
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



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 181

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


161
162
163
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 161

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



170
171
172
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 170

def hash
  [name, action, time_amount, time_unit, is_enabled, object_name_filter].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



214
215
216
217
218
219
220
221
222
223
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 214

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



208
209
210
# File 'lib/oci/object_storage/models/object_lifecycle_rule.rb', line 208

def to_s
  to_hash.to_s
end