// 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.OpensearchService;
using Oci.Common;
using Oci.Common.Auth;

namespace Oci.Sdk.DotNet.Example.Opensearch
{
    public class CreateOpensearchClusterExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createOpensearchClusterDetails = new Oci.OpensearchService.Models.CreateOpensearchClusterDetails
			{
				DisplayName = "EXAMPLE-displayName-Value",
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				SoftwareVersion = "EXAMPLE-softwareVersion-Value",
				MasterNodeCount = 770,
				MasterNodeHostType = Oci.OpensearchService.Models.MasterNodeHostType.Flex,
				MasterNodeHostBareMetalShape = "EXAMPLE-masterNodeHostBareMetalShape-Value",
				MasterNodeHostShape = "EXAMPLE-masterNodeHostShape-Value",
				MasterNodeHostOcpuCount = 3375,
				MasterNodeHostMemoryGB = 42797,
				DataNodeCount = 292,
				DataNodeHostType = Oci.OpensearchService.Models.DataNodeHostType.Bm,
				DataNodeHostBareMetalShape = "EXAMPLE-dataNodeHostBareMetalShape-Value",
				DataNodeHostShape = "EXAMPLE-dataNodeHostShape-Value",
				DataNodeHostOcpuCount = 7979,
				DataNodeHostMemoryGB = 87473,
				DataNodeStorageGB = 71463,
				OpendashboardNodeHostShape = "EXAMPLE-opendashboardNodeHostShape-Value",
				OpendashboardNodeCount = 712,
				OpendashboardNodeHostOcpuCount = 2222,
				OpendashboardNodeHostMemoryGB = 7003,
				SearchNodeCount = 869,
				SearchNodeHostType = Oci.OpensearchService.Models.SearchNodeHostType.Flex,
				SearchNodeHostShape = "EXAMPLE-searchNodeHostShape-Value",
				SearchNodeHostOcpuCount = 3664,
				SearchNodeHostMemoryGB = 55878,
				SearchNodeStorageGB = 95130,
				VcnId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vcnId-Value",
				SubnetId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
				VcnCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vcnCompartmentId-Value",
				SubnetCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-subnetCompartmentId-Value",
				SecurityMode = Oci.OpensearchService.Models.SecurityMode.Enforcing,
				SecurityMasterUserName = "EXAMPLE-securityMasterUserName-Value",
				SecurityMasterUserPasswordHash = "EXAMPLE-securityMasterUserPasswordHash-Value",
				SecuritySamlConfig = new Oci.OpensearchService.Models.SecuritySamlConfig
				{
					IsEnabled = true,
					IdpMetadataContent = "EXAMPLE-idpMetadataContent-Value",
					IdpEntityId = "ocid1.test.oc1..<unique_ID>EXAMPLE-idpEntityId-Value",
					OpendashboardUrl = "EXAMPLE-opendashboardUrl-Value",
					AdminBackendRole = "EXAMPLE-adminBackendRole-Value",
					SubjectKey = "EXAMPLE-subjectKey-Value",
					RolesKey = "EXAMPLE-rolesKey-Value"
				},
				BackupPolicy = new Oci.OpensearchService.Models.BackupPolicy
				{
					IsEnabled = true,
					RetentionInDays = 694,
					FrequencyInHours = 996
				},
				ReverseConnectionEndpointCustomerIps = new List<string>
				{
					"EXAMPLE--Value"
				},
				InboundClusterIds = new List<string>
				{
					"EXAMPLE--Value"
				},
				OutboundClusterConfig = new Oci.OpensearchService.Models.OutboundClusterConfig
				{
					IsEnabled = true,
					OutboundClusters = new List<Oci.OpensearchService.Models.OutboundClusterSummary>
					{
						new Oci.OpensearchService.Models.OutboundClusterSummary
						{
							DisplayName = "EXAMPLE-displayName-Value",
							PingSchedule = "EXAMPLE-pingSchedule-Value",
							IsSkipUnavailable = true,
							SeedClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-seedClusterId-Value",
							Mode = Oci.OpensearchService.Models.CccMode.SearchAndReplication
						}
					}
				},
				MaintenanceDetails = new Oci.OpensearchService.Models.CreateMaintenanceDetails
				{
					NotificationEmailIds = new List<string>
					{
						"EXAMPLE--Value"
					}
				},
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_G8fEX", 
						"EXAMPLE_VALUE_J0tMKhUJIvak2odtU0Rw"
					}
				},
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_FrrlZ", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_puZjj", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				SystemTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_6DDwx", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_CphPQ", 
								"EXAMPLE--Value"
							}
						}
					}
				}
			};
			var createOpensearchClusterRequest = new Oci.OpensearchService.Requests.CreateOpensearchClusterRequest
			{
				CreateOpensearchClusterDetails = createOpensearchClusterDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "GGEN8EGPLNCIBMPKW2MF<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 OpensearchClusterClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateOpensearchCluster(createOpensearchClusterRequest);
					// Retrieve value from the response.
					var versionValue = response.httpResponseMessage.Version;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateOpensearchCluster Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?