// 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{AgentConfig: &core.UpdateInstanceAgentConfigDetails{IsMonitoringDisabled: common.Bool(true),
PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateDisabled,
Name: common.String("EXAMPLE-name-Value")}},
AreAllPluginsDisabled: common.Bool(false),
IsManagementDisabled: common.Bool(true)},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
DisplayName: common.String("EXAMPLE-displayName-Value"),
LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeIscsi,
IsPvEncryptionInTransitEnabled: common.Bool(true),
NetworkType: core.UpdateLaunchOptionsNetworkTypeVfio},
Metadata: map[string]string{"EXAMPLE_KEY_tisT8": "EXAMPLE_VALUE_nW7BGbkZzmBj9QuVsfJM"},
PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(false)},
SourceDetails: core.UpdateInstanceSourceViaBootVolumeDetails{IsPreserveBootVolumeEnabled: common.Bool(true),
BootVolumeId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value")},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAllowDowntime,
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization8,
MemoryInGBs: common.Float32(3456.3584),
Nvmes: common.Int(5),
Ocpus: common.Float32(8540.275),
Vcpus: common.Int(610)},
AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(true),
RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionRestoreInstance},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_BiAxQ": map[string]interface{}{"EXAMPLE_KEY_I5wC9": "EXAMPLE--Value"}},
ExtendedMetadata: map[string]interface{}{"EXAMPLE_KEY_vlDjJ": "EXAMPLE--Value"},
FreeformTags: map[string]string{"EXAMPLE_KEY_NqVEK": "EXAMPLE_VALUE_O1PObvfZf3sDzxScLSC8"},
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(true)},
LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeBringYourOwnLicense}},
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_WjZ9x": map[string]interface{}{"EXAMPLE_KEY_pWCT9": "EXAMPLE--Value"}},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
FaultDomain: common.String("EXAMPLE-faultDomain-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)
}