// 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 CreateIPSecConnectionExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createIPSecConnectionDetails = new Oci.CoreService.Models.CreateIPSecConnectionDetails
{
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
CpeId = "ocid1.test.oc1..<unique_ID>EXAMPLE-cpeId-Value",
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_b9i8z",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_6trYX",
"EXAMPLE--Value"
}
}
}
},
DisplayName = "EXAMPLE-displayName-Value",
DrgId = "ocid1.test.oc1..<unique_ID>EXAMPLE-drgId-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_XADoo",
"EXAMPLE_VALUE_TfDjv2q0SSWID3jSG3bY"
}
},
CpeLocalIdentifier = "EXAMPLE-cpeLocalIdentifier-Value",
CpeLocalIdentifierType = Oci.CoreService.Models.CreateIPSecConnectionDetails.CpeLocalIdentifierTypeEnum.Hostname,
StaticRoutes = new List<string>
{
"EXAMPLE--Value"
},
TunnelConfiguration = new List<Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails>
{
new Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails
{
DisplayName = "EXAMPLE-displayName-Value",
Routing = Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails.RoutingEnum.Policy,
IkeVersion = Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails.IkeVersionEnum.V2,
SharedSecret = "EXAMPLE-sharedSecret-Value",
BgpSessionConfig = new Oci.CoreService.Models.CreateIPSecTunnelBgpSessionDetails
{
OracleInterfaceIp = "EXAMPLE-oracleInterfaceIp-Value",
CustomerInterfaceIp = "EXAMPLE-customerInterfaceIp-Value",
OracleInterfaceIpv6 = "EXAMPLE-oracleInterfaceIpv6-Value",
CustomerInterfaceIpv6 = "EXAMPLE-customerInterfaceIpv6-Value",
CustomerBgpAsn = "EXAMPLE-customerBgpAsn-Value"
},
OracleInitiation = Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails.OracleInitiationEnum.ResponderOnly,
NatTranslationEnabled = Oci.CoreService.Models.CreateIPSecConnectionTunnelDetails.NatTranslationEnabledEnum.Auto,
PhaseOneConfig = new Oci.CoreService.Models.PhaseOneConfigDetails
{
IsCustomPhaseOneConfig = true,
AuthenticationAlgorithm = Oci.CoreService.Models.PhaseOneConfigDetails.AuthenticationAlgorithmEnum.Sha2384,
EncryptionAlgorithm = Oci.CoreService.Models.PhaseOneConfigDetails.EncryptionAlgorithmEnum.Aes256Cbc,
DiffieHelmanGroup = Oci.CoreService.Models.PhaseOneConfigDetails.DiffieHelmanGroupEnum.Group20,
LifetimeInSeconds = 164
},
PhaseTwoConfig = new Oci.CoreService.Models.PhaseTwoConfigDetails
{
IsCustomPhaseTwoConfig = true,
AuthenticationAlgorithm = Oci.CoreService.Models.PhaseTwoConfigDetails.AuthenticationAlgorithmEnum.HmacSha1128,
EncryptionAlgorithm = Oci.CoreService.Models.PhaseTwoConfigDetails.EncryptionAlgorithmEnum.Aes256Cbc,
LifetimeInSeconds = 892,
IsPfsEnabled = true,
PfsDhGroup = Oci.CoreService.Models.PhaseTwoConfigDetails.PfsDhGroupEnum.Group14
},
DpdConfig = new Oci.CoreService.Models.DpdConfig
{
DpdMode = Oci.CoreService.Models.DpdConfig.DpdModeEnum.InitiateAndRespond,
DpdTimeoutInSec = 456
},
OracleTunnelIp = "EXAMPLE-oracleTunnelIp-Value",
AssociatedVirtualCircuits = new List<string>
{
"EXAMPLE--Value"
},
DrgRouteTableId = "ocid1.test.oc1..<unique_ID>EXAMPLE-drgRouteTableId-Value",
EncryptionDomainConfig = new Oci.CoreService.Models.CreateIPSecTunnelEncryptionDomainDetails
{
OracleTrafficSelector = new List<string>
{
"EXAMPLE--Value"
},
CpeTrafficSelector = new List<string>
{
"EXAMPLE--Value"
}
}
}
}
};
var createIPSecConnectionRequest = new Oci.CoreService.Requests.CreateIPSecConnectionRequest
{
CreateIPSecConnectionDetails = createIPSecConnectionDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-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 VirtualNetworkClient(provider, new ClientConfiguration()))
{
var response = await client.CreateIPSecConnection(createIPSecConnectionRequest);
// Retrieve value from the response.
var id = response.IPSecConnection.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateIPSecConnection Failed with {e.Message}");
throw e;
}
}
}
}