All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.services.simpleemail.model.transform.CreateReceiptRuleRequestMarshaller Maven / Gradle / Ivy

Go to download

The AWS SDK for Java with support for OSGi. The AWS SDK for Java provides Java APIs for building software on AWS' cost-effective, scalable, and reliable infrastructure products. The AWS Java SDK allows developers to code against APIs for all of Amazon's infrastructure web services (Amazon S3, Amazon EC2, Amazon SQS, Amazon Relational Database Service, Amazon AutoScaling, etc).

There is a newer version: 1.11.60
Show newest version
/*
 * Copyright 2011-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not
 * use this file except in compliance with the License. A copy of the License is
 * located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.amazonaws.services.simpleemail.model.transform;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.amazonaws.AmazonClientException;
import com.amazonaws.Request;
import com.amazonaws.DefaultRequest;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.services.simpleemail.model.*;
import com.amazonaws.transform.Marshaller;
import com.amazonaws.util.StringUtils;
import com.amazonaws.util.IdempotentUtils;

/**
 * CreateReceiptRuleRequest Marshaller
 */

public class CreateReceiptRuleRequestMarshaller implements
        Marshaller, CreateReceiptRuleRequest> {

    public Request marshall(
            CreateReceiptRuleRequest createReceiptRuleRequest) {

        if (createReceiptRuleRequest == null) {
            throw new AmazonClientException(
                    "Invalid argument passed to marshall(...)");
        }

        Request request = new DefaultRequest(
                createReceiptRuleRequest, "AmazonSimpleEmailService");
        request.addParameter("Action", "CreateReceiptRule");
        request.addParameter("Version", "2010-12-01");
        request.setHttpMethod(HttpMethodName.POST);

        if (createReceiptRuleRequest.getRuleSetName() != null) {
            request.addParameter("RuleSetName", StringUtils
                    .fromString(createReceiptRuleRequest.getRuleSetName()));
        }

        if (createReceiptRuleRequest.getAfter() != null) {
            request.addParameter("After",
                    StringUtils.fromString(createReceiptRuleRequest.getAfter()));
        }

        ReceiptRule rule = createReceiptRuleRequest.getRule();
        if (rule != null) {

            if (rule.getName() != null) {
                request.addParameter("Rule.Name",
                        StringUtils.fromString(rule.getName()));
            }

            if (rule.getEnabled() != null) {
                request.addParameter("Rule.Enabled",
                        StringUtils.fromBoolean(rule.getEnabled()));
            }

            if (rule.getTlsPolicy() != null) {
                request.addParameter("Rule.TlsPolicy",
                        StringUtils.fromString(rule.getTlsPolicy()));
            }

            com.amazonaws.internal.SdkInternalList recipientsList = (com.amazonaws.internal.SdkInternalList) rule
                    .getRecipients();
            if (!recipientsList.isEmpty() || !recipientsList.isAutoConstruct()) {
                int recipientsListIndex = 1;

                for (String recipientsListValue : recipientsList) {
                    if (recipientsListValue != null) {
                        request.addParameter("Rule.Recipients.member."
                                + recipientsListIndex,
                                StringUtils.fromString(recipientsListValue));
                    }
                    recipientsListIndex++;
                }
            }

            com.amazonaws.internal.SdkInternalList actionsList = (com.amazonaws.internal.SdkInternalList) rule
                    .getActions();
            if (!actionsList.isEmpty() || !actionsList.isAutoConstruct()) {
                int actionsListIndex = 1;

                for (ReceiptAction actionsListValue : actionsList) {

                    S3Action s3Action = actionsListValue.getS3Action();
                    if (s3Action != null) {

                        if (s3Action.getTopicArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex + ".S3Action.TopicArn",
                                    StringUtils.fromString(s3Action
                                            .getTopicArn()));
                        }

                        if (s3Action.getBucketName() != null) {
                            request.addParameter(
                                    "Rule.Actions.member." + actionsListIndex
                                            + ".S3Action.BucketName",
                                    StringUtils.fromString(s3Action
                                            .getBucketName()));
                        }

                        if (s3Action.getObjectKeyPrefix() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".S3Action.ObjectKeyPrefix", StringUtils
                                    .fromString(s3Action.getObjectKeyPrefix()));
                        }

                        if (s3Action.getKmsKeyArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex + ".S3Action.KmsKeyArn",
                                    StringUtils.fromString(s3Action
                                            .getKmsKeyArn()));
                        }
                    }

                    BounceAction bounceAction = actionsListValue
                            .getBounceAction();
                    if (bounceAction != null) {

                        if (bounceAction.getTopicArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".BounceAction.TopicArn", StringUtils
                                    .fromString(bounceAction.getTopicArn()));
                        }

                        if (bounceAction.getSmtpReplyCode() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".BounceAction.SmtpReplyCode",
                                    StringUtils.fromString(bounceAction
                                            .getSmtpReplyCode()));
                        }

                        if (bounceAction.getStatusCode() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".BounceAction.StatusCode", StringUtils
                                    .fromString(bounceAction.getStatusCode()));
                        }

                        if (bounceAction.getMessage() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".BounceAction.Message", StringUtils
                                    .fromString(bounceAction.getMessage()));
                        }

                        if (bounceAction.getSender() != null) {
                            request.addParameter(
                                    "Rule.Actions.member." + actionsListIndex
                                            + ".BounceAction.Sender",
                                    StringUtils.fromString(bounceAction
                                            .getSender()));
                        }
                    }

                    WorkmailAction workmailAction = actionsListValue
                            .getWorkmailAction();
                    if (workmailAction != null) {

                        if (workmailAction.getTopicArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".WorkmailAction.TopicArn", StringUtils
                                    .fromString(workmailAction.getTopicArn()));
                        }

                        if (workmailAction.getOrganizationArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".WorkmailAction.OrganizationArn",
                                    StringUtils.fromString(workmailAction
                                            .getOrganizationArn()));
                        }
                    }

                    LambdaAction lambdaAction = actionsListValue
                            .getLambdaAction();
                    if (lambdaAction != null) {

                        if (lambdaAction.getTopicArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".LambdaAction.TopicArn", StringUtils
                                    .fromString(lambdaAction.getTopicArn()));
                        }

                        if (lambdaAction.getFunctionArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".LambdaAction.FunctionArn", StringUtils
                                    .fromString(lambdaAction.getFunctionArn()));
                        }

                        if (lambdaAction.getInvocationType() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".LambdaAction.InvocationType",
                                    StringUtils.fromString(lambdaAction
                                            .getInvocationType()));
                        }
                    }

                    StopAction stopAction = actionsListValue.getStopAction();
                    if (stopAction != null) {

                        if (stopAction.getScope() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex + ".StopAction.Scope",
                                    StringUtils.fromString(stopAction
                                            .getScope()));
                        }

                        if (stopAction.getTopicArn() != null) {
                            request.addParameter(
                                    "Rule.Actions.member." + actionsListIndex
                                            + ".StopAction.TopicArn",
                                    StringUtils.fromString(stopAction
                                            .getTopicArn()));
                        }
                    }

                    AddHeaderAction addHeaderAction = actionsListValue
                            .getAddHeaderAction();
                    if (addHeaderAction != null) {

                        if (addHeaderAction.getHeaderName() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".AddHeaderAction.HeaderName",
                                    StringUtils.fromString(addHeaderAction
                                            .getHeaderName()));
                        }

                        if (addHeaderAction.getHeaderValue() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex
                                    + ".AddHeaderAction.HeaderValue",
                                    StringUtils.fromString(addHeaderAction
                                            .getHeaderValue()));
                        }
                    }

                    SNSAction sNSAction = actionsListValue.getSNSAction();
                    if (sNSAction != null) {

                        if (sNSAction.getTopicArn() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex + ".SNSAction.TopicArn",
                                    StringUtils.fromString(sNSAction
                                            .getTopicArn()));
                        }

                        if (sNSAction.getEncoding() != null) {
                            request.addParameter("Rule.Actions.member."
                                    + actionsListIndex + ".SNSAction.Encoding",
                                    StringUtils.fromString(sNSAction
                                            .getEncoding()));
                        }
                    }
                    actionsListIndex++;
                }
            }

            if (rule.getScanEnabled() != null) {
                request.addParameter("Rule.ScanEnabled",
                        StringUtils.fromBoolean(rule.getScanEnabled()));
            }
        }

        return request;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy