// 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{UpdateInstanceDetails: core.UpdateInstanceDetails{InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(true)},
		IsAIEnterpriseEnabled: common.Bool(true),
		SourceDetails: core.UpdateInstanceSourceViaImageDetails{BootVolumeSizeInGBs: common.Int64(110),
			ImageId:                     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value"),
			IsPreserveBootVolumeEnabled: common.Bool(false),
			KmsKeyId:                    common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value")},
		AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionStopInstance,
			IsLiveMigrationPreferred: common.Bool(false)},
		DefinedTags:      map[string]map[string]interface{}{"EXAMPLE_KEY_gTztj": map[string]interface{}{"EXAMPLE_KEY_w4cTk": "EXAMPLE--Value"}},
		ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_Aw4LM": "EXAMPLE--Value"},
		FreeformTags:     map[string]string{"EXAMPLE_KEY_OJ9aG": "EXAMPLE_VALUE_xIcjhqeCIN8LxCvSsS4w"},
		LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi,
			IsPvEncryptionInTransitEnabled: common.Bool(false),
			NetworkType:                    core.UpdateLaunchOptionsNetworkTypeParavirtualized},
		LicensingConfigs:          []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypePartnerProvided}},
		Metadata:                  map[string]string{"EXAMPLE_KEY_6Ajl7": "EXAMPLE_VALUE_bhh4MpYkpsoEXccCHrBH"},
		UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAllowDowntime,
		AgentConfig: &core.UpdateInstanceAgentConfigDetails{PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateEnabled,
			Name: common.String("EXAMPLE-name-Value")}},
			AreAllPluginsDisabled: common.Bool(true),
			IsManagementDisabled:  common.Bool(false),
			IsMonitoringDisabled:  common.Bool(true)},
		PlatformConfig:     core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
		SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_hp7FG": map[string]interface{}{"EXAMPLE_KEY_CV5QS": "EXAMPLE--Value"}},
		ShapeConfig: &core.UpdateInstanceShapeConfigDetails{Ocpus: common.Float32(7996.542),
			ResourceManagement:      core.UpdateInstanceShapeConfigDetailsResourceManagementStatic,
			Vcpus:                   common.Int(581),
			BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization2,
			LocalVolumeSizeInGBs:    common.Int(10677),
			MemoryInGBs:             common.Float32(3549.8245),
			Nvmes:                   common.Int(3)},
		DedicatedVmHostId:        common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
		Shape:                    common.String("EXAMPLE-shape-Value"),
		TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
		CapacityReservationId:    common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
		DisplayName:              common.String("EXAMPLE-displayName-Value"),
		FaultDomain:              common.String("EXAMPLE-faultDomain-Value")},
		IfMatch:       common.String("EXAMPLE-ifMatch-Value"),
		InstanceId:    common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-instanceId-Value"),
		OpcRetryToken: common.String("EXAMPLE-opcRetryToken-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)
}