// 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).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.CoreService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Core
{
public class UpdateInstanceExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var updateInstanceDetails = new Oci.CoreService.Models.UpdateInstanceDetails
{
IsAIEnterpriseEnabled = false,
CapacityReservationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_yWT13",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_kpYn3",
"EXAMPLE--Value"
}
}
}
},
SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_sak9D",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_9DL0e",
"EXAMPLE--Value"
}
}
}
},
DisplayName = "EXAMPLE-displayName-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_3ahCU",
"EXAMPLE_VALUE_mmjupYMHrCgVeKhMDln7"
}
},
AgentConfig = new Oci.CoreService.Models.UpdateInstanceAgentConfigDetails
{
IsMonitoringDisabled = false,
IsManagementDisabled = true,
AreAllPluginsDisabled = true,
PluginsConfig = new List<Oci.CoreService.Models.InstanceAgentPluginConfigDetails>
{
new Oci.CoreService.Models.InstanceAgentPluginConfigDetails
{
Name = "EXAMPLE-name-Value",
DesiredState = Oci.CoreService.Models.InstanceAgentPluginConfigDetails.DesiredStateEnum.Enabled
}
}
},
Metadata = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_EdH1W",
"EXAMPLE_VALUE_OjsrEHxrWalOyNIj6MMv"
}
},
ExtendedMetadata = new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_2Q9gC",
"EXAMPLE--Value"
}
},
Shape = "EXAMPLE-shape-Value",
ShapeConfig = new Oci.CoreService.Models.UpdateInstanceShapeConfigDetails
{
Ocpus = (float)6635.3887,
Vcpus = 648,
MemoryInGBs = (float)6379.6597,
BaselineOcpuUtilization = Oci.CoreService.Models.UpdateInstanceShapeConfigDetails.BaselineOcpuUtilizationEnum.Baseline18,
Nvmes = 2,
ResourceManagement = Oci.CoreService.Models.UpdateInstanceShapeConfigDetails.ResourceManagementEnum.Dynamic,
},
SourceDetails = new Oci.CoreService.Models.UpdateInstanceSourceViaImageDetails
{
BootVolumeSizeInGBs = 224,
ImageId = "ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
IsPreserveBootVolumeEnabled = true
},
UpdateOperationConstraint = Oci.CoreService.Models.UpdateInstanceDetails.UpdateOperationConstraintEnum.AvoidDowntime,
InstanceOptions = new Oci.CoreService.Models.InstanceOptions
{
AreLegacyImdsEndpointsDisabled = true
},
FaultDomain = "EXAMPLE-faultDomain-Value",
LaunchOptions = new Oci.CoreService.Models.UpdateLaunchOptions
{
BootVolumeType = Oci.CoreService.Models.UpdateLaunchOptions.BootVolumeTypeEnum.Paravirtualized,
NetworkType = Oci.CoreService.Models.UpdateLaunchOptions.NetworkTypeEnum.Vfio,
IsPvEncryptionInTransitEnabled = true
},
AvailabilityConfig = new Oci.CoreService.Models.UpdateInstanceAvailabilityConfigDetails
{
IsLiveMigrationPreferred = true,
RecoveryAction = Oci.CoreService.Models.UpdateInstanceAvailabilityConfigDetails.RecoveryActionEnum.RestoreInstance
},
TimeMaintenanceRebootDue = DateTime.Parse("07/22/2007 18:05:06"),
DedicatedVmHostId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
PlatformConfig = new Oci.CoreService.Models.AmdVmUpdateInstancePlatformConfig
{
IsSymmetricMultiThreadingEnabled = false
},
LicensingConfigs = new List<Oci.CoreService.Models.UpdateInstanceLicensingConfig>
{
new Oci.CoreService.Models.UpdateInstanceWindowsLicensingConfig
{
LicenseType = Oci.CoreService.Models.UpdateInstanceLicensingConfig.LicenseTypeEnum.OciProvided
}
}
};
var updateInstanceRequest = new Oci.CoreService.Requests.UpdateInstanceRequest
{
InstanceId = "ocid1.test.oc1..<unique_ID>EXAMPLE-instanceId-Value",
UpdateInstanceDetails = updateInstanceDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
IfMatch = "EXAMPLE-ifMatch-Value"
};
// 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.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new ComputeClient(provider, new ClientConfiguration()))
{
var response = await client.UpdateInstance(updateInstanceRequest);
// Retrieve value from the response.
var id = response.Instance.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"UpdateInstance Failed with {e.Message}");
throw e;
}
}
}
}