// 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.CloudmigrationsService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Cloudmigrations
{
public class CreateTargetAssetExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createTargetAssetDetails = new Oci.CloudmigrationsService.Models.CreateVmTargetAssetDetails
{
PreferredShapeType = Oci.CloudmigrationsService.Models.VmTargetAsset.PreferredShapeTypeEnum.Vm,
BlockVolumesPerformance = 997,
MsLicense = "EXAMPLE-msLicense-Value",
UserSpec = new Oci.CloudmigrationsService.Models.LaunchInstanceDetails
{
AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
CapacityReservationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
CreateVnicDetails = new Oci.CloudmigrationsService.Models.CreateVnicDetails
{
AssignPublicIp = true,
AssignPrivateDnsRecord = true,
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_ylHGR",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_KO2s0",
"EXAMPLE--Value"
}
}
}
},
DisplayName = "EXAMPLE-displayName-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_fMyFF",
"EXAMPLE_VALUE_yb4bWn1JF3UZPYfHqYiL"
}
},
HostnameLabel = "EXAMPLE-hostnameLabel-Value",
NsgIds = new List<string>
{
"EXAMPLE--Value"
},
PrivateIp = "EXAMPLE-privateIp-Value",
SkipSourceDestCheck = true,
SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
VlanId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value"
},
DedicatedVmHostId = "ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_rYEWe",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_KG5Bp",
"EXAMPLE--Value"
}
}
}
},
DisplayName = "EXAMPLE-displayName-Value",
FaultDomain = "EXAMPLE-faultDomain-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_gti78",
"EXAMPLE_VALUE_Y4fNNlpvlS0TIwRj858z"
}
},
HostnameLabel = "EXAMPLE-hostnameLabel-Value",
IpxeScript = "EXAMPLE-ipxeScript-Value",
InstanceOptions = new Oci.CloudmigrationsService.Models.InstanceOptions
{
AreLegacyImdsEndpointsDisabled = true
},
PreemptibleInstanceConfig = new Oci.CloudmigrationsService.Models.PreemptibleInstanceConfigDetails
{
PreemptionAction = new Oci.CloudmigrationsService.Models.TerminatePreemptionAction
{
PreserveBootVolume = true
}
},
AgentConfig = new Oci.CloudmigrationsService.Models.LaunchInstanceAgentConfigDetails
{
IsMonitoringDisabled = true,
IsManagementDisabled = true,
AreAllPluginsDisabled = true,
PluginsConfig = new List<Oci.CloudmigrationsService.Models.InstanceAgentPluginConfigDetails>
{
new Oci.CloudmigrationsService.Models.InstanceAgentPluginConfigDetails
{
Name = "EXAMPLE-name-Value",
DesiredState = Oci.CloudmigrationsService.Models.InstanceAgentPluginConfigDetails.DesiredStateEnum.Disabled
}
}
},
Shape = "EXAMPLE-shape-Value",
ShapeConfig = new Oci.CloudmigrationsService.Models.LaunchInstanceShapeConfigDetails
{
Ocpus = (float)8021.059,
MemoryInGBs = (float)4108.882,
BaselineOcpuUtilization = Oci.CloudmigrationsService.Models.LaunchInstanceShapeConfigDetails.BaselineOcpuUtilizationEnum.Baseline18
},
SourceDetails = new Oci.CloudmigrationsService.Models.InstanceSourceViaBootVolumeDetails
{
BootVolumeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-bootVolumeId-Value"
},
IsPvEncryptionInTransitEnabled = false
},
MigrationPlanId = "ocid1.test.oc1..<unique_ID>EXAMPLE-migrationPlanId-Value",
IsExcludedFromExecution = true
};
var createTargetAssetRequest = new Oci.CloudmigrationsService.Requests.CreateTargetAssetRequest
{
CreateTargetAssetDetails = createTargetAssetDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "RUPKNH8OKG3LLILH9ADL<unique_ID>"
};
// 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 MigrationClient(provider, new ClientConfiguration()))
{
var response = await client.CreateTargetAsset(createTargetAssetRequest);
// Retrieve value from the response.
var id = response.TargetAsset.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateTargetAsset Failed with {e.Message}");
throw e;
}
}
}
}