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

com.ksc.network.slb.model.transform.DescribeLoadBalancersRequestMarshaller Maven / Gradle / Ivy

There is a newer version: 2.1.8
Show newest version
package com.ksc.network.slb.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.network.slb.model.DescribeLoadBalancersRequest;
import com.ksc.transform.Marshaller;
import com.ksc.util.StringUtils;

/**
 * DescribeLoadBalancersRequest Marshaller
 */
public class DescribeLoadBalancersRequestMarshaller
		implements Marshaller, DescribeLoadBalancersRequest> {

	@Override
	public Request marshall(DescribeLoadBalancersRequest describeLoadBalancersRequest) {
		if (describeLoadBalancersRequest == null) {
			throw new KscClientException("Invalid argument passed to marshall(...)");
		}

		Request request = new DefaultRequest(
				describeLoadBalancersRequest, "slb");
		request.addParameter("Action", "DescribeLoadBalancers");
		String version = describeLoadBalancersRequest.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) describeLoadBalancersRequest
				.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 lbIdsList = (com.ksc.internal.SdkInternalList) describeLoadBalancersRequest
				.getLoadBalancerIds();
		if (!lbIdsList.isEmpty() || !lbIdsList.isAutoConstruct()) {
			int lbIdsListIndex = 1;

			for (String lbIdsListValue : lbIdsList) {
				if (lbIdsListValue != null) {
					request.addParameter("LoadBalancerId." + lbIdsListIndex, StringUtils.fromString(lbIdsListValue));
				}
				lbIdsListIndex++;
			}
		}
		if (describeLoadBalancersRequest.getState() != null) {
			request.addParameter("State", StringUtils.fromString(describeLoadBalancersRequest.getState()));
		}
		return request;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy