# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

require 'date'
require 'oci'

# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config

# Initialize service client with default config file
core_client = OCI::Core::ComputeClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
update_instance_response =
  core_client.update_instance(
    'ocid1.test.oc1..<unique_ID>EXAMPLE-instanceId-Value',
    OCI::Core::Models::UpdateInstanceDetails.new(
      capacity_reservation_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value',
      defined_tags: {
        'EXAMPLE_KEY_ForV7' => { 'EXAMPLE_KEY_xwLj7' => 'EXAMPLE--Value' }
      },
      security_attributes: {
        'EXAMPLE_KEY_YdUYB' => { 'EXAMPLE_KEY_z3IOH' => 'EXAMPLE--Value' }
      },
      display_name: 'EXAMPLE-displayName-Value',
      freeform_tags: {
        'EXAMPLE_KEY_Zuwdb' => 'EXAMPLE_VALUE_23pk24cuqlndrf2tEU0Y'
      },
      agent_config:
        OCI::Core::Models::UpdateInstanceAgentConfigDetails.new(
          is_monitoring_disabled: false,
          is_management_disabled: true,
          are_all_plugins_disabled: false,
          plugins_config: [
            OCI::Core::Models::InstanceAgentPluginConfigDetails.new(
              name: 'EXAMPLE-name-Value', desired_state: 'DISABLED'
            )
          ]
        ),
      metadata: { 'EXAMPLE_KEY_NlvpE' => 'EXAMPLE_VALUE_l0rqj6XQdOgoZVwXvvv6' },
      extended_metadata: { 'EXAMPLE_KEY_af37G' => 'EXAMPLE--Value' },
      shape: 'EXAMPLE-shape-Value',
      shape_config:
        OCI::Core::Models::UpdateInstanceShapeConfigDetails.new(
          ocpus: 7275.0986,
          vcpus: 586,
          memory_in_gbs: 161.12209,
          baseline_ocpu_utilization: 'BASELINE_1_2',
          nvmes: 1
        ),
      source_details:
        OCI::Core::Models::UpdateInstanceSourceViaBootVolumeDetails.new(
          source_type: 'bootVolume',
          boot_volume_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value',
          is_preserve_boot_volume_enabled: true
        ),
      update_operation_constraint: 'AVOID_DOWNTIME',
      instance_options:
        OCI::Core::Models::InstanceOptions.new(
          are_legacy_imds_endpoints_disabled: true
        ),
      fault_domain: 'EXAMPLE-faultDomain-Value',
      launch_options:
        OCI::Core::Models::UpdateLaunchOptions.new(
          boot_volume_type: 'PARAVIRTUALIZED',
          network_type: 'PARAVIRTUALIZED',
          is_pv_encryption_in_transit_enabled: false
        ),
      availability_config:
        OCI::Core::Models::UpdateInstanceAvailabilityConfigDetails.new(
          is_live_migration_preferred: true, recovery_action: 'RESTORE_INSTANCE'
        ),
      time_maintenance_reboot_due: DateTime.parse('2034-09-13T21:03:14.543Z'),
      dedicated_vm_host_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value',
      platform_config:
        OCI::Core::Models::AmdVmUpdateInstancePlatformConfig.new(
          type: 'AMD_VM', is_symmetric_multi_threading_enabled: true
        ),
      licensing_configs: [
        OCI::Core::Models::UpdateInstanceWindowsLicensingConfig.new(
          type: 'WINDOWS', license_type: 'OCI_PROVIDED'
        )
      ]
    )
  )

# Get the data from response
puts "#{update_instance_response.data}"

Was this article helpful?