# 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 '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
launch_instance_response =
  core_client.launch_instance(
    OCI::Core::Models::LaunchInstanceDetails.new(
      availability_domain: 'EXAMPLE-availabilityDomain-Value',
      compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
      shape: 'EXAMPLE-shape-Value',
      capacity_reservation_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value',
      create_vnic_details:
        OCI::Core::Models::CreateVnicDetails.new(
          assign_public_ip: false,
          assign_private_dns_record: true,
          defined_tags: {
            'EXAMPLE_KEY_hQGHn' => { 'EXAMPLE_KEY_TmZv2' => 'EXAMPLE--Value' }
          },
          display_name: 'EXAMPLE-displayName-Value',
          freeform_tags: {
            'EXAMPLE_KEY_dMC4Z' => 'EXAMPLE_VALUE_uyvgFdn7tLW5FjcoFlPJ'
          },
          hostname_label: 'EXAMPLE-hostnameLabel-Value',
          nsg_ids: %w[EXAMPLE--Value],
          private_ip: 'EXAMPLE-privateIp-Value',
          skip_source_dest_check: true,
          subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
          vlan_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value'
        ),
      dedicated_vm_host_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value',
      defined_tags: {
        'EXAMPLE_KEY_a3PgL' => { 'EXAMPLE_KEY_By7vd' => 'EXAMPLE--Value' }
      },
      display_name: 'EXAMPLE-displayName-Value',
      extended_metadata: { 'EXAMPLE_KEY_NwFqT' => 'EXAMPLE--Value' },
      fault_domain: 'EXAMPLE-faultDomain-Value',
      freeform_tags: {
        'EXAMPLE_KEY_iRPvE' => 'EXAMPLE_VALUE_lGXbmWzENbE2MRdpaYEp'
      },
      hostname_label: 'EXAMPLE-hostnameLabel-Value',
      image_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value',
      ipxe_script: 'EXAMPLE-ipxeScript-Value',
      launch_options:
        OCI::Core::Models::LaunchOptions.new(
          boot_volume_type: 'IDE',
          firmware: 'BIOS',
          network_type: 'PARAVIRTUALIZED',
          remote_data_volume_type: 'PARAVIRTUALIZED',
          is_pv_encryption_in_transit_enabled: true,
          is_consistent_volume_naming_enabled: true
        ),
      instance_options:
        OCI::Core::Models::InstanceOptions.new(
          are_legacy_imds_endpoints_disabled: false
        ),
      availability_config:
        OCI::Core::Models::LaunchInstanceAvailabilityConfigDetails.new(
          is_live_migration_preferred: true, recovery_action: 'RESTORE_INSTANCE'
        ),
      preemptible_instance_config:
        OCI::Core::Models::PreemptibleInstanceConfigDetails.new(
          preemption_action:
            OCI::Core::Models::TerminatePreemptionAction.new(
              type: 'TERMINATE', preserve_boot_volume: false
            )
        ),
      metadata: { 'EXAMPLE_KEY_sHepv' => 'EXAMPLE_VALUE_xdettmOKTK98BDx12z3d' },
      agent_config:
        OCI::Core::Models::LaunchInstanceAgentConfigDetails.new(
          is_monitoring_disabled: true,
          is_management_disabled: true,
          are_all_plugins_disabled: false,
          plugins_config: [
            OCI::Core::Models::InstanceAgentPluginConfigDetails.new(
              name: 'EXAMPLE-name-Value', desired_state: 'DISABLED'
            )
          ]
        ),
      shape_config:
        OCI::Core::Models::LaunchInstanceShapeConfigDetails.new(
          ocpus: 6194.495,
          memory_in_gbs: 519.9045,
          baseline_ocpu_utilization: 'BASELINE_1_1',
          nvmes: 587
        ),
      source_details:
        OCI::Core::Models::InstanceSourceViaImageDetails.new(
          source_type: 'image',
          image_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value',
          boot_volume_size_in_gbs: 836,
          kms_key_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value',
          boot_volume_vpus_per_gb: 745
        ),
      subnet_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value',
      is_pv_encryption_in_transit_enabled: true,
      platform_config:
        OCI::Core::Models::AmdVmLaunchInstancePlatformConfig.new(
          type: 'AMD_VM',
          is_secure_boot_enabled: true,
          is_trusted_platform_module_enabled: true,
          is_measured_boot_enabled: true
        )
    )
  )

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