private Amazon.IoTSiteWise.Model.CreateGatewayResponse CallAWSServiceOperation(IAmazonIoTSiteWise client, Amazon.IoTSiteWise.Model.CreateGatewayRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT SiteWise", "CreateGateway");
     try
     {
         #if DESKTOP
         return(client.CreateGateway(request));
         #elif CORECLR
         return(client.CreateGatewayAsync(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.IoTSiteWise.Model.CreateGatewayRequest();

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

            // populate GatewayPlatform
            var requestGatewayPlatformIsNull = true;

            request.GatewayPlatform = new Amazon.IoTSiteWise.Model.GatewayPlatform();
            Amazon.IoTSiteWise.Model.Greengrass requestGatewayPlatform_gatewayPlatform_Greengrass = null;

            // populate Greengrass
            var requestGatewayPlatform_gatewayPlatform_GreengrassIsNull = true;

            requestGatewayPlatform_gatewayPlatform_Greengrass = new Amazon.IoTSiteWise.Model.Greengrass();
            System.String requestGatewayPlatform_gatewayPlatform_Greengrass_greengrass_GroupArn = null;
            if (cmdletContext.Greengrass_GroupArn != null)
            {
                requestGatewayPlatform_gatewayPlatform_Greengrass_greengrass_GroupArn = cmdletContext.Greengrass_GroupArn;
            }
            if (requestGatewayPlatform_gatewayPlatform_Greengrass_greengrass_GroupArn != null)
            {
                requestGatewayPlatform_gatewayPlatform_Greengrass.GroupArn = requestGatewayPlatform_gatewayPlatform_Greengrass_greengrass_GroupArn;
                requestGatewayPlatform_gatewayPlatform_GreengrassIsNull    = false;
            }
            // determine if requestGatewayPlatform_gatewayPlatform_Greengrass should be set to null
            if (requestGatewayPlatform_gatewayPlatform_GreengrassIsNull)
            {
                requestGatewayPlatform_gatewayPlatform_Greengrass = null;
            }
            if (requestGatewayPlatform_gatewayPlatform_Greengrass != null)
            {
                request.GatewayPlatform.Greengrass = requestGatewayPlatform_gatewayPlatform_Greengrass;
                requestGatewayPlatformIsNull       = false;
            }
            Amazon.IoTSiteWise.Model.GreengrassV2 requestGatewayPlatform_gatewayPlatform_GreengrassV2 = null;

            // populate GreengrassV2
            var requestGatewayPlatform_gatewayPlatform_GreengrassV2IsNull = true;

            requestGatewayPlatform_gatewayPlatform_GreengrassV2 = new Amazon.IoTSiteWise.Model.GreengrassV2();
            System.String requestGatewayPlatform_gatewayPlatform_GreengrassV2_greengrassV2_CoreDeviceThingName = null;
            if (cmdletContext.GreengrassV2_CoreDeviceThingName != null)
            {
                requestGatewayPlatform_gatewayPlatform_GreengrassV2_greengrassV2_CoreDeviceThingName = cmdletContext.GreengrassV2_CoreDeviceThingName;
            }
            if (requestGatewayPlatform_gatewayPlatform_GreengrassV2_greengrassV2_CoreDeviceThingName != null)
            {
                requestGatewayPlatform_gatewayPlatform_GreengrassV2.CoreDeviceThingName = requestGatewayPlatform_gatewayPlatform_GreengrassV2_greengrassV2_CoreDeviceThingName;
                requestGatewayPlatform_gatewayPlatform_GreengrassV2IsNull = false;
            }
            // determine if requestGatewayPlatform_gatewayPlatform_GreengrassV2 should be set to null
            if (requestGatewayPlatform_gatewayPlatform_GreengrassV2IsNull)
            {
                requestGatewayPlatform_gatewayPlatform_GreengrassV2 = null;
            }
            if (requestGatewayPlatform_gatewayPlatform_GreengrassV2 != null)
            {
                request.GatewayPlatform.GreengrassV2 = requestGatewayPlatform_gatewayPlatform_GreengrassV2;
                requestGatewayPlatformIsNull         = false;
            }
            // determine if request.GatewayPlatform should be set to null
            if (requestGatewayPlatformIsNull)
            {
                request.GatewayPlatform = 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);
        }