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

com.ksc.network.slb.model.transform.CreateLoadBalancerRequestMarshaller 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.network.slb.model.CreateLoadBalancerRequest;
import com.ksc.transform.Marshaller;
import com.ksc.util.StringUtils;

/**
 * Created by LIUHONGMING on 2017/4/21.
 */
public class CreateLoadBalancerRequestMarshaller implements
        Marshaller, CreateLoadBalancerRequest> {

    @Override
    public Request marshall(
            CreateLoadBalancerRequest createLoadBalancerRequest) {

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

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

        if (!StringUtils.isNullOrEmpty(createLoadBalancerRequest.getVpcId())) {
            request.addParameter("VpcId", createLoadBalancerRequest.getVpcId());
        }

        if (!StringUtils.isNullOrEmpty(createLoadBalancerRequest.getLoadBalancerName())) {
            request.addParameter("LoadBalancerName", createLoadBalancerRequest.getLoadBalancerName());
        }

        if (!StringUtils.isNullOrEmpty(createLoadBalancerRequest.getType())) {
            request.addParameter("Type", createLoadBalancerRequest.getType());
        }

        if (!StringUtils.isNullOrEmpty(createLoadBalancerRequest.getSubnetId())) {
            request.addParameter("SubnetId", createLoadBalancerRequest.getSubnetId());
        }

        return request;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy