/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(ApiKey apiKey, JSONWriter jsonWriter) { if (apiKey == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (apiKey.getId() != null) { jsonWriter.key("id").value(apiKey.getId()); } if (apiKey.getName() != null) { jsonWriter.key("name").value(apiKey.getName()); } if (apiKey.getDescription() != null) { jsonWriter.key("description").value(apiKey.getDescription()); } if (apiKey.getEnabled() != null) { jsonWriter.key("enabled").value(apiKey.getEnabled()); } java.util.List<String> stageKeysList = apiKey.getStageKeys(); if (stageKeysList != null) { jsonWriter.key("stageKeys"); jsonWriter.array(); for (String stageKeysListValue : stageKeysList) { if (stageKeysListValue != null) { jsonWriter.value(stageKeysListValue); } } jsonWriter.endArray(); } if (apiKey.getCreatedDate() != null) { jsonWriter.key("createdDate").value(apiKey.getCreatedDate()); } if (apiKey.getLastUpdatedDate() != null) { jsonWriter.key("lastUpdatedDate").value(apiKey.getLastUpdatedDate()); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
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; }