Container for the parameters to the DeleteAccessKey operation.

Deletes the access key associated with the specified User.

If you do not specify a User name, IAM determines the User name implicitly based on the AWS Access Key ID signing the request. Because this action works for access keys under the AWS Account, you can use this API to manage root credentials even if the AWS Account has no associated Users.

Inheritance: Amazon.Runtime.AmazonWebServiceRequest
Exemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IdentityManagement.Model.DeleteAccessKeyRequest();

            if (cmdletContext.AccessKeyId != null)
            {
                request.AccessKeyId = cmdletContext.AccessKeyId;
            }
            if (cmdletContext.UserName != null)
            {
                request.UserName = cmdletContext.UserName;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteAccessKey operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAccessKey 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>
        public Task<DeleteAccessKeyResponse> DeleteAccessKeyAsync(DeleteAccessKeyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.Instance;

            return InvokeAsync<DeleteAccessKeyRequest,DeleteAccessKeyResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal DeleteAccessKeyResponse DeleteAccessKey(DeleteAccessKeyRequest request)
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.Instance;

            return Invoke<DeleteAccessKeyRequest,DeleteAccessKeyResponse>(request, marshaller, unmarshaller);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteAccessKey operation.
 /// <seealso cref="Amazon.IdentityManagement.AmazonIdentityManagementService.DeleteAccessKey"/>
 /// </summary>
 /// 
 /// <param name="deleteAccessKeyRequest">Container for the necessary parameters to execute the DeleteAccessKey operation on
 ///          AmazonIdentityManagementService.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public IAsyncResult BeginDeleteAccessKey(DeleteAccessKeyRequest deleteAccessKeyRequest, AsyncCallback callback, object state)
 {
     return invokeDeleteAccessKey(deleteAccessKeyRequest, callback, state, false);
 }
 IAsyncResult invokeDeleteAccessKey(DeleteAccessKeyRequest deleteAccessKeyRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DeleteAccessKeyRequestMarshaller().Marshall(deleteAccessKeyRequest);
     var unmarshaller = DeleteAccessKeyResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// <para>Deletes the access key associated with the specified user.</para> <para>If you do not specify a user name, IAM determines the user
 /// name implicitly based on the AWS Access Key ID signing the request. Because this action works for access keys under the AWS account, you can
 /// use this API to manage root credentials even if the AWS account has no associated users.</para>
 /// </summary>
 /// 
 /// <param name="deleteAccessKeyRequest">Container for the necessary parameters to execute the DeleteAccessKey service method on
 ///          AmazonIdentityManagementService.</param>
 /// 
 /// <exception cref="NoSuchEntityException"/>
 public DeleteAccessKeyResponse DeleteAccessKey(DeleteAccessKeyRequest deleteAccessKeyRequest)
 {
     IAsyncResult asyncResult = invokeDeleteAccessKey(deleteAccessKeyRequest, null, null, true);
     return EndDeleteAccessKey(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteAccessKey operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAccessKey operation on AmazonIdentityManagementServiceClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteAccessKey
        ///         operation.</returns>
        public IAsyncResult BeginDeleteAccessKey(DeleteAccessKeyRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.Instance;

            return BeginInvoke<DeleteAccessKeyRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// <para>Deletes the access key associated with the specified
 /// User.</para> <para>If you do not specify a User name, IAM determines
 /// the User name implicitly based on the AWS Access Key ID signing the
 /// request. Because this action works for access keys under the AWS
 /// Account, you can use this API to manage root credentials even if the
 /// AWS Account has no associated Users.</para>
 /// </summary>
 /// 
 /// <param name="deleteAccessKeyRequest">Container for the necessary
 ///           parameters to execute the DeleteAccessKey service method on
 ///           AmazonIdentityManagementService.</param>
 /// 
 /// <exception cref="NoSuchEntityException"/>
 public DeleteAccessKeyResponse DeleteAccessKey(DeleteAccessKeyRequest deleteAccessKeyRequest)
 {
     IRequest<DeleteAccessKeyRequest> request = new DeleteAccessKeyRequestMarshaller().Marshall(deleteAccessKeyRequest);
     DeleteAccessKeyResponse response = Invoke<DeleteAccessKeyRequest, DeleteAccessKeyResponse> (request, this.signer, DeleteAccessKeyResponseUnmarshaller.GetInstance());
     return response;
 }
 /// <summary>
 /// Initiates the asynchronous execution of the DeleteAccessKey operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the DeleteAccessKey operation on AmazonIdentityManagementServiceClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void DeleteAccessKeyAsync(DeleteAccessKeyRequest request, AmazonServiceCallback<DeleteAccessKeyRequest, DeleteAccessKeyResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new DeleteAccessKeyRequestMarshaller();
     var unmarshaller = DeleteAccessKeyResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<DeleteAccessKeyRequest,DeleteAccessKeyResponse> responseObject 
                     = new AmazonServiceResult<DeleteAccessKeyRequest,DeleteAccessKeyResponse>((DeleteAccessKeyRequest)req, (DeleteAccessKeyResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<DeleteAccessKeyRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteAccessKey operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService.DeleteAccessKey"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAccessKey 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>
		public async Task<DeleteAccessKeyResponse> DeleteAccessKeyAsync(DeleteAccessKeyRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DeleteAccessKeyRequest, DeleteAccessKeyResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// <para>Deletes the access key associated with the specified user.</para> <para>If you do not specify a user name, IAM determines the user
        /// name implicitly based on the AWS access key ID signing the request. Because this action works for access keys under the AWS account, you can
        /// use this API to manage root credentials even if the AWS account has no associated users.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeleteAccessKey service method on
        /// AmazonIdentityManagementService.</param>
        /// 
        /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" />
		public DeleteAccessKeyResponse DeleteAccessKey(DeleteAccessKeyRequest request)
        {
            var task = DeleteAccessKeyAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// <para>Deletes the access key associated with the specified user.</para> <para>If you do not specify a user name, IAM determines the user
        /// name implicitly based on the AWS access key ID signing the request. Because this action works for access keys under the AWS account, you can
        /// use this API to manage root credentials even if the AWS account has no associated users.</para>
        /// </summary>
        /// 
        /// <param name="deleteAccessKeyRequest">Container for the necessary parameters to execute the DeleteAccessKey service method on
        /// AmazonIdentityManagementService.</param>
        /// 
        /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" />
        /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DeleteAccessKeyResponse> DeleteAccessKeyAsync(DeleteAccessKeyRequest deleteAccessKeyRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DeleteAccessKeyRequest, DeleteAccessKeyResponse>(deleteAccessKeyRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Exemplo n.º 13
0
		internal DeleteAccessKeyResponse DeleteAccessKey(DeleteAccessKeyRequest request)
        {
            var task = DeleteAccessKeyAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Exemplo n.º 14
0
 private Amazon.IdentityManagement.Model.DeleteAccessKeyResponse CallAWSServiceOperation(IAmazonIdentityManagementService client, Amazon.IdentityManagement.Model.DeleteAccessKeyRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Identity and Access Management", "DeleteAccessKey");
     try
     {
         #if DESKTOP
         return(client.DeleteAccessKey(request));
         #elif CORECLR
         return(client.DeleteAccessKeyAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        public static void DeleteUser(this AmazonIdentityManagementServiceClient client, string userName)
        {
            try
            {
                var userPolicies =
                    client.ListUserPolicies(new ListUserPoliciesRequest { UserName = userName }).PolicyNames;

                foreach (var policy in userPolicies)
                {
                    var request = new DeleteUserPolicyRequest { UserName = userName, PolicyName = policy };
                    IgnoringNoSuchEntity(() => { client.DeleteUserPolicy(request); });
                }
            }
            catch (NoSuchEntityException)
            {
                return;
            }

            var keys = client.ListAccessKeys(new ListAccessKeysRequest { UserName = userName });

            foreach (var key in keys.AccessKeyMetadata)
            {
                var request = new DeleteAccessKeyRequest { UserName = userName, AccessKeyId = key.AccessKeyId };
                IgnoringNoSuchEntity(() => { client.DeleteAccessKey(request); });
            }

            IgnoringNoSuchEntity(() => client.DeleteUser(new DeleteUserRequest { UserName = userName }));
        }
        IAsyncResult invokeDeleteAccessKey(DeleteAccessKeyRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new DeleteAccessKeyRequestMarshaller();
            var unmarshaller = DeleteAccessKeyResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }