Пример #1
0
        /**
         * Invokes a function.
         *
         * @param fnInvokeClient the service client to use to delete the Function.
         * @param function the Function to invoke.
         * @param payload the payload to pass to the function.
         */
        private static async Task <string> InvokeFunction(FunctionsInvokeClient fnInvokeClient, FunctionSummary function, string payload)
        {
            string response = null;

            try
            {
                logger.Info($"Invoking function endpoint: {function.InvokeEndpoint}");

                // Configure the client to use the assigned function endpoint.
                fnInvokeClient.SetEndpoint(function.InvokeEndpoint);
                var invokeFunctionRequest = new InvokeFunctionRequest
                {
                    FunctionId         = function.Id,
                    InvokeFunctionBody = GenerateStreamFromString(payload)
                };

                // Invoke the function
                var invokeFunctionResponse = await fnInvokeClient.InvokeFunction(invokeFunctionRequest);

                // Handle the response
                response = new StreamReader(invokeFunctionResponse.InputStream).ReadToEnd();
            }
            catch (Exception e)
            {
                logger.Error($"Failed to invoke function: {e}");
            }

            return(response);
        }
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     client?.Dispose();
     client = new FunctionsInvokeClient(AuthProvider, new Oci.Common.ClientConfiguration
     {
         RetryConfiguration = retryConfig,
         TimeoutMillis      = TimeOutInMillis,
         ClientUserAgent    = PSUserAgent
     });
     try
     {
         WriteDebug("Choosing Endpoint:" + Endpoint);
         client.SetEndpoint(Endpoint);
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }
Пример #3
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     try
     {
         client?.Dispose();
         int timeout = GetPreferredTimeout();
         WriteDebug($"Cmdlet Timeout : {timeout} milliseconds.");
         client = new FunctionsInvokeClient(AuthProvider, new Oci.Common.ClientConfiguration
         {
             RetryConfiguration = retryConfig,
             TimeoutMillis      = timeout,
             ClientUserAgent    = PSUserAgent
         });
         WriteDebug("Choosing Endpoint:" + Endpoint);
         client.SetEndpoint(Endpoint);
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }