コード例 #1
0
 private Amazon.AuditManager.Model.CreateAssessmentResponse CallAWSServiceOperation(IAmazonAuditManager client, Amazon.AuditManager.Model.CreateAssessmentRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Audit Manager", "CreateAssessment");
     try
     {
         #if DESKTOP
         return(client.CreateAssessment(request));
         #elif CORECLR
         return(client.CreateAssessmentAsync(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;
     }
 }
コード例 #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.AuditManager.Model.CreateAssessmentRequest();


            // populate AssessmentReportsDestination
            var requestAssessmentReportsDestinationIsNull = true;

            request.AssessmentReportsDestination = new Amazon.AuditManager.Model.AssessmentReportsDestination();
            System.String requestAssessmentReportsDestination_assessmentReportsDestination_Destination = null;
            if (cmdletContext.AssessmentReportsDestination_Destination != null)
            {
                requestAssessmentReportsDestination_assessmentReportsDestination_Destination = cmdletContext.AssessmentReportsDestination_Destination;
            }
            if (requestAssessmentReportsDestination_assessmentReportsDestination_Destination != null)
            {
                request.AssessmentReportsDestination.Destination = requestAssessmentReportsDestination_assessmentReportsDestination_Destination;
                requestAssessmentReportsDestinationIsNull        = false;
            }
            Amazon.AuditManager.AssessmentReportDestinationType requestAssessmentReportsDestination_assessmentReportsDestination_DestinationType = null;
            if (cmdletContext.AssessmentReportsDestination_DestinationType != null)
            {
                requestAssessmentReportsDestination_assessmentReportsDestination_DestinationType = cmdletContext.AssessmentReportsDestination_DestinationType;
            }
            if (requestAssessmentReportsDestination_assessmentReportsDestination_DestinationType != null)
            {
                request.AssessmentReportsDestination.DestinationType = requestAssessmentReportsDestination_assessmentReportsDestination_DestinationType;
                requestAssessmentReportsDestinationIsNull            = false;
            }
            // determine if request.AssessmentReportsDestination should be set to null
            if (requestAssessmentReportsDestinationIsNull)
            {
                request.AssessmentReportsDestination = null;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.FrameworkId != null)
            {
                request.FrameworkId = cmdletContext.FrameworkId;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            if (cmdletContext.Role != null)
            {
                request.Roles = cmdletContext.Role;
            }

            // populate Scope
            var requestScopeIsNull = true;

            request.Scope = new Amazon.AuditManager.Model.Scope();
            List <Amazon.AuditManager.Model.AWSAccount> requestScope_scope_AwsAccount = null;

            if (cmdletContext.Scope_AwsAccount != null)
            {
                requestScope_scope_AwsAccount = cmdletContext.Scope_AwsAccount;
            }
            if (requestScope_scope_AwsAccount != null)
            {
                request.Scope.AwsAccounts = requestScope_scope_AwsAccount;
                requestScopeIsNull        = false;
            }
            List <Amazon.AuditManager.Model.AWSService> requestScope_scope_AwsService = null;

            if (cmdletContext.Scope_AwsService != null)
            {
                requestScope_scope_AwsService = cmdletContext.Scope_AwsService;
            }
            if (requestScope_scope_AwsService != null)
            {
                request.Scope.AwsServices = requestScope_scope_AwsService;
                requestScopeIsNull        = false;
            }
            // determine if request.Scope should be set to null
            if (requestScopeIsNull)
            {
                request.Scope = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            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);
        }