// 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.DisasterrecoveryService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Disasterrecovery
{
public class CreateDrProtectionGroupExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createDrProtectionGroupDetails = new Oci.DisasterrecoveryService.Models.CreateDrProtectionGroupDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
DisplayName = "EXAMPLE-displayName-Value",
LogLocation = new Oci.DisasterrecoveryService.Models.CreateObjectStorageLogLocationDetails
{
Namespace = "EXAMPLE-namespace-Value",
Bucket = "EXAMPLE-bucket-Value"
},
Association = new Oci.DisasterrecoveryService.Models.AssociateDrProtectionGroupDetails
{
PeerId = "ocid1.test.oc1..<unique_ID>EXAMPLE-peerId-Value",
PeerRegion = "EXAMPLE-peerRegion-Value",
Role = Oci.DisasterrecoveryService.Models.DrProtectionGroupRole.Unconfigured
},
Members = new List<Oci.DisasterrecoveryService.Models.CreateDrProtectionGroupMemberDetails>
{
new Oci.DisasterrecoveryService.Models.CreateDrProtectionGroupMemberComputeInstanceDetails
{
IsMovable = false,
VnicMapping = new List<Oci.DisasterrecoveryService.Models.ComputeInstanceVnicMappingDetails>
{
new Oci.DisasterrecoveryService.Models.ComputeInstanceVnicMappingDetails
{
SourceVnicId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sourceVnicId-Value",
DestinationSubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-destinationSubnetId-Value",
DestinationPrimaryPrivateIpAddress = "EXAMPLE-destinationPrimaryPrivateIpAddress-Value",
DestinationPrimaryPrivateIpHostnameLabel = "EXAMPLE-destinationPrimaryPrivateIpHostnameLabel-Value",
DestinationNsgIdList = new List<string>
{
"EXAMPLE--Value"
}
}
},
DestinationCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-destinationCompartmentId-Value",
DestinationDedicatedVmHostId = "ocid1.test.oc1..<unique_ID>EXAMPLE-destinationDedicatedVmHostId-Value",
MemberId = "ocid1.test.oc1..<unique_ID>EXAMPLE-memberId-Value"
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_fTNH8",
"EXAMPLE_VALUE_lOhdfTLzmqrzps3KihCP"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_uF3Sz",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_yL6jv",
"EXAMPLE--Value"
}
}
}
}
};
var createDrProtectionGroupRequest = new Oci.DisasterrecoveryService.Requests.CreateDrProtectionGroupRequest
{
CreateDrProtectionGroupDetails = createDrProtectionGroupDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "2ISSJAXD6CFH7RQTR0IG<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 DisasterRecoveryClient(provider, new ClientConfiguration()))
{
var response = await client.CreateDrProtectionGroup(createDrProtectionGroupRequest);
// Retrieve value from the response.
var id = response.DrProtectionGroup.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateDrProtectionGroup Failed with {e.Message}");
throw e;
}
}
}
}