// 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{PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
			ShapeConfig: &core.UpdateInstanceShapeConfigDetails{BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization2,
				MemoryInGBs:        common.Float32(4423.283),
				Nvmes:              common.Int(2),
				Ocpus:              common.Float32(1138.9232),
				ResourceManagement: core.UpdateInstanceShapeConfigDetailsResourceManagementDynamic,
				Vcpus:              common.Int(213)},
			SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"),
				IsPreserveBootVolumeEnabled: common.Bool(false)},
			TimeMaintenanceRebootDue:  &common.SDKTime{Time: time.Now()},
			DefinedTags:               map[string]map[string]interface{}{"EXAMPLE_KEY_5zzTh": map[string]interface{}{"EXAMPLE_KEY_wpvag": "EXAMPLE--Value"}},
			ExtendedMetadata:          map[string]interface{}{"EXAMPLE_KEY_yauAn": "EXAMPLE--Value"},
			FreeformTags:              map[string]string{"EXAMPLE_KEY_0qpjY": "EXAMPLE_VALUE_YKmDT1QZsBDpdnxVcCii"},
			IsAIEnterpriseEnabled:     common.Bool(false),
			Shape:                     common.String("EXAMPLE-shape-Value"),
			UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAllowDowntime,
			CapacityReservationId:     common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
			InstanceOptions:           &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
			Metadata:                  map[string]string{"EXAMPLE_KEY_0nwUR": "EXAMPLE_VALUE_LOGw7c4bkWT5gzw8Rx6e"},
			AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(false),
				RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionRestoreInstance},
			DisplayName:        common.String("EXAMPLE-displayName-Value"),
			FaultDomain:        common.String("EXAMPLE-faultDomain-Value"),
			LicensingConfigs:   []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeOciProvided}},
			SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_Y110r": map[string]interface{}{"EXAMPLE_KEY_tPlkr": "EXAMPLE--Value"}},
			AgentConfig: &core.UpdateInstanceAgentConfigDetails{AreAllPluginsDisabled: common.Bool(false),
				IsManagementDisabled: common.Bool(false),
				IsMonitoringDisabled: common.Bool(false),
				PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateDisabled,
					Name: common.String("EXAMPLE-name-Value")}}},
			DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
			LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi,
				IsPvEncryptionInTransitEnabled: common.Bool(true),
				NetworkType:                    core.UpdateLaunchOptionsNetworkTypeParavirtualized}}}

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