public Request<UpdateMethodRequest> marshall(UpdateMethodRequest updateMethodRequest) { if (updateMethodRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<UpdateMethodRequest> request = new DefaultRequest<UpdateMethodRequest>(updateMethodRequest, "AmazonApiGateway"); request.setHttpMethod(HttpMethodName.PATCH); String uriResourcePath = "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}"; uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "restapi_id", updateMethodRequest.getRestApiId()); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "resource_id", updateMethodRequest.getResourceId()); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "http_method", updateMethodRequest.getHttpMethod()); request.setResourcePath(uriResourcePath); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); java.util.List<PatchOperation> patchOperationsList = updateMethodRequest.getPatchOperations(); if (patchOperationsList != null) { jsonGenerator.writeFieldName("patchOperations"); jsonGenerator.writeStartArray(); for (PatchOperation patchOperationsListValue : patchOperationsList) { if (patchOperationsListValue != null) { PatchOperationJsonMarshaller.getInstance() .marshall(patchOperationsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", protocolFactory.getContentType()); } } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
public Request<UpdateBasePathMappingRequest> marshall( UpdateBasePathMappingRequest updateBasePathMappingRequest) { if (updateBasePathMappingRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<UpdateBasePathMappingRequest> request = new DefaultRequest<UpdateBasePathMappingRequest>( updateBasePathMappingRequest, "AmazonApiGateway"); request.setHttpMethod(HttpMethodName.PATCH); String uriResourcePath = "/domainnames/{domain_name}/basepathmappings/{base_path}"; uriResourcePath = uriResourcePath.replace( "{domain_name}", (updateBasePathMappingRequest.getDomainName() == null) ? "" : StringUtils.fromString(updateBasePathMappingRequest.getDomainName())); uriResourcePath = uriResourcePath.replace( "{base_path}", (updateBasePathMappingRequest.getBasePath() == null) ? "" : StringUtils.fromString(updateBasePathMappingRequest.getBasePath())); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); java.util.List<PatchOperation> patchOperationsList = updateBasePathMappingRequest.getPatchOperations(); if (patchOperationsList != null) { jsonWriter.key("patchOperations"); jsonWriter.array(); for (PatchOperation patchOperationsListValue : patchOperationsList) { if (patchOperationsListValue != null) { PatchOperationJsonMarshaller.getInstance() .marshall(patchOperationsListValue, jsonWriter); } } jsonWriter.endArray(); } jsonWriter.endObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE); } } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }