/// <summary> /// Gets information about the specified secret. /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/vault/GetSecret.cs.html">here</a> to see an example of how to use GetSecret API.</example> public async Task <GetSecretResponse> GetSecret(GetSecretRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called getSecret"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/secrets/{secretId}".Trim('/'))); HttpMethod method = new HttpMethod("GET"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <GetSecretResponse>(responseMessage)); } catch (Exception e) { logger.Error($"GetSecret failed with error: {e.Message}"); throw; } }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetSecretRequest, GetSecretResponse> ForSecret(GetSecretRequest request, WaiterConfiguration config, params Secret.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetSecretRequest, GetSecretResponse>( request, request => client.GetSecret(request), response => targetStates.Contains(response.Secret.LifecycleState.Value), targetStates.Contains(Secret.LifecycleStateEnum.Deleted) ); return(new Waiter <GetSecretRequest, GetSecretResponse>(config, agent)); }
// [END secretmanager_get_secret_version] // [START secretmanager_get_secret] /// <summary> /// Get an existing secret. /// </summary> /// <param name="projectId">ID of the project where the secret resides.</param> /// <param name="secretId">ID of the secret.</param> /// <example> /// Get an existing secret. /// <code>GetSecret("my-project", "my-secret")</code> /// </example> public static void GetSecret(string projectId, string secretId) { SecretManagerServiceClient client = SecretManagerServiceClient.Create(); // Create the request. var request = new GetSecretRequest { SecretName = new SecretName(projectId, secretId), }; // Get the secret. var secret = client.GetSecret(request); Console.WriteLine($"Secret {secret.Name}, replication {secret.Replication.ReplicationCase}"); }
private void HandleOutput(GetSecretRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForSecret(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetSecret(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Secret); }
protected override void ProcessRecord() { base.ProcessRecord(); GetSecretRequest request; try { request = new GetSecretRequest { SecretId = SecretId, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetSecretRequest, GetSecretResponse> ForSecret(GetSecretRequest request, params Secret.LifecycleStateEnum[] targetStates) { return(this.ForSecret(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }