// 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 PrevalidateShardedDatabaseExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var prevalidateShardedDatabaseDetails = new Oci.GloballydistributeddatabaseService.Models.PrevalidateShardedDatabaseDetails
			{
				PrevalidateShardedDatabaseDetailsProp = new Oci.GloballydistributeddatabaseService.Models.PrevalidateCreatePayload
				{
					PrevalidatePayload = new Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase
					{
						ReplicationMethod = Oci.GloballydistributeddatabaseService.Models.DedicatedShardedDatabase.ReplicationMethodEnum.Dg,
						ReplicationFactor = 5,
						ReplicationUnit = 757,
						ClusterCertificateCommonName = "EXAMPLE-clusterCertificateCommonName-Value",
						Chunks = 420,
						DbWorkload = Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase.DbWorkloadEnum.Oltp,
						ShardingMethod = Oci.GloballydistributeddatabaseService.Models.CreateDedicatedShardedDatabase.ShardingMethodEnum.System,
						DbVersion = "EXAMPLE-dbVersion-Value",
						CharacterSet = "EXAMPLE-characterSet-Value",
						NcharacterSet = "EXAMPLE-ncharacterSet-Value",
						ListenerPort = 64723,
						ListenerPortTls = 63986,
						OnsPortLocal = 57924,
						OnsPortRemote = 34223,
						Prefix = "tce",
						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)4214.8203,
								DataStorageSizeInGbs = 5826.9487,
								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)7120.924,
								DataStorageSizeInGbs = 5345.5957,
								IsAutoScalingEnabled = true,
								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_34I7z", 
								"EXAMPLE_VALUE_ZLGv53yU0J8ZhSDaDD5c"
							}
						},
						DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
						{
							{
								"EXAMPLE_KEY_sOTpA", 
								new Dictionary<string, Object>()
								{
									{
										"EXAMPLE_KEY_nvmr2", 
										"EXAMPLE--Value"
									}
								}
							}
						}
					}
				}
			};
			var prevalidateShardedDatabaseRequest = new Oci.GloballydistributeddatabaseService.Requests.PrevalidateShardedDatabaseRequest
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				PrevalidateShardedDatabaseDetails = prevalidateShardedDatabaseDetails,
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
				OpcRequestId = "GCXRDXDPD2VXYJRPUDSG<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.PrevalidateShardedDatabase(prevalidateShardedDatabaseRequest);
					// Retrieve value from the response.
					var validationResultValue = response.PrevalidateShardedDatabaseResult.ValidationResult;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"PrevalidateShardedDatabase Failed with {e.Message}");
                throw e;
            }
        }

    }
}

Was this article helpful?