public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoT.Model.TestInvokeAuthorizerRequest();

            if (cmdletContext.AuthorizerName != null)
            {
                request.AuthorizerName = cmdletContext.AuthorizerName;
            }
            if (cmdletContext.Token != null)
            {
                request.Token = cmdletContext.Token;
            }
            if (cmdletContext.TokenSignature != null)
            {
                request.TokenSignature = cmdletContext.TokenSignature;
            }

            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);
        }
 private Amazon.IoT.Model.TestInvokeAuthorizerResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.TestInvokeAuthorizerRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "TestInvokeAuthorizer");
     try
     {
         #if DESKTOP
         return(client.TestInvokeAuthorizer(request));
         #elif CORECLR
         return(client.TestInvokeAuthorizerAsync(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 _MqttContext_PasswordStream = null;

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

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

                // populate HttpContext
                var requestHttpContextIsNull = true;
                request.HttpContext = new Amazon.IoT.Model.HttpContext();
                Dictionary <System.String, System.String> requestHttpContext_httpContext_Header = null;
                if (cmdletContext.HttpContext_Header != null)
                {
                    requestHttpContext_httpContext_Header = cmdletContext.HttpContext_Header;
                }
                if (requestHttpContext_httpContext_Header != null)
                {
                    request.HttpContext.Headers = requestHttpContext_httpContext_Header;
                    requestHttpContextIsNull    = false;
                }
                System.String requestHttpContext_httpContext_QueryString = null;
                if (cmdletContext.HttpContext_QueryString != null)
                {
                    requestHttpContext_httpContext_QueryString = cmdletContext.HttpContext_QueryString;
                }
                if (requestHttpContext_httpContext_QueryString != null)
                {
                    request.HttpContext.QueryString = requestHttpContext_httpContext_QueryString;
                    requestHttpContextIsNull        = false;
                }
                // determine if request.HttpContext should be set to null
                if (requestHttpContextIsNull)
                {
                    request.HttpContext = null;
                }

                // populate MqttContext
                var requestMqttContextIsNull = true;
                request.MqttContext = new Amazon.IoT.Model.MqttContext();
                System.String requestMqttContext_mqttContext_ClientId = null;
                if (cmdletContext.MqttContext_ClientId != null)
                {
                    requestMqttContext_mqttContext_ClientId = cmdletContext.MqttContext_ClientId;
                }
                if (requestMqttContext_mqttContext_ClientId != null)
                {
                    request.MqttContext.ClientId = requestMqttContext_mqttContext_ClientId;
                    requestMqttContextIsNull     = false;
                }
                System.IO.MemoryStream requestMqttContext_mqttContext_Password = null;
                if (cmdletContext.MqttContext_Password != null)
                {
                    _MqttContext_PasswordStream             = new System.IO.MemoryStream(cmdletContext.MqttContext_Password);
                    requestMqttContext_mqttContext_Password = _MqttContext_PasswordStream;
                }
                if (requestMqttContext_mqttContext_Password != null)
                {
                    request.MqttContext.Password = requestMqttContext_mqttContext_Password;
                    requestMqttContextIsNull     = false;
                }
                System.String requestMqttContext_mqttContext_Username = null;
                if (cmdletContext.MqttContext_Username != null)
                {
                    requestMqttContext_mqttContext_Username = cmdletContext.MqttContext_Username;
                }
                if (requestMqttContext_mqttContext_Username != null)
                {
                    request.MqttContext.Username = requestMqttContext_mqttContext_Username;
                    requestMqttContextIsNull     = false;
                }
                // determine if request.MqttContext should be set to null
                if (requestMqttContextIsNull)
                {
                    request.MqttContext = null;
                }

                // populate TlsContext
                var requestTlsContextIsNull = true;
                request.TlsContext = new Amazon.IoT.Model.TlsContext();
                System.String requestTlsContext_tlsContext_ServerName = null;
                if (cmdletContext.TlsContext_ServerName != null)
                {
                    requestTlsContext_tlsContext_ServerName = cmdletContext.TlsContext_ServerName;
                }
                if (requestTlsContext_tlsContext_ServerName != null)
                {
                    request.TlsContext.ServerName = requestTlsContext_tlsContext_ServerName;
                    requestTlsContextIsNull       = false;
                }
                // determine if request.TlsContext should be set to null
                if (requestTlsContextIsNull)
                {
                    request.TlsContext = null;
                }
                if (cmdletContext.Token != null)
                {
                    request.Token = cmdletContext.Token;
                }
                if (cmdletContext.TokenSignature != null)
                {
                    request.TokenSignature = cmdletContext.TokenSignature;
                }

                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 (_MqttContext_PasswordStream != null)
                {
                    _MqttContext_PasswordStream.Dispose();
                }
            }
        }