/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(EC2TagFilter eC2TagFilter, JSONWriter jsonWriter) { if (eC2TagFilter == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (eC2TagFilter.getKey() != null) { jsonWriter.key("Key").value(eC2TagFilter.getKey()); } if (eC2TagFilter.getValue() != null) { jsonWriter.key("Value").value(eC2TagFilter.getValue()); } if (eC2TagFilter.getType() != null) { jsonWriter.key("Type").value(eC2TagFilter.getType()); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<DeleteDeploymentConfigRequest> marshall( DeleteDeploymentConfigRequest deleteDeploymentConfigRequest) { if (deleteDeploymentConfigRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<DeleteDeploymentConfigRequest> request = new DefaultRequest<DeleteDeploymentConfigRequest>( deleteDeploymentConfigRequest, "AmazonCodeDeploy"); request.addHeader("X-Amz-Target", "CodeDeploy_20141006.DeleteDeploymentConfig"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (deleteDeploymentConfigRequest.getDeploymentConfigName() != null) { jsonWriter .key("deploymentConfigName") .value(deleteDeploymentConfigRequest.getDeploymentConfigName()); } jsonWriter.endObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", "application/x-amz-json-1.1"); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }