// 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{ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_sMlqk": "EXAMPLE--Value"},
LaunchOptions: &core.UpdateLaunchOptions{NetworkType: core.UpdateLaunchOptionsNetworkTypeParavirtualized,
BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi,
IsPvEncryptionInTransitEnabled: common.Bool(false)},
FreeformTags: map[string]string{"EXAMPLE_KEY_0XBNz": "EXAMPLE_VALUE_f2AMbZV1bVFoHsVyeWk2"},
DisplayName: common.String("EXAMPLE-displayName-Value"),
Metadata: map[string]string{"EXAMPLE_KEY_qIRKB": "EXAMPLE_VALUE_TX6bVzOd2Lix84TEOsKC"},
PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(false)},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_dS179": map[string]interface{}{"EXAMPLE_KEY_w3Xop": "EXAMPLE--Value"}},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
Shape: common.String("EXAMPLE-shape-Value"),
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization1,
MemoryInGBs: common.Float32(6556.356),
Nvmes: common.Int(4),
Ocpus: common.Float32(1560.1063),
Vcpus: common.Int(448)},
SourceDetails: core.UpdateInstanceSourceViaImageDetails{BootVolumeSizeInGBs: common.Int64(62),
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")},
AgentConfig: &core.UpdateInstanceAgentConfigDetails{PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{Name: common.String("EXAMPLE-name-Value"),
DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateEnabled}},
AreAllPluginsDisabled: common.Bool(true),
IsManagementDisabled: common.Bool(false),
IsMonitoringDisabled: common.Bool(false)},
AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(false),
RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionStopInstance},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAvoidDowntime}}
// 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)
}