// 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{FreeformTags: map[string]string{"EXAMPLE_KEY_Z0XyM": "EXAMPLE_VALUE_VTR7jaqIk80skPzvB3w3"},
LaunchOptions: &core.UpdateLaunchOptions{NetworkType: core.UpdateLaunchOptionsNetworkTypeParavirtualized,
BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi,
IsPvEncryptionInTransitEnabled: common.Bool(true)},
LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeOciProvided}},
Metadata: map[string]string{"EXAMPLE_KEY_xerhv": "EXAMPLE_VALUE_zZq4BqsDLUzAbuAH2F8z"},
SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"),
IsPreserveBootVolumeEnabled: common.Bool(false)},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAvoidDowntime,
AgentConfig: &core.UpdateInstanceAgentConfigDetails{AreAllPluginsDisabled: common.Bool(false),
IsManagementDisabled: common.Bool(true),
IsMonitoringDisabled: common.Bool(true),
PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateEnabled,
Name: common.String("EXAMPLE-name-Value")}}},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_tH8Wv": map[string]interface{}{"EXAMPLE_KEY_yYBBI": "EXAMPLE--Value"}},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(false),
RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionRestoreInstance},
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(false)},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_b3kAP": map[string]interface{}{"EXAMPLE_KEY_0v8Ma": "EXAMPLE--Value"}},
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization2,
MemoryInGBs: common.Float32(1553.3251),
Nvmes: common.Int(4),
Ocpus: common.Float32(7111.166),
Vcpus: common.Int(994)},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_7SwHr": "EXAMPLE--Value"},
Shape: common.String("EXAMPLE-shape-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)
}