class OCI::Core::Models::Image

A boot disk image for launching an instance. For more information, see [Overview of the Compute Service](docs.cloud.oracle.com/iaas/Content/Compute/Concepts/computeoverview.htm).

To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, talk to an administrator. If you're an administrator who needs to write policies to give users access, see [Getting Started with Policies](docs.cloud.oracle.com/iaas/Content/Identity/Concepts/policygetstarted.htm).

Warning: Oracle recommends that you avoid using any confidential information when you supply string values using the API.

Constants

LAUNCH_MODE_ENUM
LIFECYCLE_STATE_ENUM
LISTING_TYPE_ENUM

Attributes

agent_features[RW]

@return [OCI::Core::Models::InstanceAgentFeatures]

base_image_id[RW]

The OCID of the image originally used to launch the instance. @return [String]

billable_size_in_gbs[RW]

The size of the internal storage for this image that is subject to billing (1 GB = 1,073,741,824 bytes).

Example: `100`

@return [Integer]

compartment_id[RW]

[Required] The OCID of the compartment containing the instance you want to use as the basis for the image.

@return [String]

create_image_allowed[RW]

[Required] Whether instances launched with this image can be used to create new images. For example, you cannot create an image of an Oracle Database instance.

Example: `true`

@return [BOOLEAN]

defined_tags[RW]

Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).

Example: `{"Operations": {"CostCenter": "42"}}`

@return [Hash<String, Hash<String, Object>>]

display_name[RW]

A user-friendly name for the image. It does not have to be unique, and it's changeable. Avoid entering confidential information.

You cannot use a platform image name as a custom image name.

Example: `My custom Oracle Linux image`

@return [String]

freeform_tags[RW]

Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm).

Example: `{"Department": "Finance"}`

@return [Hash<String, String>]

id[RW]

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

launch_mode[R]

Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are:

  • `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for platform images.

  • `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller.

  • `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using VirtIO drivers.

  • `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter.

@return [String]

launch_options[RW]

@return [OCI::Core::Models::LaunchOptions]

lifecycle_state[R]

This attribute is required. @return [String]

listing_type[R]

The listing type of the image. The default value is "NONE". @return [String]

operating_system[RW]

[Required] The image's operating system.

Example: `Oracle Linux`

@return [String]

operating_system_version[RW]

[Required] The image's operating system version.

Example: `7.2`

@return [String]

size_in_mbs[RW]

The boot volume size for an instance launched from this image (1 MB = 1,048,576 bytes). Note this is not the same as the size of the image when it was exported or the actual size of the image.

Example: `47694`

@return [Integer]

time_created[RW]

[Required] The date and time the image was created, in the format defined by [RFC3339](tools.ietf.org/html/rfc3339).

Example: `2016-08-25T21:10:29.600Z`

@return [DateTime]

Public Class Methods

attribute_map() click to toggle source

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

# File lib/oci/core/models/image.rb, line 151
def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'base_image_id': :'baseImageId',
    'compartment_id': :'compartmentId',
    'create_image_allowed': :'createImageAllowed',
    'defined_tags': :'definedTags',
    'display_name': :'displayName',
    'freeform_tags': :'freeformTags',
    'id': :'id',
    'launch_mode': :'launchMode',
    'launch_options': :'launchOptions',
    'lifecycle_state': :'lifecycleState',
    'operating_system': :'operatingSystem',
    'operating_system_version': :'operatingSystemVersion',
    'agent_features': :'agentFeatures',
    'listing_type': :'listingType',
    'size_in_mbs': :'sizeInMBs',
    'billable_size_in_gbs': :'billableSizeInGBs',
    'time_created': :'timeCreated'
    # 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] :base_image_id The value to assign to the {#base_image_id} property @option attributes [String] :compartment_id The value to assign to the {#compartment_id} property @option attributes [BOOLEAN] :create_image_allowed The value to assign to the {#create_image_allowed} property @option attributes [Hash<String, Hash<String, Object>>] :defined_tags The value to assign to the {#defined_tags} property @option attributes [String] :display_name The value to assign to the {#display_name} property @option attributes [Hash<String, String>] :freeform_tags The value to assign to the {#freeform_tags} property @option attributes [String] :id The value to assign to the {#id} property @option attributes [String] :launch_mode The value to assign to the {#launch_mode} property @option attributes [OCI::Core::Models::LaunchOptions] :launch_options The value to assign to the {#launch_options} property @option attributes [String] :lifecycle_state The value to assign to the {#lifecycle_state} property @option attributes [String] :operating_system The value to assign to the {#operating_system} property @option attributes [String] :operating_system_version The value to assign to the {#operating_system_version} property @option attributes [OCI::Core::Models::InstanceAgentFeatures] :agent_features The value to assign to the {#agent_features} property @option attributes [String] :listing_type The value to assign to the {#listing_type} property @option attributes [Integer] :size_in_mbs The value to assign to the {#size_in_mbs} property @option attributes [Integer] :billable_size_in_gbs The value to assign to the {#billable_size_in_gbs} property @option attributes [DateTime] :time_created The value to assign to the {#time_created} property

# File lib/oci/core/models/image.rb, line 223
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.base_image_id = attributes[:'baseImageId'] if attributes[:'baseImageId']

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

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

  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.create_image_allowed = attributes[:'createImageAllowed'] unless attributes[:'createImageAllowed'].nil?

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

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

  self.defined_tags = attributes[:'definedTags'] if attributes[:'definedTags']

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

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

  self.display_name = attributes[:'displayName'] if attributes[:'displayName']

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

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

  self.freeform_tags = attributes[:'freeformTags'] if attributes[:'freeformTags']

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

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

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

  self.launch_mode = attributes[:'launchMode'] if attributes[:'launchMode']

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

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

  self.launch_options = attributes[:'launchOptions'] if attributes[:'launchOptions']

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

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

  self.lifecycle_state = attributes[:'lifecycleState'] if attributes[:'lifecycleState']

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

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

  self.operating_system = attributes[:'operatingSystem'] if attributes[:'operatingSystem']

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

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

  self.operating_system_version = attributes[:'operatingSystemVersion'] if attributes[:'operatingSystemVersion']

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

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

  self.agent_features = attributes[:'agentFeatures'] if attributes[:'agentFeatures']

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

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

  self.listing_type = attributes[:'listingType'] if attributes[:'listingType']

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

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

  self.size_in_mbs = attributes[:'sizeInMBs'] if attributes[:'sizeInMBs']

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

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

  self.billable_size_in_gbs = attributes[:'billableSizeInGBs'] if attributes[:'billableSizeInGBs']

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

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

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

Attribute type mapping.

# File lib/oci/core/models/image.rb, line 176
def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'base_image_id': :'String',
    'compartment_id': :'String',
    'create_image_allowed': :'BOOLEAN',
    'defined_tags': :'Hash<String, Hash<String, Object>>',
    'display_name': :'String',
    'freeform_tags': :'Hash<String, String>',
    'id': :'String',
    'launch_mode': :'String',
    'launch_options': :'OCI::Core::Models::LaunchOptions',
    'lifecycle_state': :'String',
    'operating_system': :'String',
    'operating_system_version': :'String',
    'agent_features': :'OCI::Core::Models::InstanceAgentFeatures',
    'listing_type': :'String',
    'size_in_mbs': :'Integer',
    'billable_size_in_gbs': :'Integer',
    'time_created': :'DateTime'
    # 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/core/models/image.rb, line 374
def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    base_image_id == other.base_image_id &&
    compartment_id == other.compartment_id &&
    create_image_allowed == other.create_image_allowed &&
    defined_tags == other.defined_tags &&
    display_name == other.display_name &&
    freeform_tags == other.freeform_tags &&
    id == other.id &&
    launch_mode == other.launch_mode &&
    launch_options == other.launch_options &&
    lifecycle_state == other.lifecycle_state &&
    operating_system == other.operating_system &&
    operating_system_version == other.operating_system_version &&
    agent_features == other.agent_features &&
    listing_type == other.listing_type &&
    size_in_mbs == other.size_in_mbs &&
    billable_size_in_gbs == other.billable_size_in_gbs &&
    time_created == other.time_created
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/core/models/image.rb, line 420
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/core/models/image.rb, line 400
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/core/models/image.rb, line 409
def hash
  [base_image_id, compartment_id, create_image_allowed, defined_tags, display_name, freeform_tags, id, launch_mode, launch_options, lifecycle_state, operating_system, operating_system_version, agent_features, listing_type, size_in_mbs, billable_size_in_gbs, time_created].hash
end
launch_mode=(launch_mode) click to toggle source

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

# File lib/oci/core/models/image.rb, line 332
def launch_mode=(launch_mode)
  # rubocop:disable Style/ConditionalAssignment
  if launch_mode && !LAUNCH_MODE_ENUM.include?(launch_mode)
    OCI.logger.debug("Unknown value for 'launch_mode' [" + launch_mode + "]. Mapping to 'LAUNCH_MODE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @launch_mode = LAUNCH_MODE_UNKNOWN_ENUM_VALUE
  else
    @launch_mode = launch_mode
  end
  # rubocop:enable Style/ConditionalAssignment
end
lifecycle_state=(lifecycle_state) click to toggle source

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

# File lib/oci/core/models/image.rb, line 345
def lifecycle_state=(lifecycle_state)
  # rubocop:disable Style/ConditionalAssignment
  if lifecycle_state && !LIFECYCLE_STATE_ENUM.include?(lifecycle_state)
    OCI.logger.debug("Unknown value for 'lifecycle_state' [" + lifecycle_state + "]. Mapping to 'LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @lifecycle_state = LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE
  else
    @lifecycle_state = lifecycle_state
  end
  # rubocop:enable Style/ConditionalAssignment
end
listing_type=(listing_type) click to toggle source

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

# File lib/oci/core/models/image.rb, line 358
def listing_type=(listing_type)
  # rubocop:disable Style/ConditionalAssignment
  if listing_type && !LISTING_TYPE_ENUM.include?(listing_type)
    OCI.logger.debug("Unknown value for 'listing_type' [" + listing_type + "]. Mapping to 'LISTING_TYPE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @listing_type = LISTING_TYPE_UNKNOWN_ENUM_VALUE
  else
    @listing_type = listing_type
  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/core/models/image.rb, line 453
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/core/models/image.rb, line 447
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/core/models/image.rb, line 470
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