// 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{AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionStopInstance,
IsLiveMigrationPreferred: common.Bool(true)},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_yBaAe": map[string]interface{}{"EXAMPLE_KEY_8h2lY": "EXAMPLE--Value"}},
ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_40a08": "EXAMPLE--Value"},
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(true)},
SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"),
IsPreserveBootVolumeEnabled: common.Bool(true)},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
FreeformTags: map[string]string{"EXAMPLE_KEY_MlEi6": "EXAMPLE_VALUE_JAJgL79kd44DlwJHNaFB"},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_SyjOj": map[string]interface{}{"EXAMPLE_KEY_XZ7ly": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-Value"),
LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeParavirtualized,
IsPvEncryptionInTransitEnabled: common.Bool(true),
NetworkType: core.UpdateLaunchOptionsNetworkTypeParavirtualized},
Metadata: map[string]string{"EXAMPLE_KEY_yTJW0": "EXAMPLE_VALUE_BxLtgAoj44p5HZ9rFFyk"},
PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAllowDowntime,
AgentConfig: &core.UpdateInstanceAgentConfigDetails{AreAllPluginsDisabled: common.Bool(false),
IsManagementDisabled: common.Bool(true),
IsMonitoringDisabled: common.Bool(false),
PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{Name: common.String("EXAMPLE-name-Value"),
DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateEnabled}}},
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeBringYourOwnLicense}},
Shape: common.String("EXAMPLE-shape-Value"),
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization2,
MemoryInGBs: common.Float32(9378.396),
Nvmes: common.Int(3),
Ocpus: common.Float32(9208.136),
Vcpus: common.Int(756)},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()}}}
// 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)
}