示例#1
0
 private Amazon.CloudFront.Model.UpdateFunctionResponse CallAWSServiceOperation(IAmazonCloudFront client, Amazon.CloudFront.Model.UpdateFunctionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudFront", "UpdateFunction");
     try
     {
         #if DESKTOP
         return(client.UpdateFunction(request));
         #elif CORECLR
         return(client.UpdateFunctionAsync(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.MemoryStream _FunctionCodeStream = null;

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

                if (cmdletContext.FunctionCode != null)
                {
                    _FunctionCodeStream  = new System.IO.MemoryStream(cmdletContext.FunctionCode);
                    request.FunctionCode = _FunctionCodeStream;
                }

                // populate FunctionConfig
                var requestFunctionConfigIsNull = true;
                request.FunctionConfig = new Amazon.CloudFront.Model.FunctionConfig();
                System.String requestFunctionConfig_functionConfig_Comment = null;
                if (cmdletContext.FunctionConfig_Comment != null)
                {
                    requestFunctionConfig_functionConfig_Comment = cmdletContext.FunctionConfig_Comment;
                }
                if (requestFunctionConfig_functionConfig_Comment != null)
                {
                    request.FunctionConfig.Comment = requestFunctionConfig_functionConfig_Comment;
                    requestFunctionConfigIsNull    = false;
                }
                Amazon.CloudFront.FunctionRuntime requestFunctionConfig_functionConfig_Runtime = null;
                if (cmdletContext.FunctionConfig_Runtime != null)
                {
                    requestFunctionConfig_functionConfig_Runtime = cmdletContext.FunctionConfig_Runtime;
                }
                if (requestFunctionConfig_functionConfig_Runtime != null)
                {
                    request.FunctionConfig.Runtime = requestFunctionConfig_functionConfig_Runtime;
                    requestFunctionConfigIsNull    = false;
                }
                // determine if request.FunctionConfig should be set to null
                if (requestFunctionConfigIsNull)
                {
                    request.FunctionConfig = null;
                }
                if (cmdletContext.IfMatch != null)
                {
                    request.IfMatch = cmdletContext.IfMatch;
                }
                if (cmdletContext.Name != null)
                {
                    request.Name = cmdletContext.Name;
                }

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