public Request<UpdateMethodRequest> marshall(UpdateMethodRequest updateMethodRequest) { if (updateMethodRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<UpdateMethodRequest> request = new DefaultRequest<UpdateMethodRequest>(updateMethodRequest, "AmazonApiGateway"); request.setHttpMethod(HttpMethodName.PATCH); String uriResourcePath = "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}"; uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "restapi_id", updateMethodRequest.getRestApiId()); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "resource_id", updateMethodRequest.getResourceId()); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "http_method", updateMethodRequest.getHttpMethod()); request.setResourcePath(uriResourcePath); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); java.util.List<PatchOperation> patchOperationsList = updateMethodRequest.getPatchOperations(); if (patchOperationsList != null) { jsonGenerator.writeFieldName("patchOperations"); jsonGenerator.writeStartArray(); for (PatchOperation patchOperationsListValue : patchOperationsList) { if (patchOperationsListValue != null) { PatchOperationJsonMarshaller.getInstance() .marshall(patchOperationsListValue, jsonGenerator); } } jsonGenerator.writeEndArray(); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); if (!request.getHeaders().containsKey("Content-Type")) { 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<CreateBasePathMappingRequest> marshall( CreateBasePathMappingRequest createBasePathMappingRequest) { if (createBasePathMappingRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreateBasePathMappingRequest> request = new DefaultRequest<CreateBasePathMappingRequest>( createBasePathMappingRequest, "AmazonApiGateway"); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = "/domainnames/{domain_name}/basepathmappings"; uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall( uriResourcePath, "domain_name", createBasePathMappingRequest.getDomainName()); request.setResourcePath(uriResourcePath); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (createBasePathMappingRequest.getBasePath() != null) { jsonGenerator .writeFieldName("basePath") .writeValue(createBasePathMappingRequest.getBasePath()); } if (createBasePathMappingRequest.getRestApiId() != null) { jsonGenerator .writeFieldName("restApiId") .writeValue(createBasePathMappingRequest.getRestApiId()); } if (createBasePathMappingRequest.getStage() != null) { jsonGenerator.writeFieldName("stage").writeValue(createBasePathMappingRequest.getStage()); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", protocolFactory.getContentType()); } } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(MethodSetting methodSetting, StructuredJsonGenerator jsonGenerator) { if (methodSetting == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (methodSetting.getMetricsEnabled() != null) { jsonGenerator .writeFieldName("metricsEnabled") .writeValue(methodSetting.getMetricsEnabled()); } if (methodSetting.getLoggingLevel() != null) { jsonGenerator.writeFieldName("loggingLevel").writeValue(methodSetting.getLoggingLevel()); } if (methodSetting.getDataTraceEnabled() != null) { jsonGenerator .writeFieldName("dataTraceEnabled") .writeValue(methodSetting.getDataTraceEnabled()); } if (methodSetting.getThrottlingBurstLimit() != null) { jsonGenerator .writeFieldName("throttlingBurstLimit") .writeValue(methodSetting.getThrottlingBurstLimit()); } if (methodSetting.getThrottlingRateLimit() != null) { jsonGenerator .writeFieldName("throttlingRateLimit") .writeValue(methodSetting.getThrottlingRateLimit()); } if (methodSetting.getCachingEnabled() != null) { jsonGenerator .writeFieldName("cachingEnabled") .writeValue(methodSetting.getCachingEnabled()); } if (methodSetting.getCacheTtlInSeconds() != null) { jsonGenerator .writeFieldName("cacheTtlInSeconds") .writeValue(methodSetting.getCacheTtlInSeconds()); } if (methodSetting.getCacheDataEncrypted() != null) { jsonGenerator .writeFieldName("cacheDataEncrypted") .writeValue(methodSetting.getCacheDataEncrypted()); } if (methodSetting.getRequireAuthorizationForCacheControl() != null) { jsonGenerator .writeFieldName("requireAuthorizationForCacheControl") .writeValue(methodSetting.getRequireAuthorizationForCacheControl()); } if (methodSetting.getUnauthorizedCacheControlHeaderStrategy() != null) { jsonGenerator .writeFieldName("unauthorizedCacheControlHeaderStrategy") .writeValue(methodSetting.getUnauthorizedCacheControlHeaderStrategy()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }