// 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 CreateClusterNetworkExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createClusterNetworkDetails = new Oci.CoreService.Models.CreateClusterNetworkDetails
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_widxW", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_BHQjX", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				DisplayName = "EXAMPLE-displayName-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_g7SOZ", 
						"EXAMPLE_VALUE_4AhQL8c4rAXwGGPm2PHC"
					}
				},
				InstancePools = new List<Oci.CoreService.Models.CreateClusterNetworkInstancePoolDetails>
				{
					new Oci.CoreService.Models.CreateClusterNetworkInstancePoolDetails
					{
						DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
						{
							{
								"EXAMPLE_KEY_iEWaw", 
								new Dictionary<string, Object>()
								{
									{
										"EXAMPLE_KEY_FR9mX", 
										"EXAMPLE--Value"
									}
								}
							}
						},
						DisplayName = "EXAMPLE-displayName-Value",
						FreeformTags = new Dictionary<string, string>()
						{
							{
								"EXAMPLE_KEY_hgIGJ", 
								"EXAMPLE_VALUE_NSIMH9PvvtcEvRxI94Bt"
							}
						},
						InstanceConfigurationId = "ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value",
						Size = 134
					}
				},
				PlacementConfiguration = new Oci.CoreService.Models.ClusterNetworkPlacementConfigurationDetails
				{
					AvailabilityDomain = "EXAMPLE-availabilityDomain-Value",
					PlacementConstraint = Oci.CoreService.Models.ClusterNetworkPlacementConfigurationDetails.PlacementConstraintEnum.SingleTier,
					PrimarySubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-primarySubnetId-Value",
					PrimaryVnicSubnets = new Oci.CoreService.Models.InstancePoolPlacementPrimarySubnet
					{
						IsAssignIpv6Ip = true,
						Ipv6AddressIpv6SubnetCidrPairDetails = new List<Oci.CoreService.Models.InstancePoolPlacementIpv6AddressIpv6SubnetCidrDetails>
						{
							new Oci.CoreService.Models.InstancePoolPlacementIpv6AddressIpv6SubnetCidrDetails
							{
								Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value"
							}
						},
						SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
					},
					SecondaryVnicSubnets = new List<Oci.CoreService.Models.InstancePoolPlacementSecondaryVnicSubnet>
					{
						new Oci.CoreService.Models.InstancePoolPlacementSecondaryVnicSubnet
						{
							DisplayName = "EXAMPLE-displayName-Value",
							IsAssignIpv6Ip = true,
							Ipv6AddressIpv6SubnetCidrPairDetails = new List<Oci.CoreService.Models.InstancePoolPlacementIpv6AddressIpv6SubnetCidrDetails>
							{
								new Oci.CoreService.Models.InstancePoolPlacementIpv6AddressIpv6SubnetCidrDetails
								{
									Ipv6SubnetCidr = "EXAMPLE-ipv6SubnetCidr-Value"
								}
							},
							SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value"
						}
					}
				},
				ClusterConfiguration = new Oci.CoreService.Models.ClusterConfigurationDetails
				{
					NetworkBlockIds = new List<string>
					{
						"EXAMPLE--Value"
					},
					HpcIslandId = "ocid1.test.oc1..<unique_ID>EXAMPLE-hpcIslandId-Value"
				}
			};
			var createClusterNetworkRequest = new Oci.CoreService.Requests.CreateClusterNetworkRequest
			{
				CreateClusterNetworkDetails = createClusterNetworkDetails,
				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 ComputeManagementClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateClusterNetwork(createClusterNetworkRequest);
					// Retrieve value from the response.
					var id = response.ClusterNetwork.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateClusterNetwork Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?