private Amazon.IoTSiteWise.Model.CreatePortalResponse CallAWSServiceOperation(IAmazonIoTSiteWise client, Amazon.IoTSiteWise.Model.CreatePortalRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT SiteWise", "CreatePortal");
     try
     {
         #if DESKTOP
         return(client.CreatePortal(request));
         #elif CORECLR
         return(client.CreatePortalAsync(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)
        {
            System.IO.MemoryStream _PortalLogoImageFile_DataStream = null;

            try
            {
                var cmdletContext = context as CmdletContext;
                // create request
                var request = new Amazon.IoTSiteWise.Model.CreatePortalRequest();


                // populate Alarms
                var requestAlarmsIsNull = true;
                request.Alarms = new Amazon.IoTSiteWise.Model.Alarms();
                System.String requestAlarms_alarms_AlarmRoleArn = null;
                if (cmdletContext.Alarms_AlarmRoleArn != null)
                {
                    requestAlarms_alarms_AlarmRoleArn = cmdletContext.Alarms_AlarmRoleArn;
                }
                if (requestAlarms_alarms_AlarmRoleArn != null)
                {
                    request.Alarms.AlarmRoleArn = requestAlarms_alarms_AlarmRoleArn;
                    requestAlarmsIsNull         = false;
                }
                System.String requestAlarms_alarms_NotificationLambdaArn = null;
                if (cmdletContext.Alarms_NotificationLambdaArn != null)
                {
                    requestAlarms_alarms_NotificationLambdaArn = cmdletContext.Alarms_NotificationLambdaArn;
                }
                if (requestAlarms_alarms_NotificationLambdaArn != null)
                {
                    request.Alarms.NotificationLambdaArn = requestAlarms_alarms_NotificationLambdaArn;
                    requestAlarmsIsNull = false;
                }
                // determine if request.Alarms should be set to null
                if (requestAlarmsIsNull)
                {
                    request.Alarms = null;
                }
                if (cmdletContext.ClientToken != null)
                {
                    request.ClientToken = cmdletContext.ClientToken;
                }
                if (cmdletContext.NotificationSenderEmail != null)
                {
                    request.NotificationSenderEmail = cmdletContext.NotificationSenderEmail;
                }
                if (cmdletContext.PortalAuthMode != null)
                {
                    request.PortalAuthMode = cmdletContext.PortalAuthMode;
                }
                if (cmdletContext.PortalContactEmail != null)
                {
                    request.PortalContactEmail = cmdletContext.PortalContactEmail;
                }
                if (cmdletContext.PortalDescription != null)
                {
                    request.PortalDescription = cmdletContext.PortalDescription;
                }

                // populate PortalLogoImageFile
                var requestPortalLogoImageFileIsNull = true;
                request.PortalLogoImageFile = new Amazon.IoTSiteWise.Model.ImageFile();
                System.IO.MemoryStream requestPortalLogoImageFile_portalLogoImageFile_Data = null;
                if (cmdletContext.PortalLogoImageFile_Data != null)
                {
                    _PortalLogoImageFile_DataStream = new System.IO.MemoryStream(cmdletContext.PortalLogoImageFile_Data);
                    requestPortalLogoImageFile_portalLogoImageFile_Data = _PortalLogoImageFile_DataStream;
                }
                if (requestPortalLogoImageFile_portalLogoImageFile_Data != null)
                {
                    request.PortalLogoImageFile.Data = requestPortalLogoImageFile_portalLogoImageFile_Data;
                    requestPortalLogoImageFileIsNull = false;
                }
                Amazon.IoTSiteWise.ImageFileType requestPortalLogoImageFile_portalLogoImageFile_Type = null;
                if (cmdletContext.PortalLogoImageFile_Type != null)
                {
                    requestPortalLogoImageFile_portalLogoImageFile_Type = cmdletContext.PortalLogoImageFile_Type;
                }
                if (requestPortalLogoImageFile_portalLogoImageFile_Type != null)
                {
                    request.PortalLogoImageFile.Type = requestPortalLogoImageFile_portalLogoImageFile_Type;
                    requestPortalLogoImageFileIsNull = false;
                }
                // determine if request.PortalLogoImageFile should be set to null
                if (requestPortalLogoImageFileIsNull)
                {
                    request.PortalLogoImageFile = null;
                }
                if (cmdletContext.PortalName != null)
                {
                    request.PortalName = cmdletContext.PortalName;
                }
                if (cmdletContext.RoleArn != null)
                {
                    request.RoleArn = cmdletContext.RoleArn;
                }
                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);
            }
            finally
            {
                if (_PortalLogoImageFile_DataStream != null)
                {
                    _PortalLogoImageFile_DataStream.Dispose();
                }
            }
        }