Amazon.IdentityManagement.AmazonIdentityManagementServiceClient.DeleteUserPolicyAsync C# (CSharp) Method

DeleteUserPolicyAsync() public method

Initiates the asynchronous execution of the DeleteUserPolicy operation.
public DeleteUserPolicyAsync ( DeleteUserPolicyRequest request, DeleteUserPolicyResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
request Amazon.IdentityManagement.Model.DeleteUserPolicyRequest Container for the necessary parameters to execute the DeleteUserPolicy operation on AmazonIdentityManagementServiceClient.
callback DeleteUserPolicyResponse>.AmazonServiceCallback An Action delegate that is invoked when the operation completes.
options Amazon.Runtime.AsyncOptions A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.
return void
        public void DeleteUserPolicyAsync(DeleteUserPolicyRequest request, AmazonServiceCallback<DeleteUserPolicyRequest, DeleteUserPolicyResponse> callback, AsyncOptions options = null)
        {
            options = options == null?new AsyncOptions():options;
            var marshaller = new DeleteUserPolicyRequestMarshaller();
            var unmarshaller = DeleteUserPolicyResponseUnmarshaller.Instance;
            Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
            if(callback !=null )
                callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
                    AmazonServiceResult<DeleteUserPolicyRequest,DeleteUserPolicyResponse> responseObject 
                            = new AmazonServiceResult<DeleteUserPolicyRequest,DeleteUserPolicyResponse>((DeleteUserPolicyRequest)req, (DeleteUserPolicyResponse)res, ex , ao.State);    
                        callback(responseObject); 
                };
            BeginInvoke<DeleteUserPolicyRequest>(request, marshaller, unmarshaller, options, callbackHelper);
        }

Same methods

AmazonIdentityManagementServiceClient::DeleteUserPolicyAsync ( DeleteUserPolicyRequest request, System cancellationToken = default(CancellationToken) ) : Task

Usage Example

Example #1
0
 public static void DeleteUserPoliciesForUser(AmazonIdentityManagementServiceClient client, string username)
 {
     ListUserPoliciesResponse response =
         client.ListUserPoliciesAsync(new ListUserPoliciesRequest() { UserName = username }).Result;
     foreach (string pName in response.PolicyNames)
     {
         client.DeleteUserPolicyAsync(new DeleteUserPolicyRequest() { UserName = username, PolicyName = pName }).Wait();
     }
 }
AmazonIdentityManagementServiceClient