private Amazon.CloudFront.Model.CreateFunctionResponse CallAWSServiceOperation(IAmazonCloudFront client, Amazon.CloudFront.Model.CreateFunctionRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CloudFront", "CreateFunction"); try { #if DESKTOP return client.CreateFunction(request); #elif CORECLR return client.CreateFunctionAsync(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 _FunctionCodeStream = null; try { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.CloudFront.Model.CreateFunctionRequest(); 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.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(); } } }