// 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.GloballydistributeddatabaseService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Globallydistributeddatabase
{
public class CreateShardedDatabaseExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createShardedDatabaseDetails = new Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase
{
ReplicationMethod = Oci.GloballydistributeddatabaseService.Models.DedicatedShardedDatabase.ReplicationMethodEnum.Dg,
ReplicationFactor = 3,
ReplicationUnit = 762,
ClusterCertificateCommonName = "EXAMPLE-clusterCertificateCommonName-Value",
Chunks = 630,
DbWorkload = Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase.DbWorkloadEnum.Dw,
ShardingMethod = Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase.ShardingMethodEnum.User,
DbVersion = "EXAMPLE-dbVersion-Value",
CharacterSet = "EXAMPLE-characterSet-Value",
NcharacterSet = "EXAMPLE-ncharacterSet-Value",
ListenerPort = 59350,
ListenerPortTls = 22060,
OnsPortLocal = 35180,
OnsPortRemote = 11633,
Prefix = "rcr",
ShardDetails = new List<Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardDetail>
{
new Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardDetail
{
EncryptionKeyDetails = new Oci.GloballydistributeddatabaseService.Models.DedicatedShardOrCatalogEncryptionKeyDetails
{
VaultId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vaultId-Value",
KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
KmsKeyVersionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyVersionId-Value"
},
AdminPassword = "EXAMPLE-adminPassword-Value",
ComputeCount = (float)6221.103,
DataStorageSizeInGbs = 1787.9521,
ShardSpace = "EXAMPLE-shardSpace-Value",
IsAutoScalingEnabled = true,
CloudAutonomousVmClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-cloudAutonomousVmClusterId-Value",
PeerCloudAutonomousVmClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-peerCloudAutonomousVmClusterId-Value"
}
},
CatalogDetails = new List<Oci.GloballydistributeddatabaseService.Models.CreateDedicatedCatalogDetail>
{
new Oci.GloballydistributeddatabaseService.Models.CreateDedicatedCatalogDetail
{
EncryptionKeyDetails = new Oci.GloballydistributeddatabaseService.Models.DedicatedShardOrCatalogEncryptionKeyDetails
{
VaultId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vaultId-Value",
KmsKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
KmsKeyVersionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyVersionId-Value"
},
AdminPassword = "EXAMPLE-adminPassword-Value",
ComputeCount = (float)9013.374,
DataStorageSizeInGbs = 5584.3633,
IsAutoScalingEnabled = false,
CloudAutonomousVmClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-cloudAutonomousVmClusterId-Value",
PeerCloudAutonomousVmClusterId = "ocid1.test.oc1..<unique_ID>EXAMPLE-peerCloudAutonomousVmClusterId-Value"
}
},
CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
DisplayName = "EXAMPLE-displayName-Value",
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_FuSAh",
"EXAMPLE_VALUE_s605Ndse6p8VzTZxwf0Z"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_ghc0r",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_b3sRf",
"EXAMPLE--Value"
}
}
}
}
};
var createShardedDatabaseRequest = new Oci.GloballydistributeddatabaseService.Requests.CreateShardedDatabaseRequest
{
CreateShardedDatabaseDetails = createShardedDatabaseDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "9Q8CXYDTGBNHLV6PPD8A<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 ShardedDatabaseServiceClient(provider, new ClientConfiguration()))
{
var response = await client.CreateShardedDatabase(createShardedDatabaseRequest);
// Retrieve value from the response.
var id = response.ShardedDatabase.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateShardedDatabase Failed with {e.Message}");
throw e;
}
}
}
}