コード例 #1
0
 private Amazon.Lex.Model.PostContentResponse CallAWSServiceOperation(IAmazonLex client, Amazon.Lex.Model.PostContentRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lex", "PostContent");
     try
     {
         #if DESKTOP
         return(client.PostContent(request));
         #elif CORECLR
         return(client.PostContentAsync(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)
        {
            System.IO.Stream _InputStreamStream = null;

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

                if (cmdletContext.Accept != null)
                {
                    request.Accept = cmdletContext.Accept;
                }
                if (cmdletContext.BotAlias != null)
                {
                    request.BotAlias = cmdletContext.BotAlias;
                }
                if (cmdletContext.BotName != null)
                {
                    request.BotName = cmdletContext.BotName;
                }
                if (cmdletContext.ContentType != null)
                {
                    request.ContentType = cmdletContext.ContentType;
                }
                if (cmdletContext.InputStream != null)
                {
                    _InputStreamStream  = Amazon.PowerShell.Common.StreamParameterConverter.TransformToStream(cmdletContext.InputStream);
                    request.InputStream = _InputStreamStream;
                }
                if (cmdletContext.RequestAttribute != null)
                {
                    request.RequestAttributes = cmdletContext.RequestAttribute;
                }
                if (cmdletContext.SessionAttribute != null)
                {
                    request.SessionAttributes = cmdletContext.SessionAttribute;
                }
                if (cmdletContext.UserId != null)
                {
                    request.UserId = cmdletContext.UserId;
                }

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