class OCI::ObjectStorage::Models::ObjectLifecycleRule

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](docs.cloud.oracle.com/Content/Identity/Concepts/policygetstarted.htm).

Constants

TIME_UNIT_ENUM

Attributes

action[RW]

[Required] The action of the object lifecycle policy rule. Rules using the action 'ARCHIVE' move objects from Standard and InfrequentAccess storage tiers into the [Archive storage tier](docs.cloud.oracle.com/Content/Archive/Concepts/archivestorageoverview.htm). Rules using the action 'INFREQUENT_ACCESS' move objects from Standard storage tier into the Infrequent Access Storage tier. Objects that are already in InfrequentAccess tier or in Archive tier are left untouched. Rules using the action 'DELETE' permanently delete objects from buckets. Rules using 'ABORT' abort the uncommitted multipart-uploads and permanently delete their parts from buckets.

@return [String]

is_enabled[RW]

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

name[RW]

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

object_name_filter[RW]

@return [OCI::ObjectStorage::Models::ObjectNameFilter]

target[RW]

The target of the object lifecycle policy rule. The values of target can be either "objects", "multipart-uploads" or "previous-object-versions". This field when declared as "objects" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for objects. This field when declared as "previous-object-versions" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for previous versions of existing objects. This field when declared as "multipart-uploads" is used to specify the ABORT (only) rule for uncommitted multipart-uploads.

@return [String]

time_amount[RW]

[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.

@return [Integer]

time_unit[R]

[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.

@return [String]

Public Class Methods

attribute_map() click to toggle source

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

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 68
def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'name',
    'target': :'target',
    'action': :'action',
    'time_amount': :'timeAmount',
    'time_unit': :'timeUnit',
    'is_enabled': :'isEnabled',
    'object_name_filter': :'objectNameFilter'
    # rubocop:enable Style/SymbolLiteral
  }
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash @option attributes [String] :name The value to assign to the {#name} property @option attributes [String] :target The value to assign to the {#target} property @option attributes [String] :action The value to assign to the {#action} property @option attributes [Integer] :time_amount The value to assign to the {#time_amount} property @option attributes [String] :time_unit The value to assign to the {#time_unit} property @option attributes [BOOLEAN] :is_enabled The value to assign to the {#is_enabled} property @option attributes [OCI::ObjectStorage::Models::ObjectNameFilter] :object_name_filter The value to assign to the {#object_name_filter} property

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 110
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.target = attributes[:'target'] if attributes[:'target']
  self.target = "objects" if target.nil? && !attributes.key?(:'target') # rubocop:disable Style/StringLiterals

  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
swagger_types() click to toggle source

Attribute type mapping.

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 83
def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'name': :'String',
    'target': :'String',
    'action': :'String',
    'time_amount': :'Integer',
    'time_unit': :'String',
    'is_enabled': :'BOOLEAN',
    'object_name_filter': :'OCI::ObjectStorage::Models::ObjectNameFilter'
    # rubocop:enable Style/SymbolLiteral
  }
end

Public Instance Methods

==(other) click to toggle source

Checks equality by comparing each attribute. @param [Object] other the other object to be compared

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 168
def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    name == other.name &&
    target == other.target &&
    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) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 204
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) click to toggle source

@see the `==` method @param [Object] other the other object to be compared

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 184
def eql?(other)
  self == other
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 193
def hash
  [name, target, action, time_amount, time_unit, is_enabled, object_name_filter].hash
end
time_unit=(time_unit) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] time_unit Object to be assigned

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 152
def time_unit=(time_unit)
  # rubocop:disable Style/ConditionalAssignment
  if time_unit && !TIME_UNIT_ENUM.include?(time_unit)
    OCI.logger.debug("Unknown value for 'time_unit' [" + time_unit + "]. Mapping to 'TIME_UNIT_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @time_unit = TIME_UNIT_UNKNOWN_ENUM_VALUE
  else
    @time_unit = time_unit
  end
  # rubocop:enable Style/ConditionalAssignment
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 237
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_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 231
def to_s
  to_hash.to_s
end

Private Instance Methods

_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/oci/object_storage/models/object_lifecycle_rule.rb, line 254
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end