// 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{IsAIEnterpriseEnabled: common.Bool(true),
Metadata: map[string]string{"EXAMPLE_KEY_sdVlV": "EXAMPLE_VALUE_Tq8abmzTQpocMiBaH7Sm"},
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeOciProvided}},
Shape: common.String("EXAMPLE-shape-Value"),
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{Vcpus: common.Int(998),
BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization1,
MemoryInGBs: common.Float32(6012.6865),
Nvmes: common.Int(4),
Ocpus: common.Float32(2989.4114),
ResourceManagement: core.UpdateInstanceShapeConfigDetailsResourceManagementStatic},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_K1I8d": "EXAMPLE--Value"},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_QDLWY": map[string]interface{}{"EXAMPLE_KEY_XMbyN": "EXAMPLE--Value"}},
SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"),
IsPreserveBootVolumeEnabled: common.Bool(false)},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAllowDowntime,
AgentConfig: &core.UpdateInstanceAgentConfigDetails{AreAllPluginsDisabled: common.Bool(true),
IsManagementDisabled: common.Bool(true),
IsMonitoringDisabled: common.Bool(true),
PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateDisabled,
Name: common.String("EXAMPLE-name-Value")}}},
LaunchOptions: &core.UpdateLaunchOptions{IsPvEncryptionInTransitEnabled: common.Bool(true),
NetworkType: core.UpdateLaunchOptionsNetworkTypeParavirtualized,
BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi},
PlatformConfig: core.IntelVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(true),
RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionStopInstance},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_hxScB": map[string]interface{}{"EXAMPLE_KEY_OKUC2": "EXAMPLE--Value"}},
FreeformTags: map[string]string{"EXAMPLE_KEY_iuiDL": "EXAMPLE_VALUE_fEBBaNZ6fwUfyf3ap5f4"},
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(true)}}}
// 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)
}