// 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 = 169,
MasterNodeHostType = Oci.OpensearchService.Models.MasterNodeHostType.Bm,
MasterNodeHostBareMetalShape = "EXAMPLE-masterNodeHostBareMetalShape-Value",
MasterNodeHostShape = "EXAMPLE-masterNodeHostShape-Value",
MasterNodeHostOcpuCount = 3694,
MasterNodeHostMemoryGB = 24666,
DataNodeCount = 46,
DataNodeHostType = Oci.OpensearchService.Models.DataNodeHostType.Flex,
DataNodeHostBareMetalShape = "EXAMPLE-dataNodeHostBareMetalShape-Value",
DataNodeHostShape = "EXAMPLE-dataNodeHostShape-Value",
DataNodeHostOcpuCount = 1637,
DataNodeHostMemoryGB = 19627,
DataNodeStorageGB = 30624,
OpendashboardNodeHostShape = "EXAMPLE-opendashboardNodeHostShape-Value",
OpendashboardNodeCount = 241,
OpendashboardNodeHostOcpuCount = 5162,
OpendashboardNodeHostMemoryGB = 6829,
SearchNodeCount = 811,
SearchNodeHostType = Oci.OpensearchService.Models.SearchNodeHostType.Flex,
SearchNodeHostShape = "EXAMPLE-searchNodeHostShape-Value",
SearchNodeHostOcpuCount = 241,
SearchNodeHostMemoryGB = 28538,
SearchNodeStorageGB = 79059,
MlNodeCount = 114,
MlNodeHostType = Oci.OpensearchService.Models.MlNodeHostType.Flex,
MlNodeHostShape = "EXAMPLE-mlNodeHostShape-Value",
MlNodeHostOcpuCount = 9041,
MlNodeHostMemoryGB = 32022,
MlNodeStorageGB = 28421,
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.Permissive,
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 = false,
RetentionInDays = 472,
FrequencyInHours = 795
},
NsgId = "ocid1.test.oc1..<unique_ID>EXAMPLE-nsgId-Value",
ReverseConnectionEndpointCustomerIps = new List<string>
{
"EXAMPLE--Value"
},
InboundClusterIds = new List<string>
{
"EXAMPLE--Value"
},
OutboundClusterConfig = new Oci.OpensearchService.Models.OutboundClusterConfig
{
IsEnabled = false,
OutboundClusters = new List<Oci.OpensearchService.Models.OutboundClusterSummary>
{
new Oci.OpensearchService.Models.OutboundClusterSummary
{
DisplayName = "EXAMPLE-displayName-Value",
PingSchedule = "EXAMPLE-pingSchedule-Value",
IsSkipUnavailable = false,
SeedClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-seedClusterId-Value",
Mode = Oci.OpensearchService.Models.CccMode.ReplicationOnly
}
}
},
MaintenanceDetails = new Oci.OpensearchService.Models.CreateMaintenanceDetails
{
NotificationEmailIds = new List<string>
{
"EXAMPLE--Value"
}
},
LoadBalancerConfig = new Oci.OpensearchService.Models.LoadBalancerConfig
{
LoadBalancerServiceType = Oci.OpensearchService.Models.LoadBalancerConfig.LoadBalancerServiceTypeEnum.LoadBalancer,
LoadBalancerMinBandwidthInMbps = 2178,
LoadBalancerMaxBandwidthInMbps = 5674
},
CertificateConfig = new Oci.OpensearchService.Models.CertificateConfig
{
ClusterCertificateMode = Oci.OpensearchService.Models.CertificateMode.OpensearchService,
DashboardCertificateMode = Oci.OpensearchService.Models.CertificateMode.OciCertificatesService,
OpenSearchApiCertificateId = "ocid1.test.oc1..<unique_ID>EXAMPLE-openSearchApiCertificateId-Value",
OpenSearchDashboardCertificateId = "ocid1.test.oc1..<unique_ID>EXAMPLE-openSearchDashboardCertificateId-Value"
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_97PEK",
"EXAMPLE_VALUE_uwRhXgkLfiYvWgj7gjaA"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_fs8Oo",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_cu9NA",
"EXAMPLE--Value"
}
}
}
},
SystemTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_fI98A",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_xO962",
"EXAMPLE--Value"
}
}
}
},
SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_N7jr4",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_ul17u",
"EXAMPLE--Value"
}
}
}
}
};
var createOpensearchClusterRequest = new Oci.OpensearchService.Requests.CreateOpensearchClusterRequest
{
CreateOpensearchClusterDetails = createOpensearchClusterDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "MOYFRU6O9JK5RHLQGACQ<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;
}
}
}
}