software.amazon.awssdk.services.protocolrestxml.transform.MultiLocationOperationRequestMarshaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocol-tests Show documentation
Show all versions of protocol-tests Show documentation
Contains functional tests for all supported protocols.
/*
* Copyright 2013-2018 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 software.amazon.awssdk.services.protocolrestxml.transform;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.io.StringWriter;
import javax.annotation.Generated;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.Request;
import software.amazon.awssdk.core.DefaultRequest;
import software.amazon.awssdk.core.http.HttpMethodName;
import software.amazon.awssdk.services.protocolrestxml.model.*;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.utils.StringInputStream;
import software.amazon.awssdk.core.util.StringConversion;
import software.amazon.awssdk.core.util.xml.XmlWriter;
/**
* MultiLocationOperationRequest Marshaller
*/
@Generated("software.amazon.awssdk:aws-java-sdk-code-generator")
public class MultiLocationOperationRequestMarshaller implements
Marshaller, MultiLocationOperationRequest> {
public Request marshall(MultiLocationOperationRequest multiLocationOperationRequest) {
if (multiLocationOperationRequest == null) {
throw SdkClientException.builder().message("Invalid argument passed to marshall(...)").build();
}
Request request = new DefaultRequest(
multiLocationOperationRequest, "ProtocolRestXmlClient");
request.setHttpMethod(HttpMethodName.POST);
if (multiLocationOperationRequest.stringHeaderMember() != null) {
request.addHeader("x-amz-header-string",
StringConversion.fromString(multiLocationOperationRequest.stringHeaderMember()));
}
if (multiLocationOperationRequest.timestampHeaderMember() != null) {
request.addHeader("x-amz-timearg",
StringConversion.fromInstant(multiLocationOperationRequest.timestampHeaderMember()));
}
String uriResourcePath = "/2016-03-11/multiLocationOperation/{PathParam}";
uriResourcePath = software.amazon.awssdk.core.runtime.transform.PathMarshaller.NON_GREEDY.marshall(uriResourcePath,
"PathParam", multiLocationOperationRequest.pathParam());
request.setResourcePath(uriResourcePath);
if (multiLocationOperationRequest.queryParamOne() != null) {
request.addParameter("QueryParamOne", StringConversion.fromString(multiLocationOperationRequest.queryParamOne()));
}
if (multiLocationOperationRequest.queryParamTwo() != null) {
request.addParameter("QueryParamTwo", StringConversion.fromString(multiLocationOperationRequest.queryParamTwo()));
}
try {
StringWriter stringWriter = new StringWriter();
XmlWriter xmlWriter = new XmlWriter(stringWriter, "https://restxml/");
xmlWriter.startElement("MultiLocationOperationRequest");
PayloadStructType payloadStructParam = multiLocationOperationRequest.payloadStructParam();
if (payloadStructParam != null) {
xmlWriter.startElement("PayloadStructParam");
if (payloadStructParam.payloadMemberOne() != null) {
xmlWriter.startElement("PayloadMemberOne").value(payloadStructParam.payloadMemberOne()).endElement();
}
if (payloadStructParam.payloadMemberTwo() != null) {
xmlWriter.startElement("PayloadMemberTwo").value(payloadStructParam.payloadMemberTwo()).endElement();
}
xmlWriter.endElement();
}
xmlWriter.endElement();
request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF_8).length));
if (!request.getHeaders().containsKey("Content-Type")) {
request.addHeader("Content-Type", "application/xml");
}
} catch (Throwable t) {
throw SdkClientException.builder().message("Unable to marshall request to XML: " + t.getMessage()).cause(t).build();
}
return request;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy