Exemple #1
0
        public async Task ProcessReport()
        {
            // We build up a mapping of notifications by username
            var notifications = new Notifications();

            LogLine("Retrieving and Processing Credential Report...");
            try
            {
                var crRequ = new GetCredentialReportRequest();
                var crResp = await _iamClient.GetCredentialReportAsync(crRequ);

                LogLine("Retrieved CREDENTIAL REPORT"
                        + $" of format [{crResp.ReportFormat}]"
                        + $" generated at [{crResp.GeneratedTime}]");

                using (var stream = crResp.Content)
                    using (var reader = new StreamReader(stream))
                        using (var csv = new CsvReader(reader))
                        {
                            var userRecords = csv.GetRecords <CredentialReportEntry>();
                            CheckUsers(userRecords, notifications);
                        }

                await NotifyUsers(notifications);
            }
            catch (CredentialReportNotPresentException ex)
            {
                LogLine("ERROR:  Credential Report Not Present:");
                LogLine(ex.ToString());
                return;
            }
            catch (CredentialReportNotReadyException ex)
            {
                LogLine("ERROR:  Credential Report Not Ready:");
                LogLine(ex.ToString());
                return;
            }
            catch (CredentialReportExpiredException ex)
            {
                LogLine("ERROR:  Credential Report Expired:");
                LogLine(ex.ToString());
                return;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetCredentialReport operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport 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<GetCredentialReportResponse> GetCredentialReportAsync(GetCredentialReportRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetCredentialReportRequestMarshaller();
            var unmarshaller = GetCredentialReportResponseUnmarshaller.Instance;

            return InvokeAsync<GetCredentialReportRequest,GetCredentialReportResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal GetCredentialReportResponse GetCredentialReport(GetCredentialReportRequest request)
        {
            var marshaller = new GetCredentialReportRequestMarshaller();
            var unmarshaller = GetCredentialReportResponseUnmarshaller.Instance;

            return Invoke<GetCredentialReportRequest,GetCredentialReportResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetCredentialReport operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport 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 EndGetCredentialReport
        ///         operation.</returns>
        public IAsyncResult BeginGetCredentialReport(GetCredentialReportRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetCredentialReportRequestMarshaller();
            var unmarshaller = GetCredentialReportResponseUnmarshaller.Instance;

            return BeginInvoke<GetCredentialReportRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 public Task <GetCredentialReportResponse> GetCredentialReportAsync(GetCredentialReportRequest request,
                                                                    CancellationToken cancellationToken = new CancellationToken())
 {
     throw new System.NotImplementedException();
 }
 /// <summary>
 /// Initiates the asynchronous execution of the GetCredentialReport operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport 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 GetCredentialReportAsync(GetCredentialReportRequest request, AmazonServiceCallback<GetCredentialReportRequest, GetCredentialReportResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new GetCredentialReportRequestMarshaller();
     var unmarshaller = GetCredentialReportResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<GetCredentialReportRequest,GetCredentialReportResponse> responseObject 
                     = new AmazonServiceResult<GetCredentialReportRequest,GetCredentialReportResponse>((GetCredentialReportRequest)req, (GetCredentialReportResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<GetCredentialReportRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
 internal GetCredentialReportResponse GetCredentialReport(GetCredentialReportRequest request)
 {
     var task = GetCredentialReportAsync(request);
     try
     {
         return task.Result;
     }
     catch(AggregateException e)
     {
         ExceptionDispatchInfo.Capture(e.InnerException).Throw();
         return null;
     }
 }
        /// <summary>
        /// Initiates the asynchronous execution of the GetCredentialReport operation.
        /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService.GetCredentialReport"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport 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<GetCredentialReportResponse> GetCredentialReportAsync(GetCredentialReportRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetCredentialReportRequestMarshaller();
            var unmarshaller = GetCredentialReportResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetCredentialReportRequest, GetCredentialReportResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
        IAsyncResult invokeGetCredentialReport(GetCredentialReportRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new GetCredentialReportRequestMarshaller();
            var unmarshaller = GetCredentialReportResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the GetCredentialReport operation.
 /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/>
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport 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 EndGetCredentialReport
 ///         operation.</returns>
 public IAsyncResult BeginGetCredentialReport(GetCredentialReportRequest request, AsyncCallback callback, object state)
 {
     return invokeGetCredentialReport(request, callback, state, false);
 }
 /// <summary>
 /// Retrieves a credential report for the AWS account. For more information about the
 /// credential report, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/credential-reports.html">Getting
 /// Credential Reports</a> in the <i>Using IAM</i> guide.
 /// </summary>
 /// <param name="request">Container for the necessary parameters to execute the GetCredentialReport service method.</param>
 /// 
 /// <returns>The response from the GetCredentialReport service method, as returned by IdentityManagementService.</returns>
 /// <exception cref="CredentialReportExpiredException">
 /// The request was rejected because the most recent credential report has expired. To
 /// generate a new credential report, use <a>GenerateCredentialReport</a>. For more information
 /// about credential report expiration, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/credential-reports.html">Getting
 /// Credential Reports</a> in the <i>Using IAM</i> guide.
 /// </exception>
 /// <exception cref="CredentialReportNotPresentException">
 /// The request was rejected because the credential report does not exist. To generate
 /// a credential report, use <a>GenerateCredentialReport</a>.
 /// </exception>
 /// <exception cref="CredentialReportNotReadyException">
 /// The request was rejected because the credential report is still being generated.
 /// </exception>
 public GetCredentialReportResponse GetCredentialReport(GetCredentialReportRequest request)
 {
     IAsyncResult asyncResult = invokeGetCredentialReport(request, null, null, true);
     return EndGetCredentialReport(asyncResult);
 }