// 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_OWeob": "EXAMPLE--Value"},
IsAIEnterpriseEnabled: common.Bool(true),
SecurityAttributes: map[string]map[string]interface{}{"EXAMPLE_KEY_n4m5i": map[string]interface{}{"EXAMPLE_KEY_XNxWN": "EXAMPLE--Value"}},
Shape: common.String("EXAMPLE-shape-Value"),
DedicatedVmHostId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value"),
FaultDomain: common.String("EXAMPLE-faultDomain-Value"),
LaunchOptions: &core.UpdateLaunchOptions{BootVolumeType: core.UpdateLaunchOptionsBootVolumeTypeParavirtualized,
IsPvEncryptionInTransitEnabled: common.Bool(true),
NetworkType: core.UpdateLaunchOptionsNetworkTypeVfio},
LicensingConfigs: []core.UpdateInstanceLicensingConfig{core.UpdateInstanceWindowsLicensingConfig{LicenseType: core.UpdateInstanceLicensingConfigLicenseTypeBringYourOwnLicense}},
SourceDetails: core.UpdateInstanceSourceViaImageDetails{KmsKeyId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value"),
BootVolumeSizeInGBs: common.Int64(884),
ImageId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value"),
IsPreserveBootVolumeEnabled: common.Bool(false)},
TimeMaintenanceRebootDue: &common.SDKTime{Time: time.Now()},
FreeformTags: map[string]string{"EXAMPLE_KEY_BJhAp": "EXAMPLE_VALUE_h1cdcVjh0SS4MtImKt8v"},
InstanceOptions: &core.InstanceOptions{AreLegacyImdsEndpointsDisabled: common.Bool(false)},
Metadata: map[string]string{"EXAMPLE_KEY_UNZqr": "EXAMPLE_VALUE_V90XYZ4As2SFAuv05Otj"},
AgentConfig: &core.UpdateInstanceAgentConfigDetails{AreAllPluginsDisabled: common.Bool(true),
IsManagementDisabled: common.Bool(true),
IsMonitoringDisabled: common.Bool(false),
PluginsConfig: []core.InstanceAgentPluginConfigDetails{core.InstanceAgentPluginConfigDetails{DesiredState: core.InstanceAgentPluginConfigDetailsDesiredStateEnabled,
Name: common.String("EXAMPLE-name-Value")}}},
CapacityReservationId: common.String("ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value"),
PlatformConfig: core.AmdVmUpdateInstancePlatformConfig{IsSymmetricMultiThreadingEnabled: common.Bool(true)},
ShapeConfig: &core.UpdateInstanceShapeConfigDetails{Nvmes: common.Int(2),
Ocpus: common.Float32(2606.2488),
ResourceManagement: core.UpdateInstanceShapeConfigDetailsResourceManagementDynamic,
Vcpus: common.Int(575),
BaselineOcpuUtilization: core.UpdateInstanceShapeConfigDetailsBaselineOcpuUtilization1,
MemoryInGBs: common.Float32(619.67017)},
UpdateOperationConstraint: core.UpdateInstanceDetailsUpdateOperationConstraintAvoidDowntime,
AvailabilityConfig: &core.UpdateInstanceAvailabilityConfigDetails{IsLiveMigrationPreferred: common.Bool(false),
RecoveryAction: core.UpdateInstanceAvailabilityConfigDetailsRecoveryActionStopInstance},
DefinedTags: map[string]map[string]interface{}{"EXAMPLE_KEY_nhKW4": map[string]interface{}{"EXAMPLE_KEY_N0fX4": "EXAMPLE--Value"}},
DisplayName: common.String("EXAMPLE-displayName-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)
}