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

com.ksc.network.eip.model.transform.DescribeAddressesRequestMarshaller Maven / Gradle / Ivy

There is a newer version: 2.1.8
Show newest version
package com.ksc.network.eip.model.transform;

import com.ksc.DefaultRequest;
import com.ksc.KscClientException;
import com.ksc.Request;
import com.ksc.http.HttpMethodName;
import com.ksc.model.Filter;
import com.ksc.transform.Marshaller;
import com.ksc.util.StringUtils;
import com.ksyun.api.sdk.kec.model.eip.DescribeAddressesRequest;

/**
 * DescribeAddressesRequest Marshaller
 */

public class DescribeAddressesRequestMarshaller implements
        Marshaller, DescribeAddressesRequest> {

    public Request marshall(
            DescribeAddressesRequest describeAddressesRequest) {

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

        Request request = new DefaultRequest(
                describeAddressesRequest, "eip");
        request.addParameter("Action", "DescribeAddresses");
        String version=describeAddressesRequest.getVersion();
        if(StringUtils.isNullOrEmpty(version)){
        	version="2016-03-04";
        }
        request.addParameter("Version", version);
        request.setHttpMethod(HttpMethodName.GET);

        com.ksc.internal.SdkInternalList filtersList = (com.ksc.internal.SdkInternalList) describeAddressesRequest
                .getFilters();
        if (!filtersList.isEmpty() || !filtersList.isAutoConstruct()) {
            int filtersListIndex = 1;

            for (Filter filtersListValue : filtersList) {

                if (filtersListValue.getName() != null) {
                    request.addParameter(
                            "Filter." + filtersListIndex + ".Name",
                            StringUtils.fromString(filtersListValue.getName()));
                }

                com.ksc.internal.SdkInternalList valuesList = (com.ksc.internal.SdkInternalList) filtersListValue
                        .getValues();
                if (!valuesList.isEmpty() || !valuesList.isAutoConstruct()) {
                    int valuesListIndex = 1;

                    for (String valuesListValue : valuesList) {
                        if (valuesListValue != null) {
                            request.addParameter("Filter." + filtersListIndex
                                    + ".Value." + valuesListIndex,
                                    StringUtils.fromString(valuesListValue));
                        }
                        valuesListIndex++;
                    }
                }
                filtersListIndex++;
            }
        }

        com.ksc.internal.SdkInternalList allocationIdsList = (com.ksc.internal.SdkInternalList) describeAddressesRequest
                .getAllocationIds();
        if (!allocationIdsList.isEmpty()
                || !allocationIdsList.isAutoConstruct()) {
            int allocationIdsListIndex = 1;

            for (String allocationIdsListValue : allocationIdsList) {
                if (allocationIdsListValue != null) {
                    request.addParameter("AllocationId."
                            + allocationIdsListIndex,
                            StringUtils.fromString(allocationIdsListValue));
                }
                allocationIdsListIndex++;
            }
        }
        if (describeAddressesRequest.getNextToken() != null) {
            request.addParameter("NextToken", StringUtils
                    .fromString(describeAddressesRequest.getNextToken()));
        }

        if (describeAddressesRequest.getMaxResults() != null) {
            request.addParameter("MaxResults", StringUtils
                    .fromInteger(describeAddressesRequest.getMaxResults()));
        }
        return request;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy