class OCI::Secrets::Models::SecretBundle

The contents of the secret, properties of the secret (and secret version), and user-provided contextual metadata for the secret.

Constants

STAGES_ENUM

Attributes

metadata[RW]

Customer-provided contextual metadata for the secret.

@return [Hash<String, Object>]

secret_bundle_content[RW]

@return [OCI::Secrets::Models::SecretBundleContentDetails]

secret_id[RW]

[Required] The OCID of the secret. @return [String]

stages[R]

A list of possible rotation states for the secret version. @return [Array<String>]

time_created[RW]

The time when the secret bundle was created. @return [DateTime]

time_of_deletion[RW]

An optional property indicating when to delete the secret version, expressed in [RFC 3339](tools.ietf.org/html/rfc3339) timestamp format. Example: `2019-04-03T21:10:29.600Z`

@return [DateTime]

time_of_expiry[RW]

An optional property indicating when the secret version will expire, expressed in [RFC 3339](tools.ietf.org/html/rfc3339) timestamp format. Example: `2019-04-03T21:10:29.600Z`

@return [DateTime]

version_name[RW]

The name of the secret version. Labels are unique across the different versions of a particular secret.

@return [String]

version_number[RW]

[Required] The version number of the secret. @return [Integer]

Public Class Methods

attribute_map() click to toggle source

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

# File lib/oci/secrets/models/secret_bundle.rb, line 63
def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'secret_id': :'secretId',
    'time_created': :'timeCreated',
    'version_number': :'versionNumber',
    'version_name': :'versionName',
    'secret_bundle_content': :'secretBundleContent',
    'time_of_deletion': :'timeOfDeletion',
    'time_of_expiry': :'timeOfExpiry',
    'stages': :'stages',
    'metadata': :'metadata'
    # 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] :secret_id The value to assign to the {#secret_id} property @option attributes [DateTime] :time_created The value to assign to the {#time_created} property @option attributes [Integer] :version_number The value to assign to the {#version_number} property @option attributes [String] :version_name The value to assign to the {#version_name} property @option attributes [OCI::Secrets::Models::SecretBundleContentDetails] :secret_bundle_content The value to assign to the {#secret_bundle_content} property @option attributes [DateTime] :time_of_deletion The value to assign to the {#time_of_deletion} property @option attributes [DateTime] :time_of_expiry The value to assign to the {#time_of_expiry} property @option attributes [Array<String>] :stages The value to assign to the {#stages} property @option attributes [Hash<String, Object>] :metadata The value to assign to the {#metadata} property

# File lib/oci/secrets/models/secret_bundle.rb, line 111
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.secret_id = attributes[:'secretId'] if attributes[:'secretId']

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

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

  self.time_created = attributes[:'timeCreated'] if attributes[:'timeCreated']

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

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

  self.version_number = attributes[:'versionNumber'] if attributes[:'versionNumber']

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

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

  self.version_name = attributes[:'versionName'] if attributes[:'versionName']

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

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

  self.secret_bundle_content = attributes[:'secretBundleContent'] if attributes[:'secretBundleContent']

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

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

  self.time_of_deletion = attributes[:'timeOfDeletion'] if attributes[:'timeOfDeletion']

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

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

  self.time_of_expiry = attributes[:'timeOfExpiry'] if attributes[:'timeOfExpiry']

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

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

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

  self.metadata = attributes[:'metadata'] if attributes[:'metadata']
end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/oci/secrets/models/secret_bundle.rb, line 80
def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'secret_id': :'String',
    'time_created': :'DateTime',
    'version_number': :'Integer',
    'version_name': :'String',
    'secret_bundle_content': :'OCI::Secrets::Models::SecretBundleContentDetails',
    'time_of_deletion': :'DateTime',
    'time_of_expiry': :'DateTime',
    'stages': :'Array<String>',
    'metadata': :'Hash<String, Object>'
    # 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/secrets/models/secret_bundle.rb, line 191
def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    secret_id == other.secret_id &&
    time_created == other.time_created &&
    version_number == other.version_number &&
    version_name == other.version_name &&
    secret_bundle_content == other.secret_bundle_content &&
    time_of_deletion == other.time_of_deletion &&
    time_of_expiry == other.time_of_expiry &&
    stages == other.stages &&
    metadata == other.metadata
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/secrets/models/secret_bundle.rb, line 229
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/secrets/models/secret_bundle.rb, line 209
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/secrets/models/secret_bundle.rb, line 218
def hash
  [secret_id, time_created, version_number, version_name, secret_bundle_content, time_of_deletion, time_of_expiry, stages, metadata].hash
end
stages=(stages) click to toggle source

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

# File lib/oci/secrets/models/secret_bundle.rb, line 168
def stages=(stages)
  # rubocop:disable Style/ConditionalAssignment
  if stages.nil?
    @stages = nil
  else
    @stages =
      stages.collect do |item|
        if STAGES_ENUM.include?(item)
          item
        else
          OCI.logger.debug("Unknown value for 'stages' [#{item}]. Mapping to 'STAGES_UNKNOWN_ENUM_VALUE'") if OCI.logger
          STAGES_UNKNOWN_ENUM_VALUE
        end
      end
  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/secrets/models/secret_bundle.rb, line 262
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/secrets/models/secret_bundle.rb, line 256
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/secrets/models/secret_bundle.rb, line 279
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