public Request<GetEvaluationRequest> marshall(GetEvaluationRequest getEvaluationRequest) { if (getEvaluationRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<GetEvaluationRequest> request = new DefaultRequest<GetEvaluationRequest>(getEvaluationRequest, "AmazonMachineLearning"); request.addHeader("X-Amz-Target", "AmazonML_20141212.GetEvaluation"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (getEvaluationRequest.getEvaluationId() != null) { jsonWriter.key("EvaluationId").value(getEvaluationRequest.getEvaluationId()); } 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; }
public Request<DescribeDataSourcesRequest> marshall( DescribeDataSourcesRequest describeDataSourcesRequest) { if (describeDataSourcesRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<DescribeDataSourcesRequest> request = new DefaultRequest<DescribeDataSourcesRequest>( describeDataSourcesRequest, "AmazonMachineLearning"); request.addHeader("X-Amz-Target", "AmazonML_20141212.DescribeDataSources"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (describeDataSourcesRequest.getFilterVariable() != null) { jsonWriter.key("FilterVariable").value(describeDataSourcesRequest.getFilterVariable()); } if (describeDataSourcesRequest.getEQ() != null) { jsonWriter.key("EQ").value(describeDataSourcesRequest.getEQ()); } if (describeDataSourcesRequest.getGT() != null) { jsonWriter.key("GT").value(describeDataSourcesRequest.getGT()); } if (describeDataSourcesRequest.getLT() != null) { jsonWriter.key("LT").value(describeDataSourcesRequest.getLT()); } if (describeDataSourcesRequest.getGE() != null) { jsonWriter.key("GE").value(describeDataSourcesRequest.getGE()); } if (describeDataSourcesRequest.getLE() != null) { jsonWriter.key("LE").value(describeDataSourcesRequest.getLE()); } if (describeDataSourcesRequest.getNE() != null) { jsonWriter.key("NE").value(describeDataSourcesRequest.getNE()); } if (describeDataSourcesRequest.getPrefix() != null) { jsonWriter.key("Prefix").value(describeDataSourcesRequest.getPrefix()); } if (describeDataSourcesRequest.getSortOrder() != null) { jsonWriter.key("SortOrder").value(describeDataSourcesRequest.getSortOrder()); } if (describeDataSourcesRequest.getNextToken() != null) { jsonWriter.key("NextToken").value(describeDataSourcesRequest.getNextToken()); } if (describeDataSourcesRequest.getLimit() != null) { jsonWriter.key("Limit").value(describeDataSourcesRequest.getLimit()); } 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; }
/** Marshall the given parameter object, and output to a JSONWriter */ public void marshall(RDSDataSpec rDSDataSpec, JSONWriter jsonWriter) { if (rDSDataSpec == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonWriter.object(); if (rDSDataSpec.getDatabaseInformation() != null) { jsonWriter.key("DatabaseInformation"); RDSDatabaseJsonMarshaller.getInstance() .marshall(rDSDataSpec.getDatabaseInformation(), jsonWriter); } if (rDSDataSpec.getSelectSqlQuery() != null) { jsonWriter.key("SelectSqlQuery").value(rDSDataSpec.getSelectSqlQuery()); } if (rDSDataSpec.getDatabaseCredentials() != null) { jsonWriter.key("DatabaseCredentials"); RDSDatabaseCredentialsJsonMarshaller.getInstance() .marshall(rDSDataSpec.getDatabaseCredentials(), jsonWriter); } if (rDSDataSpec.getS3StagingLocation() != null) { jsonWriter.key("S3StagingLocation").value(rDSDataSpec.getS3StagingLocation()); } if (rDSDataSpec.getDataRearrangement() != null) { jsonWriter.key("DataRearrangement").value(rDSDataSpec.getDataRearrangement()); } if (rDSDataSpec.getDataSchema() != null) { jsonWriter.key("DataSchema").value(rDSDataSpec.getDataSchema()); } if (rDSDataSpec.getDataSchemaUri() != null) { jsonWriter.key("DataSchemaUri").value(rDSDataSpec.getDataSchemaUri()); } if (rDSDataSpec.getResourceRole() != null) { jsonWriter.key("ResourceRole").value(rDSDataSpec.getResourceRole()); } if (rDSDataSpec.getServiceRole() != null) { jsonWriter.key("ServiceRole").value(rDSDataSpec.getServiceRole()); } if (rDSDataSpec.getSubnetId() != null) { jsonWriter.key("SubnetId").value(rDSDataSpec.getSubnetId()); } com.amazonaws.internal.SdkInternalList<String> securityGroupIdsList = (com.amazonaws.internal.SdkInternalList<String>) rDSDataSpec.getSecurityGroupIds(); if (!securityGroupIdsList.isEmpty() || !securityGroupIdsList.isAutoConstruct()) { jsonWriter.key("SecurityGroupIds"); jsonWriter.array(); for (String securityGroupIdsListValue : securityGroupIdsList) { if (securityGroupIdsListValue != null) { jsonWriter.value(securityGroupIdsListValue); } } jsonWriter.endArray(); } jsonWriter.endObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }