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

namespace Oci.Sdk.DotNet.Example.Vault
{
    public class CreateSecretExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var createSecretDetails = new Oci.VaultService.Models.CreateSecretDetails
			{
				CompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_EjY25", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_2oBH9", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				Description = "EXAMPLE-description-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_3Kd8I", 
						"EXAMPLE_VALUE_fAyJCBtg2ysL4EB7NmP0"
					}
				},
				KeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-keyId-Value",
				Metadata = new Dictionary<string, Object>()
				{
					{
						"EXAMPLE_KEY_5tnuk", 
						"EXAMPLE--Value"
					}
				},
				SecretContent = new Oci.VaultService.Models.Base64SecretContentDetails
				{
					Content = "EXAMPLE-content-Value",
					Name = "EXAMPLE-name-Value",
					Stage = Oci.VaultService.Models.SecretContentDetails.StageEnum.Pending
				},
				ReplicationConfig = new Oci.VaultService.Models.ReplicationConfig
				{
					ReplicationTargets = new List<Oci.VaultService.Models.ReplicationTarget>
					{
						new Oci.VaultService.Models.ReplicationTarget
						{
							TargetKeyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-targetKeyId-Value",
							TargetRegion = "EXAMPLE-targetRegion-Value",
							TargetVaultId = "ocid1.test.oc1..<unique_ID>EXAMPLE-targetVaultId-Value"
						}
					},
					IsWriteForwardEnabled = true
				},
				RotationConfig = new Oci.VaultService.Models.RotationConfig
				{
					RotationInterval = "EXAMPLE-rotationInterval-Value",
					TargetSystemDetails = new Oci.VaultService.Models.FunctionTargetSystemDetails
					{
						FunctionId = "ocid1.test.oc1..<unique_ID>EXAMPLE-functionId-Value"
					},
					IsScheduledRotationEnabled = false
				},
				SecretName = "EXAMPLE-secretName-Value",
				SecretRules = new List<Oci.VaultService.Models.SecretRule>
				{
					new Oci.VaultService.Models.SecretExpiryRule
					{
						SecretVersionExpiryInterval = "EXAMPLE-secretVersionExpiryInterval-Value",
						TimeOfAbsoluteExpiry = DateTime.Parse("04/30/2017 07:51:22"),
						IsSecretContentRetrievalBlockedOnExpiry = true
					}
				},
				VaultId = "ocid1.test.oc1..<unique_ID>EXAMPLE-vaultId-Value",
				SecretGenerationContext = new Oci.VaultService.Models.SshKeyGenerationContext
				{
					GenerationTemplate = Oci.VaultService.Models.SshKeyGenerationContext.GenerationTemplateEnum.Rsa2048,
					SecretTemplate = "EXAMPLE-secretTemplate-Value"
				},
				EnableAutoGeneration = false
			};
			var createSecretRequest = new Oci.VaultService.Requests.CreateSecretRequest
			{
				CreateSecretDetails = createSecretDetails,
				OpcRequestId = "NEQ66KW6FFAE14OBY8DV<unique_ID>",
				OpcRetryToken = "EXAMPLE-opcRetryToken-Value"
			};

            // 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 VaultsClient(provider, new ClientConfiguration()))
				{
					var response = await client.CreateSecret(createSecretRequest);
					// Retrieve value from the response.
					var id = response.Secret.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"CreateSecret Failed with {e.Message}");
                throw e;
            }
        }

    }
}