コード例 #1
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     client?.Dispose();
     client = new SecretsClient(AuthProvider, new Oci.Common.ClientConfiguration
     {
         RetryConfiguration = retryConfig,
         TimeoutMillis      = TimeOutInMillis,
         ClientUserAgent    = PSUserAgent
     });
     try
     {
         string region = GetPreferredRegion();
         if (region != null)
         {
             WriteDebug("Choosing Region:" + region);
             client.SetRegion(region);
         }
         if (Endpoint != null)
         {
             WriteDebug("Choosing Endpoint:" + Endpoint);
             client.SetEndpoint(Endpoint);
         }
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }
コード例 #2
0
        public static async Task <GetSecretBundleResponse> getSecretResponse(string vaultSecretOCID, string ociRegion)
        {
            var getSecretBundleRequest = new Oci.SecretsService.Requests.GetSecretBundleRequest
            {
                // SecretId = "ocid1.vaultsecret.oc1.iad.amaaaaaaq33dybya5qo2jtafngz7krbqdt64fygvm4v5ml7dnamg6ct7vaza"
                SecretId = vaultSecretOCID
            };
            var provider = new InstancePrincipalsAuthenticationDetailsProvider();

            try
            {
                using (var client = new SecretsClient(provider, new ClientConfiguration()))
                {
                    // client.SetRegion("us-ashburn-1");
                    client.SetRegion(ociRegion);
                    return(await client.GetSecretBundle(getSecretBundleRequest));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"GetSecretBundle Failed with {e.Message}");
                throw e;
            }
        }