// 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
			{
				CapacityReservationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_BiAxQ", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_I5wC9", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_WjZ9x", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_pWCT9", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				DisplayName = "EXAMPLE-displayName-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_NqVEK", 
						"EXAMPLE_VALUE_O1PObvfZf3sDzxScLSC8"
					}
				},
				AgentConfig = new Oci.CoreService.Models.UpdateInstanceAgentConfigDetails
				{
					IsMonitoringDisabled = true,
					IsManagementDisabled = true,
					AreAllPluginsDisabled = false,
					PluginsConfig = new List<Oci.CoreService.Models.InstanceAgentPluginConfigDetails>
					{
						new Oci.CoreService.Models.InstanceAgentPluginConfigDetails
						{
							Name = "EXAMPLE-name-Value",
							DesiredState = Oci.CoreService.Models.InstanceAgentPluginConfigDetails.DesiredStateEnum.Disabled
						}
					}
				},
				Metadata = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_tisT8", 
						"EXAMPLE_VALUE_nW7BGbkZzmBj9QuVsfJM"
					}
				},
				ExtendedMetadata = new Dictionary<string, Object>()
				{
					{
						"EXAMPLE_KEY_vlDjJ", 
						"EXAMPLE--Value"
					}
				},
				Shape = "EXAMPLE-shape-Value",
				ShapeConfig = new Oci.CoreService.Models.UpdateInstanceShapeConfigDetails
				{
					Ocpus = (float)8540.275,
					Vcpus = 610,
					MemoryInGBs = (float)3456.3584,
					BaselineOcpuUtilization = Oci.CoreService.Models.UpdateInstanceShapeConfigDetails.BaselineOcpuUtilizationEnum.Baseline18,
					Nvmes = 5
				},
				SourceDetails = new Oci.CoreService.Models.UpdateInstanceSourceViaBootVolumeDetails
				{
					BootVolumeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value",
					IsPreserveBootVolumeEnabled = true
				},
				UpdateOperationConstraint = Oci.CoreService.Models.UpdateInstanceDetails.UpdateOperationConstraintEnum.AllowDowntime,
				InstanceOptions = new Oci.CoreService.Models.InstanceOptions
				{
					AreLegacyImdsEndpointsDisabled = true
				},
				FaultDomain = "EXAMPLE-faultDomain-Value",
				LaunchOptions = new Oci.CoreService.Models.UpdateLaunchOptions
				{
					BootVolumeType = Oci.CoreService.Models.UpdateLaunchOptions.BootVolumeTypeEnum.Iscsi,
					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("06/11/2047 03:54:02"),
				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.BringYourOwnLicense
					}
				}
			};
			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;
            }
        }

    }
}

Was this article helpful?