# 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).

import oci
from datetime import datetime

# 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.config.from_file()


# Initialize service client with default config file
core_client = oci.core.ComputeClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
update_instance_response = core_client.update_instance(
    instance_id="ocid1.test.oc1..<unique_ID>EXAMPLE-instanceId-Value",
    update_instance_details=oci.core.models.UpdateInstanceDetails(
        capacity_reservation_id="ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
        defined_tags={
            'EXAMPLE_KEY_7c9co': {
                'EXAMPLE_KEY_VzqZZ': 'EXAMPLE--Value'}},
        security_attributes={
            'EXAMPLE_KEY_rr9j6': {
                'EXAMPLE_KEY_DuG5k': 'EXAMPLE--Value'}},
        display_name="EXAMPLE-displayName-Value",
        freeform_tags={
            'EXAMPLE_KEY_Xl9zQ': 'EXAMPLE_VALUE_qGB8E83JqA2Os9CHpAtk'},
        agent_config=oci.core.models.UpdateInstanceAgentConfigDetails(
            is_monitoring_disabled=True,
            is_management_disabled=False,
            are_all_plugins_disabled=False,
            plugins_config=[
                oci.core.models.InstanceAgentPluginConfigDetails(
                    name="EXAMPLE-name-Value",
                    desired_state="DISABLED")]),
        metadata={
            'EXAMPLE_KEY_DMEmZ': 'EXAMPLE_VALUE_gJjOMzajkcKe9mFcn78K'},
        extended_metadata={
            'EXAMPLE_KEY_IId9f': 'EXAMPLE--Value'},
        shape="EXAMPLE-shape-Value",
        shape_config=oci.core.models.UpdateInstanceShapeConfigDetails(
            ocpus=3241.7822,
            vcpus=533,
            memory_in_gbs=5760.464,
            baseline_ocpu_utilization="BASELINE_1_8",
            nvmes=3),
        source_details=oci.core.models.UpdateInstanceSourceViaImageDetails(
            source_type="image",
            image_id="ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
            is_preserve_boot_volume_enabled=True,
            boot_volume_size_in_gbs=643,
            kms_key_id="ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
        update_operation_constraint="AVOID_DOWNTIME",
        instance_options=oci.core.models.InstanceOptions(
            are_legacy_imds_endpoints_disabled=True),
        fault_domain="EXAMPLE-faultDomain-Value",
        launch_options=oci.core.models.UpdateLaunchOptions(
            boot_volume_type="ISCSI",
            network_type="PARAVIRTUALIZED",
            is_pv_encryption_in_transit_enabled=True),
        availability_config=oci.core.models.UpdateInstanceAvailabilityConfigDetails(
            is_live_migration_preferred=True,
            recovery_action="STOP_INSTANCE"),
        time_maintenance_reboot_due=datetime.strptime(
            "2018-12-28T16:37:22.829Z",
            "%Y-%m-%dT%H:%M:%S.%fZ"),
        dedicated_vm_host_id="ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
        platform_config=oci.core.models.IntelVmUpdateInstancePlatformConfig(
            type="INTEL_VM",
            is_symmetric_multi_threading_enabled=True),
        licensing_configs=[
            oci.core.models.UpdateInstanceWindowsLicensingConfig(
                type="WINDOWS",
                license_type="OCI_PROVIDED")]),
    opc_retry_token="EXAMPLE-opcRetryToken-Value",
    if_match="EXAMPLE-ifMatch-Value")

# Get the data from response
print(update_instance_response.data)

Was this article helpful?