Inheritance: AmazonLambdaRequest
Exemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            System.IO.Stream _InvokeArgsStreamStream = null;

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

                if (cmdletContext.InvokeArg != null)
                {
                    request.InvokeArgs = cmdletContext.InvokeArg;
                }
                if (cmdletContext.FunctionName != null)
                {
                    request.FunctionName = cmdletContext.FunctionName;
                }
                if (cmdletContext.InvokeArgsStream != null)
                {
                    _InvokeArgsStreamStream  = Amazon.PowerShell.Common.StreamParameterConverter.TransformToStream(cmdletContext.InvokeArgsStream);
                    request.InvokeArgsStream = _InvokeArgsStreamStream;
                }

                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 (_InvokeArgsStreamStream != null)
                {
                    _InvokeArgsStreamStream.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        public Task<InvokeAsyncResponse> InvokeAsyncAsync(InvokeAsyncRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new InvokeAsyncRequestMarshaller();
            var unmarshaller = InvokeAsyncResponseUnmarshaller.Instance;

            return InvokeAsync<InvokeAsyncRequest,InvokeAsyncResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Exemplo n.º 3
0
        internal InvokeAsyncResponse InvokeAsync(InvokeAsyncRequest request)
        {
            var marshaller = new InvokeAsyncRequestMarshaller();
            var unmarshaller = InvokeAsyncResponseUnmarshaller.Instance;

            return Invoke<InvokeAsyncRequest,InvokeAsyncResponse>(request, marshaller, unmarshaller);
        }
Exemplo n.º 4
0
 private Amazon.Lambda.Model.InvokeAsyncResponse CallAWSServiceOperation(IAmazonLambda client, Amazon.Lambda.Model.InvokeAsyncRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Lambda", "InvokeAsync");
     try
     {
         #if DESKTOP
         return(client.InvokeAsync(request));
         #elif CORECLR
         return(client.InvokeAsyncAsync(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;
     }
 }
Exemplo n.º 5
0
        public IAsyncResult BeginInvokeAsync(InvokeAsyncRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new InvokeAsyncRequestMarshaller();
            var unmarshaller = InvokeAsyncResponseUnmarshaller.Instance;

            return BeginInvoke<InvokeAsyncRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Exemplo n.º 6
0
 public void InvokeAsyncAsync(InvokeAsyncRequest request, AmazonServiceCallback<InvokeAsyncRequest, InvokeAsyncResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new InvokeAsyncRequestMarshaller();
     var unmarshaller = InvokeAsyncResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<InvokeAsyncRequest,InvokeAsyncResponse> responseObject 
                     = new AmazonServiceResult<InvokeAsyncRequest,InvokeAsyncResponse>((InvokeAsyncRequest)req, (InvokeAsyncResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<InvokeAsyncRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }