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

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/oracle/oci-go-sdk/v65/common"
	"github.com/oracle/oci-go-sdk/v65/core"
	"github.com/oracle/oci-go-sdk/v65/example/helpers"
)

func ExampleUpdateInstance() {
	// Create a default authentication provider that uses the DEFAULT
	// profile in the configuration file.
	// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
	client, err := core.NewComputeClientWithConfigurationProvider(common.DefaultConfigProvider())
	helpers.FatalIfError(err)

	// Create a request and dependent object(s).

	req := core.UpdateInstanceRequest{IfMatch: common.String("EXAMPLE-ifMatch-Value"),
		InstanceId:    common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-instanceId-Value"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-Value"),
		UpdateInstanceDetails: core.UpdateInstanceDetails{AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(false),
			RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionRestoreInstance},
			DisplayName:      common.String("EXAMPLE-displayName-Value"),
			LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeOciProvided}},
			ShapeConfig: &core.UpdateInstanceShapeConfigDetails{Nvmes: common.Int(1),
				Ocpus:                   common.Float32(1820.5135),
				ResourceManagement:      core.UpdateInstanceShapeConfigDetailsResourceManagementDynamic,
				Vcpus:                   common.Int(859),
				BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization8,
				MemoryInGBs:             common.Float32(4275.7646)},
			UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAvoidDowntime,
			LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeParavirtualized,
				IsPvEncryptionInTransitEnabled: common.Bool(false),
				NetworkType:                    core.UpdateLaunchOptionsNetworkTypeVfio},
			DedicatedVmHostId:        common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
			ExtendedMetadata:         map[string]interface{}{"EXAMPLE_KEY_JUhkc": "EXAMPLE--Value"},
			FaultDomain:              common.String("EXAMPLE-faultDomain-Value"),
			Shape:                    common.String("EXAMPLE-shape-Value"),
			TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
			CapacityReservationId:    common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
			Metadata:                 map[string]string{"EXAMPLE_KEY_uWqwZ": "EXAMPLE_VALUE_rHvqzQvvOlBKc4g8CttB"},
			PlatformConfig:           core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
			SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"),
				IsPreserveBootVolumeEnabled: common.Bool(true)},
			AgentConfig: &core.UpdateInstanceAgentConfigDetails{PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{Name: common.String("EXAMPLE-name-Value"),
				DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateDisabled}},
				AreAllPluginsDisabled: common.Bool(true),
				IsManagementDisabled:  common.Bool(false),
				IsMonitoringDisabled:  common.Bool(true)},
			DefinedTags:           map[string]map[string]interface{}{"EXAMPLE_KEY_vrj5Z": map[string]interface{}{"EXAMPLE_KEY_kQz7F": "EXAMPLE--Value"}},
			FreeformTags:          map[string]string{"EXAMPLE_KEY_trB56": "EXAMPLE_VALUE_dE279qqg0tgaflWNJh3h"},
			InstanceOptions:       &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
			IsAIEnterpriseEnabled: common.Bool(false),
			SecurityAttributes:    map[string]map[string]interface{}{"EXAMPLE_KEY_tKr3c": map[string]interface{}{"EXAMPLE_KEY_CrLZE": "EXAMPLE--Value"}}}}

	// Send the request using the service client
	resp, err := client.UpdateInstance(context.Background(), req)
	helpers.FatalIfError(err)

	// Retrieve value from the response.
	fmt.Println(resp)
}