private Amazon.IoT.Model.GetBucketsAggregationResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.GetBucketsAggregationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "GetBucketsAggregation");
     try
     {
         #if DESKTOP
         return(client.GetBucketsAggregation(request));
         #elif CORECLR
         return(client.GetBucketsAggregationAsync(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 object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoT.Model.GetBucketsAggregationRequest();

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

            // populate BucketsAggregationType
            var requestBucketsAggregationTypeIsNull = true;

            request.BucketsAggregationType = new Amazon.IoT.Model.BucketsAggregationType();
            Amazon.IoT.Model.TermsAggregation requestBucketsAggregationType_bucketsAggregationType_TermsAggregation = null;

            // populate TermsAggregation
            var requestBucketsAggregationType_bucketsAggregationType_TermsAggregationIsNull = true;

            requestBucketsAggregationType_bucketsAggregationType_TermsAggregation = new Amazon.IoT.Model.TermsAggregation();
            System.Int32?requestBucketsAggregationType_bucketsAggregationType_TermsAggregation_termsAggregation_MaxBucket = null;
            if (cmdletContext.TermsAggregation_MaxBucket != null)
            {
                requestBucketsAggregationType_bucketsAggregationType_TermsAggregation_termsAggregation_MaxBucket = cmdletContext.TermsAggregation_MaxBucket.Value;
            }
            if (requestBucketsAggregationType_bucketsAggregationType_TermsAggregation_termsAggregation_MaxBucket != null)
            {
                requestBucketsAggregationType_bucketsAggregationType_TermsAggregation.MaxBuckets = requestBucketsAggregationType_bucketsAggregationType_TermsAggregation_termsAggregation_MaxBucket.Value;
                requestBucketsAggregationType_bucketsAggregationType_TermsAggregationIsNull      = false;
            }
            // determine if requestBucketsAggregationType_bucketsAggregationType_TermsAggregation should be set to null
            if (requestBucketsAggregationType_bucketsAggregationType_TermsAggregationIsNull)
            {
                requestBucketsAggregationType_bucketsAggregationType_TermsAggregation = null;
            }
            if (requestBucketsAggregationType_bucketsAggregationType_TermsAggregation != null)
            {
                request.BucketsAggregationType.TermsAggregation = requestBucketsAggregationType_bucketsAggregationType_TermsAggregation;
                requestBucketsAggregationTypeIsNull             = false;
            }
            // determine if request.BucketsAggregationType should be set to null
            if (requestBucketsAggregationTypeIsNull)
            {
                request.BucketsAggregationType = null;
            }
            if (cmdletContext.IndexName != null)
            {
                request.IndexName = cmdletContext.IndexName;
            }
            if (cmdletContext.QueryString != null)
            {
                request.QueryString = cmdletContext.QueryString;
            }
            if (cmdletContext.QueryVersion != null)
            {
                request.QueryVersion = cmdletContext.QueryVersion;
            }

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