com.ksyun.api.sdk.kec.transform.DescribeInstancesRequestMarshaller Maven / Gradle / Ivy
package com.ksyun.api.sdk.kec.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.DescribeInstancesRequest;
/**
* DescribeInstancesRequest Marshaller
*/
public class DescribeInstancesRequestMarshaller implements
Marshaller, DescribeInstancesRequest> {
public Request marshall(
DescribeInstancesRequest describeInstancesRequest) {
if (describeInstancesRequest == null) {
throw new KscClientException(
"Invalid argument passed to marshall(...)");
}
Request request = new DefaultRequest(
describeInstancesRequest, "kec");
request.addParameter("Action", "DescribeInstances");
String version=describeInstancesRequest.getVersion();
if(StringUtils.isNullOrEmpty(version)){
version="2016-03-04";
}
request.addParameter("Version", version);
request.setHttpMethod(HttpMethodName.GET);
com.ksc.internal.SdkInternalList instanceIdsList = (com.ksc.internal.SdkInternalList) describeInstancesRequest
.getInstanceIds();
if (!instanceIdsList.isEmpty() || !instanceIdsList.isAutoConstruct()) {
int instanceIdsListIndex = 1;
for (String instanceIdsListValue : instanceIdsList) {
if (instanceIdsListValue != null) {
request.addParameter("InstanceId." + instanceIdsListIndex,
StringUtils.fromString(instanceIdsListValue));
}
instanceIdsListIndex++;
}
}
com.ksc.internal.SdkInternalList filtersList = (com.ksc.internal.SdkInternalList) describeInstancesRequest
.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++;
}
}
if (describeInstancesRequest.getNextToken() != null) {
request.addParameter("NextToken", StringUtils
.fromString(describeInstancesRequest.getNextToken()));
}
if (describeInstancesRequest.getMaxResults() != null) {
request.addParameter("MaxResults", StringUtils
.fromInteger(describeInstancesRequest.getMaxResults()));
}
if (describeInstancesRequest.getMarker() != null) {
request.addParameter("Marker", StringUtils
.fromInteger(describeInstancesRequest.getMarker()));
}
if (describeInstancesRequest.getSearch() != null) {
request.addParameter("Search", StringUtils
.fromString(describeInstancesRequest.getSearch()));
}
return request;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy