public Request<TerminateProvisionedProductRequest> marshall( TerminateProvisionedProductRequest terminateProvisionedProductRequest) { if (terminateProvisionedProductRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<TerminateProvisionedProductRequest> request = new DefaultRequest<TerminateProvisionedProductRequest>( terminateProvisionedProductRequest, "AWSServiceCatalog"); request.addHeader("X-Amz-Target", "AWS242ServiceCatalogService.TerminateProvisionedProduct"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (terminateProvisionedProductRequest.getProvisionedProductName() != null) { jsonGenerator .writeFieldName("ProvisionedProductName") .writeValue(terminateProvisionedProductRequest.getProvisionedProductName()); } if (terminateProvisionedProductRequest.getProvisionedProductId() != null) { jsonGenerator .writeFieldName("ProvisionedProductId") .writeValue(terminateProvisionedProductRequest.getProvisionedProductId()); } jsonGenerator .writeFieldName("TerminateToken") .writeValue( IdempotentUtils.resolveString( terminateProvisionedProductRequest.getTerminateToken())); if (terminateProvisionedProductRequest.getIgnoreErrors() != null) { jsonGenerator .writeFieldName("IgnoreErrors") .writeValue(terminateProvisionedProductRequest.getIgnoreErrors()); } if (terminateProvisionedProductRequest.getAcceptLanguage() != null) { jsonGenerator .writeFieldName("AcceptLanguage") .writeValue(terminateProvisionedProductRequest.getAcceptLanguage()); } 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; }
public Request<PurchaseScheduledInstancesRequest> marshall( PurchaseScheduledInstancesRequest purchaseScheduledInstancesRequest) { if (purchaseScheduledInstancesRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<PurchaseScheduledInstancesRequest> request = new DefaultRequest<PurchaseScheduledInstancesRequest>( purchaseScheduledInstancesRequest, "AmazonEC2"); request.addParameter("Action", "PurchaseScheduledInstances"); request.addParameter("Version", "2016-11-15"); request.setHttpMethod(HttpMethodName.POST); request.addParameter( "ClientToken", IdempotentUtils.resolveString(purchaseScheduledInstancesRequest.getClientToken())); com.amazonaws.internal.SdkInternalList<PurchaseRequest> purchaseScheduledInstancesRequestPurchaseRequestsList = (com.amazonaws.internal.SdkInternalList<PurchaseRequest>) purchaseScheduledInstancesRequest.getPurchaseRequests(); if (!purchaseScheduledInstancesRequestPurchaseRequestsList.isEmpty() || !purchaseScheduledInstancesRequestPurchaseRequestsList.isAutoConstruct()) { int purchaseRequestsListIndex = 1; for (PurchaseRequest purchaseScheduledInstancesRequestPurchaseRequestsListValue : purchaseScheduledInstancesRequestPurchaseRequestsList) { if (purchaseScheduledInstancesRequestPurchaseRequestsListValue.getPurchaseToken() != null) { request.addParameter( "PurchaseRequest." + purchaseRequestsListIndex + ".PurchaseToken", StringUtils.fromString( purchaseScheduledInstancesRequestPurchaseRequestsListValue.getPurchaseToken())); } if (purchaseScheduledInstancesRequestPurchaseRequestsListValue.getInstanceCount() != null) { request.addParameter( "PurchaseRequest." + purchaseRequestsListIndex + ".InstanceCount", StringUtils.fromInteger( purchaseScheduledInstancesRequestPurchaseRequestsListValue.getInstanceCount())); } purchaseRequestsListIndex++; } } return request; }