internal virtual GetRandomPasswordResponse GetRandomPassword(GetRandomPasswordRequest request)
        {
            var marshaller   = GetRandomPasswordRequestMarshaller.Instance;
            var unmarshaller = GetRandomPasswordResponseUnmarshaller.Instance;

            return(Invoke <GetRandomPasswordRequest, GetRandomPasswordResponse>(request, marshaller, unmarshaller));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetRandomPassword operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetRandomPassword operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/secretsmanager-2017-10-17/GetRandomPassword">REST API Reference for GetRandomPassword Operation</seealso>
        public virtual Task <GetRandomPasswordResponse> GetRandomPasswordAsync(GetRandomPasswordRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = GetRandomPasswordRequestMarshaller.Instance;
            var unmarshaller = GetRandomPasswordResponseUnmarshaller.Instance;

            return(InvokeAsync <GetRandomPasswordRequest, GetRandomPasswordResponse>(request, marshaller,
                                                                                     unmarshaller, cancellationToken));
        }
Ejemplo n.º 3
0
        internal virtual GetRandomPasswordResponse GetRandomPassword(GetRandomPasswordRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetRandomPasswordRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetRandomPasswordResponseUnmarshaller.Instance;

            return(Invoke <GetRandomPasswordResponse>(request, options));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetRandomPassword operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetRandomPassword operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/secretsmanager-2017-10-17/GetRandomPassword">REST API Reference for GetRandomPassword Operation</seealso>
        public virtual Task <GetRandomPasswordResponse> GetRandomPasswordAsync(GetRandomPasswordRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetRandomPasswordRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetRandomPasswordResponseUnmarshaller.Instance;

            return(InvokeAsync <GetRandomPasswordResponse>(request, options, cancellationToken));
        }
Ejemplo n.º 5
0
        internal static void CreateSecret(AmazonSecretsManagerClient client, string secretId, string token)
        {
            Console.WriteLine("Creating secret");
            var secretValue = GetSecret(client, secretId, "AWSCURRENT");

            try {
                GetSecret(client, secretId, "AWSPENDING", token);
                Console.WriteLine("createSecret: There is already a pending secret for " + secretId + " - no need to set a new one");
            } catch (AggregateException ae) {
                ae.Handle((x) =>
                {
                    if (x is ResourceNotFoundException) // Catch the inner exception from the task and only handle the not found error
                    {
                        Console.WriteLine("createSecret: No pending secret found for " + secretId + " creating a new random password");
                        return(true);
                    }
                    return(false); // Let anything else fail the function.
                });
                var passwordRequest = new GetRandomPasswordRequest();
                passwordRequest.ExcludePunctuation = true; //avoid possible parsing issues
                var    asyncGetPassword = client.GetRandomPasswordAsync(passwordRequest);
                string newPassword      = asyncGetPassword.Result.RandomPassword;
                var    secretString     = JsonConvert.DeserializeObject <SecretString>(secretValue.SecretString);
                secretString.Password = newPassword;

                var asyncResult = client.PutSecretValueAsync(new PutSecretValueRequest {
                    SecretId           = secretId,
                    ClientRequestToken = token,
                    SecretString       = JsonConvert.SerializeObject(secretString),
                    VersionStages      = new List <string> {
                        "AWSPENDING"
                    }
                });
                Console.WriteLine($"createSecret: Pending secret successfully set for {secretId} - " +
                                  $"response code: {asyncResult.Result.HttpStatusCode.ToString()}");
            }
        }