public Request<CreateBranchRequest> marshall(CreateBranchRequest createBranchRequest) { if (createBranchRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateBranchRequest> request = new DefaultRequest<CreateBranchRequest>(createBranchRequest, "AWSCodeCommit"); request.addHeader("X-Amz-Target", "CodeCommit_20150413.CreateBranch"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { StringWriter stringWriter = new StringWriter(); JSONWriter jsonWriter = new JSONWriter(stringWriter); jsonWriter.object(); if (createBranchRequest.getRepositoryName() != null) { jsonWriter.key("repositoryName").value(createBranchRequest.getRepositoryName()); } if (createBranchRequest.getBranchName() != null) { jsonWriter.key("branchName").value(createBranchRequest.getBranchName()); } if (createBranchRequest.getCommitId() != null) { jsonWriter.key("commitId").value(createBranchRequest.getCommitId()); } 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<GetRepositoryTriggersRequest> marshall( GetRepositoryTriggersRequest getRepositoryTriggersRequest) { if (getRepositoryTriggersRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<GetRepositoryTriggersRequest> request = new DefaultRequest<GetRepositoryTriggersRequest>( getRepositoryTriggersRequest, "AWSCodeCommit"); request.addHeader("X-Amz-Target", "CodeCommit_20150413.GetRepositoryTriggers"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (getRepositoryTriggersRequest.getRepositoryName() != null) { jsonGenerator .writeFieldName("repositoryName") .writeValue(getRepositoryTriggersRequest.getRepositoryName()); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", protocolFactory.getContentType()); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }