// 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 = 709,
MasterNodeHostType = Oci.OpensearchService.Models.MasterNodeHostType.Flex,
MasterNodeHostBareMetalShape = "EXAMPLE-masterNodeHostBareMetalShape-Value",
MasterNodeHostShape = "EXAMPLE-masterNodeHostShape-Value",
MasterNodeHostOcpuCount = 524,
MasterNodeHostMemoryGB = 38330,
DataNodeCount = 381,
DataNodeHostType = Oci.OpensearchService.Models.DataNodeHostType.Bm,
DataNodeHostBareMetalShape = "EXAMPLE-dataNodeHostBareMetalShape-Value",
DataNodeHostShape = "EXAMPLE-dataNodeHostShape-Value",
DataNodeHostOcpuCount = 1518,
DataNodeHostMemoryGB = 78756,
DataNodeStorageGB = 21069,
OpendashboardNodeHostShape = "EXAMPLE-opendashboardNodeHostShape-Value",
OpendashboardNodeCount = 627,
OpendashboardNodeHostOcpuCount = 1020,
OpendashboardNodeHostMemoryGB = 7838,
SearchNodeCount = 8,
SearchNodeHostType = Oci.OpensearchService.Models.SearchNodeHostType.Flex,
SearchNodeHostShape = "EXAMPLE-searchNodeHostShape-Value",
SearchNodeHostOcpuCount = 9229,
SearchNodeHostMemoryGB = 70732,
SearchNodeStorageGB = 2085,
MlNodeCount = 230,
MlNodeHostType = Oci.OpensearchService.Models.MlNodeHostType.Flex,
MlNodeHostShape = "EXAMPLE-mlNodeHostShape-Value",
MlNodeHostOcpuCount = 2032,
MlNodeHostMemoryGB = 27770,
MlNodeStorageGB = 43873,
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 = false,
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 = 38,
FrequencyInHours = 465
},
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 = 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"
}
},
LoadBalancerConfig = new Oci.OpensearchService.Models.LoadBalancerConfig
{
LoadBalancerServiceType = Oci.OpensearchService.Models.LoadBalancerConfig.LoadBalancerServiceTypeEnum.LoadBalancer,
LoadBalancerMinBandwidthInMbps = 3428,
LoadBalancerMaxBandwidthInMbps = 4197
},
CertificateConfig = new Oci.OpensearchService.Models.CertificateConfig
{
ClusterCertificateMode = Oci.OpensearchService.Models.CertificateMode.OciCertificatesService,
DashboardCertificateMode = Oci.OpensearchService.Models.CertificateMode.OpensearchService,
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_4E9rR",
"EXAMPLE_VALUE_gDN7OEJ0JDAPq9IkSaId"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_G4Cuo",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_HKuCL",
"EXAMPLE--Value"
}
}
}
},
SystemTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_SojxN",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_9Gwtm",
"EXAMPLE--Value"
}
}
}
},
SecurityAttributes = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_H7qAG",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_IQ2bx",
"EXAMPLE--Value"
}
}
}
}
};
var createOpensearchClusterRequest = new Oci.OpensearchService.Requests.CreateOpensearchClusterRequest
{
CreateOpensearchClusterDetails = createOpensearchClusterDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "9UHUE7IH0YSGF0QSASL6<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;
}
}
}
}