Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Lambda.Model.UpdateFunctionConfigurationRequest();


            // 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;
            }
            if (cmdletContext.KMSKeyArn != null)
            {
                request.KMSKeyArn = cmdletContext.KMSKeyArn;
            }
            if (cmdletContext.Layer != null)
            {
                request.Layers = cmdletContext.Layer;
            }
            if (cmdletContext.IsLayersSet != null)
            {
                request.IsLayersSet = cmdletContext.IsLayersSet.Value;
            }
            if (cmdletContext.MemorySize != null)
            {
                request.MemorySize = cmdletContext.MemorySize.Value;
            }
            if (cmdletContext.RevisionId != null)
            {
                request.RevisionId = cmdletContext.RevisionId;
            }
            if (cmdletContext.Role != null)
            {
                request.Role = cmdletContext.Role;
            }
            if (cmdletContext.Runtime != null)
            {
                request.Runtime = cmdletContext.Runtime;
            }
            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);
        }