Exemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SimpleEmailV2.Model.SendBulkEmailRequest();

            if (cmdletContext.BulkEmailEntry != null)
            {
                request.BulkEmailEntries = cmdletContext.BulkEmailEntry;
            }
            if (cmdletContext.ConfigurationSetName != null)
            {
                request.ConfigurationSetName = cmdletContext.ConfigurationSetName;
            }

            // populate DefaultContent
            var requestDefaultContentIsNull = true;

            request.DefaultContent = new Amazon.SimpleEmailV2.Model.BulkEmailContent();
            Amazon.SimpleEmailV2.Model.Template requestDefaultContent_defaultContent_Template = null;

            // populate Template
            var requestDefaultContent_defaultContent_TemplateIsNull = true;

            requestDefaultContent_defaultContent_Template = new Amazon.SimpleEmailV2.Model.Template();
            System.String requestDefaultContent_defaultContent_Template_template_TemplateArn = null;
            if (cmdletContext.Template_TemplateArn != null)
            {
                requestDefaultContent_defaultContent_Template_template_TemplateArn = cmdletContext.Template_TemplateArn;
            }
            if (requestDefaultContent_defaultContent_Template_template_TemplateArn != null)
            {
                requestDefaultContent_defaultContent_Template.TemplateArn = requestDefaultContent_defaultContent_Template_template_TemplateArn;
                requestDefaultContent_defaultContent_TemplateIsNull       = false;
            }
            System.String requestDefaultContent_defaultContent_Template_template_TemplateData = null;
            if (cmdletContext.Template_TemplateData != null)
            {
                requestDefaultContent_defaultContent_Template_template_TemplateData = cmdletContext.Template_TemplateData;
            }
            if (requestDefaultContent_defaultContent_Template_template_TemplateData != null)
            {
                requestDefaultContent_defaultContent_Template.TemplateData = requestDefaultContent_defaultContent_Template_template_TemplateData;
                requestDefaultContent_defaultContent_TemplateIsNull        = false;
            }
            System.String requestDefaultContent_defaultContent_Template_template_TemplateName = null;
            if (cmdletContext.Template_TemplateName != null)
            {
                requestDefaultContent_defaultContent_Template_template_TemplateName = cmdletContext.Template_TemplateName;
            }
            if (requestDefaultContent_defaultContent_Template_template_TemplateName != null)
            {
                requestDefaultContent_defaultContent_Template.TemplateName = requestDefaultContent_defaultContent_Template_template_TemplateName;
                requestDefaultContent_defaultContent_TemplateIsNull        = false;
            }
            // determine if requestDefaultContent_defaultContent_Template should be set to null
            if (requestDefaultContent_defaultContent_TemplateIsNull)
            {
                requestDefaultContent_defaultContent_Template = null;
            }
            if (requestDefaultContent_defaultContent_Template != null)
            {
                request.DefaultContent.Template = requestDefaultContent_defaultContent_Template;
                requestDefaultContentIsNull     = false;
            }
            // determine if request.DefaultContent should be set to null
            if (requestDefaultContentIsNull)
            {
                request.DefaultContent = null;
            }
            if (cmdletContext.DefaultEmailTag != null)
            {
                request.DefaultEmailTags = cmdletContext.DefaultEmailTag;
            }
            if (cmdletContext.FeedbackForwardingEmailAddress != null)
            {
                request.FeedbackForwardingEmailAddress = cmdletContext.FeedbackForwardingEmailAddress;
            }
            if (cmdletContext.FeedbackForwardingEmailAddressIdentityArn != null)
            {
                request.FeedbackForwardingEmailAddressIdentityArn = cmdletContext.FeedbackForwardingEmailAddressIdentityArn;
            }
            if (cmdletContext.FromEmailAddress != null)
            {
                request.FromEmailAddress = cmdletContext.FromEmailAddress;
            }
            if (cmdletContext.FromEmailAddressIdentityArn != null)
            {
                request.FromEmailAddressIdentityArn = cmdletContext.FromEmailAddressIdentityArn;
            }
            if (cmdletContext.ReplyToAddress != null)
            {
                request.ReplyToAddresses = cmdletContext.ReplyToAddress;
            }

            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);
        }
Exemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            System.IO.MemoryStream _Raw_DataStream = null;

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

                if (cmdletContext.ConfigurationSetName != null)
                {
                    request.ConfigurationSetName = cmdletContext.ConfigurationSetName;
                }

                // populate Content
                var requestContentIsNull = true;
                request.Content = new Amazon.SimpleEmailV2.Model.EmailContent();
                Amazon.SimpleEmailV2.Model.RawMessage requestContent_content_Raw = null;

                // populate Raw
                var requestContent_content_RawIsNull = true;
                requestContent_content_Raw = new Amazon.SimpleEmailV2.Model.RawMessage();
                System.IO.MemoryStream requestContent_content_Raw_raw_Data = null;
                if (cmdletContext.Raw_Data != null)
                {
                    _Raw_DataStream = new System.IO.MemoryStream(cmdletContext.Raw_Data);
                    requestContent_content_Raw_raw_Data = _Raw_DataStream;
                }
                if (requestContent_content_Raw_raw_Data != null)
                {
                    requestContent_content_Raw.Data  = requestContent_content_Raw_raw_Data;
                    requestContent_content_RawIsNull = false;
                }
                // determine if requestContent_content_Raw should be set to null
                if (requestContent_content_RawIsNull)
                {
                    requestContent_content_Raw = null;
                }
                if (requestContent_content_Raw != null)
                {
                    request.Content.Raw  = requestContent_content_Raw;
                    requestContentIsNull = false;
                }
                Amazon.SimpleEmailV2.Model.Message requestContent_content_Simple = null;

                // populate Simple
                var requestContent_content_SimpleIsNull = true;
                requestContent_content_Simple = new Amazon.SimpleEmailV2.Model.Message();
                Amazon.SimpleEmailV2.Model.Body requestContent_content_Simple_content_Simple_Body = null;

                // populate Body
                var requestContent_content_Simple_content_Simple_BodyIsNull = true;
                requestContent_content_Simple_content_Simple_Body = new Amazon.SimpleEmailV2.Model.Body();
                Amazon.SimpleEmailV2.Model.Content requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html = null;

                // populate Html
                var requestContent_content_Simple_content_Simple_Body_content_Simple_Body_HtmlIsNull = true;
                requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html = new Amazon.SimpleEmailV2.Model.Content();
                System.String requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Charset = null;
                if (cmdletContext.Html_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Charset = cmdletContext.Html_Charset;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html.Charset = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Charset;
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_HtmlIsNull   = false;
                }
                System.String requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Data = null;
                if (cmdletContext.Html_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Data = cmdletContext.Html_Data;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html.Data  = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html_html_Data;
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_HtmlIsNull = false;
                }
                // determine if requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html should be set to null
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_HtmlIsNull)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html = null;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html != null)
                {
                    requestContent_content_Simple_content_Simple_Body.Html  = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Html;
                    requestContent_content_Simple_content_Simple_BodyIsNull = false;
                }
                Amazon.SimpleEmailV2.Model.Content requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text = null;

                // populate Text
                var requestContent_content_Simple_content_Simple_Body_content_Simple_Body_TextIsNull = true;
                requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text = new Amazon.SimpleEmailV2.Model.Content();
                System.String requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Charset = null;
                if (cmdletContext.Text_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Charset = cmdletContext.Text_Charset;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text.Charset = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Charset;
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_TextIsNull   = false;
                }
                System.String requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Data = null;
                if (cmdletContext.Text_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Data = cmdletContext.Text_Data;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text.Data  = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text_text_Data;
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_TextIsNull = false;
                }
                // determine if requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text should be set to null
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_TextIsNull)
                {
                    requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text = null;
                }
                if (requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text != null)
                {
                    requestContent_content_Simple_content_Simple_Body.Text  = requestContent_content_Simple_content_Simple_Body_content_Simple_Body_Text;
                    requestContent_content_Simple_content_Simple_BodyIsNull = false;
                }
                // determine if requestContent_content_Simple_content_Simple_Body should be set to null
                if (requestContent_content_Simple_content_Simple_BodyIsNull)
                {
                    requestContent_content_Simple_content_Simple_Body = null;
                }
                if (requestContent_content_Simple_content_Simple_Body != null)
                {
                    requestContent_content_Simple.Body  = requestContent_content_Simple_content_Simple_Body;
                    requestContent_content_SimpleIsNull = false;
                }
                Amazon.SimpleEmailV2.Model.Content requestContent_content_Simple_content_Simple_Subject = null;

                // populate Subject
                var requestContent_content_Simple_content_Simple_SubjectIsNull = true;
                requestContent_content_Simple_content_Simple_Subject = new Amazon.SimpleEmailV2.Model.Content();
                System.String requestContent_content_Simple_content_Simple_Subject_subject_Charset = null;
                if (cmdletContext.Subject_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Subject_subject_Charset = cmdletContext.Subject_Charset;
                }
                if (requestContent_content_Simple_content_Simple_Subject_subject_Charset != null)
                {
                    requestContent_content_Simple_content_Simple_Subject.Charset = requestContent_content_Simple_content_Simple_Subject_subject_Charset;
                    requestContent_content_Simple_content_Simple_SubjectIsNull   = false;
                }
                System.String requestContent_content_Simple_content_Simple_Subject_subject_Data = null;
                if (cmdletContext.Subject_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Subject_subject_Data = cmdletContext.Subject_Data;
                }
                if (requestContent_content_Simple_content_Simple_Subject_subject_Data != null)
                {
                    requestContent_content_Simple_content_Simple_Subject.Data  = requestContent_content_Simple_content_Simple_Subject_subject_Data;
                    requestContent_content_Simple_content_Simple_SubjectIsNull = false;
                }
                // determine if requestContent_content_Simple_content_Simple_Subject should be set to null
                if (requestContent_content_Simple_content_Simple_SubjectIsNull)
                {
                    requestContent_content_Simple_content_Simple_Subject = null;
                }
                if (requestContent_content_Simple_content_Simple_Subject != null)
                {
                    requestContent_content_Simple.Subject = requestContent_content_Simple_content_Simple_Subject;
                    requestContent_content_SimpleIsNull   = false;
                }
                // determine if requestContent_content_Simple should be set to null
                if (requestContent_content_SimpleIsNull)
                {
                    requestContent_content_Simple = null;
                }
                if (requestContent_content_Simple != null)
                {
                    request.Content.Simple = requestContent_content_Simple;
                    requestContentIsNull   = false;
                }
                Amazon.SimpleEmailV2.Model.Template requestContent_content_Template = null;

                // populate Template
                var requestContent_content_TemplateIsNull = true;
                requestContent_content_Template = new Amazon.SimpleEmailV2.Model.Template();
                System.String requestContent_content_Template_template_TemplateArn = null;
                if (cmdletContext.Template_TemplateArn != null)
                {
                    requestContent_content_Template_template_TemplateArn = cmdletContext.Template_TemplateArn;
                }
                if (requestContent_content_Template_template_TemplateArn != null)
                {
                    requestContent_content_Template.TemplateArn = requestContent_content_Template_template_TemplateArn;
                    requestContent_content_TemplateIsNull       = false;
                }
                System.String requestContent_content_Template_template_TemplateData = null;
                if (cmdletContext.Template_TemplateData != null)
                {
                    requestContent_content_Template_template_TemplateData = cmdletContext.Template_TemplateData;
                }
                if (requestContent_content_Template_template_TemplateData != null)
                {
                    requestContent_content_Template.TemplateData = requestContent_content_Template_template_TemplateData;
                    requestContent_content_TemplateIsNull        = false;
                }
                // determine if requestContent_content_Template should be set to null
                if (requestContent_content_TemplateIsNull)
                {
                    requestContent_content_Template = null;
                }
                if (requestContent_content_Template != null)
                {
                    request.Content.Template = requestContent_content_Template;
                    requestContentIsNull     = false;
                }
                // determine if request.Content should be set to null
                if (requestContentIsNull)
                {
                    request.Content = null;
                }

                // populate Destination
                var requestDestinationIsNull = true;
                request.Destination = new Amazon.SimpleEmailV2.Model.Destination();
                List <System.String> requestDestination_destination_BccAddress = null;
                if (cmdletContext.Destination_BccAddress != null)
                {
                    requestDestination_destination_BccAddress = cmdletContext.Destination_BccAddress;
                }
                if (requestDestination_destination_BccAddress != null)
                {
                    request.Destination.BccAddresses = requestDestination_destination_BccAddress;
                    requestDestinationIsNull         = false;
                }
                List <System.String> requestDestination_destination_CcAddress = null;
                if (cmdletContext.Destination_CcAddress != null)
                {
                    requestDestination_destination_CcAddress = cmdletContext.Destination_CcAddress;
                }
                if (requestDestination_destination_CcAddress != null)
                {
                    request.Destination.CcAddresses = requestDestination_destination_CcAddress;
                    requestDestinationIsNull        = false;
                }
                List <System.String> requestDestination_destination_ToAddress = null;
                if (cmdletContext.Destination_ToAddress != null)
                {
                    requestDestination_destination_ToAddress = cmdletContext.Destination_ToAddress;
                }
                if (requestDestination_destination_ToAddress != null)
                {
                    request.Destination.ToAddresses = requestDestination_destination_ToAddress;
                    requestDestinationIsNull        = false;
                }
                // determine if request.Destination should be set to null
                if (requestDestinationIsNull)
                {
                    request.Destination = null;
                }
                if (cmdletContext.EmailTag != null)
                {
                    request.EmailTags = cmdletContext.EmailTag;
                }
                if (cmdletContext.FeedbackForwardingEmailAddress != null)
                {
                    request.FeedbackForwardingEmailAddress = cmdletContext.FeedbackForwardingEmailAddress;
                }
                if (cmdletContext.FromEmailAddress != null)
                {
                    request.FromEmailAddress = cmdletContext.FromEmailAddress;
                }
                if (cmdletContext.ReplyToAddress != null)
                {
                    request.ReplyToAddresses = cmdletContext.ReplyToAddress;
                }

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