Example #1
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateFunction operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateFunction operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<CreateFunctionResponse> CreateFunctionAsync(CreateFunctionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateFunctionRequestMarshaller();
            var unmarshaller = CreateFunctionResponseUnmarshaller.Instance;

            return InvokeAsync<CreateFunctionRequest,CreateFunctionResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Example #2
0
        internal CreateFunctionResponse CreateFunction(CreateFunctionRequest request)
        {
            var marshaller = new CreateFunctionRequestMarshaller();
            var unmarshaller = CreateFunctionResponseUnmarshaller.Instance;

            return Invoke<CreateFunctionRequest,CreateFunctionResponse>(request, marshaller, unmarshaller);
        }
Example #3
0
 private Amazon.Lambda.Model.CreateFunctionResponse CallAWSServiceOperation(IAmazonLambda client, Amazon.Lambda.Model.CreateFunctionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Lambda", "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;
     }
 }
Example #4
0
        public object Execute(ExecutorContext context)
        {
            System.IO.MemoryStream _Code_ZipFileStream = null;

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


                // populate Code
                var requestCodeIsNull = true;
                request.Code = new Amazon.Lambda.Model.FunctionCode();
                System.String requestCode_code_ImageUri = null;
                if (cmdletContext.Code_ImageUri != null)
                {
                    requestCode_code_ImageUri = cmdletContext.Code_ImageUri;
                }
                if (requestCode_code_ImageUri != null)
                {
                    request.Code.ImageUri = requestCode_code_ImageUri;
                    requestCodeIsNull     = false;
                }
                System.String requestCode_code_S3Bucket = null;
                if (cmdletContext.Code_S3Bucket != null)
                {
                    requestCode_code_S3Bucket = cmdletContext.Code_S3Bucket;
                }
                if (requestCode_code_S3Bucket != null)
                {
                    request.Code.S3Bucket = requestCode_code_S3Bucket;
                    requestCodeIsNull     = false;
                }
                System.String requestCode_code_S3Key = null;
                if (cmdletContext.Code_S3Key != null)
                {
                    requestCode_code_S3Key = cmdletContext.Code_S3Key;
                }
                if (requestCode_code_S3Key != null)
                {
                    request.Code.S3Key = requestCode_code_S3Key;
                    requestCodeIsNull  = false;
                }
                System.String requestCode_code_S3ObjectVersion = null;
                if (cmdletContext.Code_S3ObjectVersion != null)
                {
                    requestCode_code_S3ObjectVersion = cmdletContext.Code_S3ObjectVersion;
                }
                if (requestCode_code_S3ObjectVersion != null)
                {
                    request.Code.S3ObjectVersion = requestCode_code_S3ObjectVersion;
                    requestCodeIsNull            = false;
                }
                System.IO.MemoryStream requestCode_code_ZipFile = null;
                if (cmdletContext.Code_ZipFile != null)
                {
                    _Code_ZipFileStream      = new System.IO.MemoryStream(cmdletContext.Code_ZipFile);
                    requestCode_code_ZipFile = _Code_ZipFileStream;
                }
                if (requestCode_code_ZipFile != null)
                {
                    request.Code.ZipFile = requestCode_code_ZipFile;
                    requestCodeIsNull    = false;
                }
                // determine if request.Code should be set to null
                if (requestCodeIsNull)
                {
                    request.Code = null;
                }
                if (cmdletContext.CodeSigningConfigArn != null)
                {
                    request.CodeSigningConfigArn = cmdletContext.CodeSigningConfigArn;
                }

                // populate DeadLetterConfig
                var requestDeadLetterConfigIsNull = true;
                request.DeadLetterConfig = new Amazon.Lambda.Model.DeadLetterConfig();
                System.String requestDeadLetterConfig_deadLetterConfig_TargetArn = null;
                if (cmdletContext.DeadLetterConfig_TargetArn != null)
                {
                    requestDeadLetterConfig_deadLetterConfig_TargetArn = cmdletContext.DeadLetterConfig_TargetArn;
                }
                if (requestDeadLetterConfig_deadLetterConfig_TargetArn != null)
                {
                    request.DeadLetterConfig.TargetArn = requestDeadLetterConfig_deadLetterConfig_TargetArn;
                    requestDeadLetterConfigIsNull      = false;
                }
                // determine if request.DeadLetterConfig should be set to null
                if (requestDeadLetterConfigIsNull)
                {
                    request.DeadLetterConfig = null;
                }
                if (cmdletContext.Description != null)
                {
                    request.Description = cmdletContext.Description;
                }

                // populate Environment
                var requestEnvironmentIsNull = true;
                request.Environment = new Amazon.Lambda.Model.Environment();
                Dictionary <System.String, System.String> requestEnvironment_environment_Variable = null;
                if (cmdletContext.Environment_Variable != null)
                {
                    requestEnvironment_environment_Variable = cmdletContext.Environment_Variable;
                }
                if (requestEnvironment_environment_Variable != null)
                {
                    request.Environment.Variables = requestEnvironment_environment_Variable;
                    requestEnvironmentIsNull      = false;
                }
                System.Boolean?requestEnvironment_environment_IsVariablesSet = null;
                if (cmdletContext.Environment_IsVariablesSet != null)
                {
                    requestEnvironment_environment_IsVariablesSet = cmdletContext.Environment_IsVariablesSet.Value;
                }
                if (requestEnvironment_environment_IsVariablesSet != null)
                {
                    request.Environment.IsVariablesSet = requestEnvironment_environment_IsVariablesSet.Value;
                    requestEnvironmentIsNull           = false;
                }
                // determine if request.Environment should be set to null
                if (requestEnvironmentIsNull)
                {
                    request.Environment = null;
                }
                if (cmdletContext.FileSystemConfig != null)
                {
                    request.FileSystemConfigs = cmdletContext.FileSystemConfig;
                }
                if (cmdletContext.FunctionName != null)
                {
                    request.FunctionName = cmdletContext.FunctionName;
                }
                if (cmdletContext.Handler != null)
                {
                    request.Handler = cmdletContext.Handler;
                }

                // populate ImageConfig
                var requestImageConfigIsNull = true;
                request.ImageConfig = new Amazon.Lambda.Model.ImageConfig();
                List <System.String> requestImageConfig_imageConfig_Command = null;
                if (cmdletContext.ImageConfig_Command != null)
                {
                    requestImageConfig_imageConfig_Command = cmdletContext.ImageConfig_Command;
                }
                if (requestImageConfig_imageConfig_Command != null)
                {
                    request.ImageConfig.Command = requestImageConfig_imageConfig_Command;
                    requestImageConfigIsNull    = false;
                }
                System.Boolean?requestImageConfig_imageConfig_IsCommandSet = null;
                if (cmdletContext.ImageConfig_IsCommandSet != null)
                {
                    requestImageConfig_imageConfig_IsCommandSet = cmdletContext.ImageConfig_IsCommandSet.Value;
                }
                if (requestImageConfig_imageConfig_IsCommandSet != null)
                {
                    request.ImageConfig.IsCommandSet = requestImageConfig_imageConfig_IsCommandSet.Value;
                    requestImageConfigIsNull         = false;
                }
                List <System.String> requestImageConfig_imageConfig_EntryPoint = null;
                if (cmdletContext.ImageConfig_EntryPoint != null)
                {
                    requestImageConfig_imageConfig_EntryPoint = cmdletContext.ImageConfig_EntryPoint;
                }
                if (requestImageConfig_imageConfig_EntryPoint != null)
                {
                    request.ImageConfig.EntryPoint = requestImageConfig_imageConfig_EntryPoint;
                    requestImageConfigIsNull       = false;
                }
                System.Boolean?requestImageConfig_imageConfig_IsEntryPointSet = null;
                if (cmdletContext.ImageConfig_IsEntryPointSet != null)
                {
                    requestImageConfig_imageConfig_IsEntryPointSet = cmdletContext.ImageConfig_IsEntryPointSet.Value;
                }
                if (requestImageConfig_imageConfig_IsEntryPointSet != null)
                {
                    request.ImageConfig.IsEntryPointSet = requestImageConfig_imageConfig_IsEntryPointSet.Value;
                    requestImageConfigIsNull            = false;
                }
                System.String requestImageConfig_imageConfig_WorkingDirectory = null;
                if (cmdletContext.ImageConfig_WorkingDirectory != null)
                {
                    requestImageConfig_imageConfig_WorkingDirectory = cmdletContext.ImageConfig_WorkingDirectory;
                }
                if (requestImageConfig_imageConfig_WorkingDirectory != null)
                {
                    request.ImageConfig.WorkingDirectory = requestImageConfig_imageConfig_WorkingDirectory;
                    requestImageConfigIsNull             = false;
                }
                // determine if request.ImageConfig should be set to null
                if (requestImageConfigIsNull)
                {
                    request.ImageConfig = null;
                }
                if (cmdletContext.KMSKeyArn != null)
                {
                    request.KMSKeyArn = cmdletContext.KMSKeyArn;
                }
                if (cmdletContext.Layer != null)
                {
                    request.Layers = cmdletContext.Layer;
                }
                if (cmdletContext.MemorySize != null)
                {
                    request.MemorySize = cmdletContext.MemorySize.Value;
                }
                if (cmdletContext.PackageType != null)
                {
                    request.PackageType = cmdletContext.PackageType;
                }
                if (cmdletContext.PublishVersion != null)
                {
                    request.Publish = cmdletContext.PublishVersion.Value;
                }
                if (cmdletContext.Role != null)
                {
                    request.Role = cmdletContext.Role;
                }
                if (cmdletContext.Runtime != null)
                {
                    request.Runtime = cmdletContext.Runtime;
                }
                if (cmdletContext.Tag != null)
                {
                    request.Tags = cmdletContext.Tag;
                }
                if (cmdletContext.Timeout != null)
                {
                    request.Timeout = cmdletContext.Timeout.Value;
                }

                // populate TracingConfig
                var requestTracingConfigIsNull = true;
                request.TracingConfig = new Amazon.Lambda.Model.TracingConfig();
                Amazon.Lambda.TracingMode requestTracingConfig_tracingConfig_Mode = null;
                if (cmdletContext.TracingConfig_Mode != null)
                {
                    requestTracingConfig_tracingConfig_Mode = cmdletContext.TracingConfig_Mode;
                }
                if (requestTracingConfig_tracingConfig_Mode != null)
                {
                    request.TracingConfig.Mode = requestTracingConfig_tracingConfig_Mode;
                    requestTracingConfigIsNull = false;
                }
                // determine if request.TracingConfig should be set to null
                if (requestTracingConfigIsNull)
                {
                    request.TracingConfig = null;
                }

                // populate VpcConfig
                var requestVpcConfigIsNull = true;
                request.VpcConfig = new Amazon.Lambda.Model.VpcConfig();
                List <System.String> requestVpcConfig_vpcConfig_SecurityGroupId = null;
                if (cmdletContext.VpcConfig_SecurityGroupId != null)
                {
                    requestVpcConfig_vpcConfig_SecurityGroupId = cmdletContext.VpcConfig_SecurityGroupId;
                }
                if (requestVpcConfig_vpcConfig_SecurityGroupId != null)
                {
                    request.VpcConfig.SecurityGroupIds = requestVpcConfig_vpcConfig_SecurityGroupId;
                    requestVpcConfigIsNull             = false;
                }
                List <System.String> requestVpcConfig_vpcConfig_SubnetId = null;
                if (cmdletContext.VpcConfig_SubnetId != null)
                {
                    requestVpcConfig_vpcConfig_SubnetId = cmdletContext.VpcConfig_SubnetId;
                }
                if (requestVpcConfig_vpcConfig_SubnetId != null)
                {
                    request.VpcConfig.SubnetIds = requestVpcConfig_vpcConfig_SubnetId;
                    requestVpcConfigIsNull      = false;
                }
                // determine if request.VpcConfig should be set to null
                if (requestVpcConfigIsNull)
                {
                    request.VpcConfig = null;
                }

                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 (_Code_ZipFileStream != null)
                {
                    _Code_ZipFileStream.Dispose();
                }
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateFunction operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateFunction operation on AmazonLambdaClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateFunction
        ///         operation.</returns>
        public IAsyncResult BeginCreateFunction(CreateFunctionRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CreateFunctionRequestMarshaller();
            var unmarshaller = CreateFunctionResponseUnmarshaller.Instance;

            return BeginInvoke<CreateFunctionRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Example #6
0
 /// <summary>
 /// Initiates the asynchronous execution of the CreateFunction operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the CreateFunction operation on AmazonLambdaClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void CreateFunctionAsync(CreateFunctionRequest request, AmazonServiceCallback<CreateFunctionRequest, CreateFunctionResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new CreateFunctionRequestMarshaller();
     var unmarshaller = CreateFunctionResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<CreateFunctionRequest,CreateFunctionResponse> responseObject 
                     = new AmazonServiceResult<CreateFunctionRequest,CreateFunctionResponse>((CreateFunctionRequest)req, (CreateFunctionResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<CreateFunctionRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }