// 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 UpdateSecretExample
    {
        public static async Task Main()
        {
            // Create a request and dependent object(s).
			var updateSecretDetails = new Oci.VaultService.Models.UpdateSecretDetails
			{
				CurrentVersionNumber = 231,
				DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
				{
					{
						"EXAMPLE_KEY_qyL3S", 
						new Dictionary<string, Object>()
						{
							{
								"EXAMPLE_KEY_Ov8Vo", 
								"EXAMPLE--Value"
							}
						}
					}
				},
				Description = "EXAMPLE-description-Value",
				FreeformTags = new Dictionary<string, string>()
				{
					{
						"EXAMPLE_KEY_De2Ku", 
						"EXAMPLE_VALUE_EAkQfjaepir1RYcOmqT8"
					}
				},
				Metadata = new Dictionary<string, Object>()
				{
					{
						"EXAMPLE_KEY_Utw87", 
						"EXAMPLE--Value"
					}
				},
				SecretContent = new Oci.VaultService.Models.Base64SecretContentDetails
				{
					Content = "EXAMPLE-content-Value",
					Name = "EXAMPLE-name-Value",
					Stage = Oci.VaultService.Models.SecretContentDetails.StageEnum.Current
				},
				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.AdbTargetSystemDetails
					{
						AdbId = "ocid1.test.oc1..<unique_ID>EXAMPLE-adbId-Value"
					},
					IsScheduledRotationEnabled = true
				},
				SecretRules = new List<Oci.VaultService.Models.SecretRule>
				{
					new Oci.VaultService.Models.SecretReuseRule
					{
						IsEnforcedOnDeletedSecretVersions = true
					}
				},
				SecretGenerationContext = new Oci.VaultService.Models.SshKeyGenerationContext
				{
					GenerationTemplate = Oci.VaultService.Models.SshKeyGenerationContext.GenerationTemplateEnum.Rsa3072,
					SecretTemplate = "EXAMPLE-secretTemplate-Value"
				},
				EnableAutoGeneration = false
			};
			var updateSecretRequest = new Oci.VaultService.Requests.UpdateSecretRequest
			{
				SecretId = "ocid1.test.oc1..<unique_ID>EXAMPLE-secretId-Value",
				UpdateSecretDetails = updateSecretDetails,
				IfMatch = "EXAMPLE-ifMatch-Value",
				OpcRequestId = "5SA1NFKWPUWWSV4GUMXO<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 VaultsClient(provider, new ClientConfiguration()))
				{
					var response = await client.UpdateSecret(updateSecretRequest);
					// Retrieve value from the response.
					var id = response.Secret.Id;
				}
            }
            catch (Exception e)
            {
                Console.WriteLine($"UpdateSecret Failed with {e.Message}");
                throw e;
            }
        }

    }
}