public Request<CreatePlayerSessionsRequest> marshall( CreatePlayerSessionsRequest createPlayerSessionsRequest) { if (createPlayerSessionsRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<CreatePlayerSessionsRequest> request = new DefaultRequest<CreatePlayerSessionsRequest>( createPlayerSessionsRequest, "AmazonGameLift"); request.addHeader("X-Amz-Target", "GameLift.CreatePlayerSessions"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (createPlayerSessionsRequest.getGameSessionId() != null) { jsonGenerator .writeFieldName("GameSessionId") .writeValue(createPlayerSessionsRequest.getGameSessionId()); } java.util.List<String> playerIdsList = createPlayerSessionsRequest.getPlayerIds(); if (playerIdsList != null) { jsonGenerator.writeFieldName("PlayerIds"); jsonGenerator.writeStartArray(); for (String playerIdsListValue : playerIdsList) { if (playerIdsListValue != null) { jsonGenerator.writeValue(playerIdsListValue); } } jsonGenerator.writeEndArray(); } 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; }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(FleetUtilization fleetUtilization, StructuredJsonGenerator jsonGenerator) { if (fleetUtilization == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (fleetUtilization.getFleetId() != null) { jsonGenerator.writeFieldName("FleetId").writeValue(fleetUtilization.getFleetId()); } if (fleetUtilization.getActiveGameSessionCount() != null) { jsonGenerator .writeFieldName("ActiveGameSessionCount") .writeValue(fleetUtilization.getActiveGameSessionCount()); } if (fleetUtilization.getCurrentPlayerSessionCount() != null) { jsonGenerator .writeFieldName("CurrentPlayerSessionCount") .writeValue(fleetUtilization.getCurrentPlayerSessionCount()); } if (fleetUtilization.getMaximumPlayerSessionCount() != null) { jsonGenerator .writeFieldName("MaximumPlayerSessionCount") .writeValue(fleetUtilization.getMaximumPlayerSessionCount()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<UpdateBuildRequest> marshall(UpdateBuildRequest updateBuildRequest) { if (updateBuildRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<UpdateBuildRequest> request = new DefaultRequest<UpdateBuildRequest>(updateBuildRequest, "AmazonGameLift"); request.addHeader("X-Amz-Target", "GameLift.UpdateBuild"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (updateBuildRequest.getBuildId() != null) { jsonGenerator.writeFieldName("BuildId").writeValue(updateBuildRequest.getBuildId()); } if (updateBuildRequest.getName() != null) { jsonGenerator.writeFieldName("Name").writeValue(updateBuildRequest.getName()); } if (updateBuildRequest.getVersion() != null) { jsonGenerator.writeFieldName("Version").writeValue(updateBuildRequest.getVersion()); } 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 AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(FleetAttributes fleetAttributes, StructuredJsonGenerator jsonGenerator) { if (fleetAttributes == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (fleetAttributes.getFleetId() != null) { jsonGenerator.writeFieldName("FleetId").writeValue(fleetAttributes.getFleetId()); } if (fleetAttributes.getDescription() != null) { jsonGenerator.writeFieldName("Description").writeValue(fleetAttributes.getDescription()); } if (fleetAttributes.getName() != null) { jsonGenerator.writeFieldName("Name").writeValue(fleetAttributes.getName()); } if (fleetAttributes.getCreationTime() != null) { jsonGenerator.writeFieldName("CreationTime").writeValue(fleetAttributes.getCreationTime()); } if (fleetAttributes.getTerminationTime() != null) { jsonGenerator .writeFieldName("TerminationTime") .writeValue(fleetAttributes.getTerminationTime()); } if (fleetAttributes.getStatus() != null) { jsonGenerator.writeFieldName("Status").writeValue(fleetAttributes.getStatus()); } if (fleetAttributes.getBuildId() != null) { jsonGenerator.writeFieldName("BuildId").writeValue(fleetAttributes.getBuildId()); } if (fleetAttributes.getServerLaunchPath() != null) { jsonGenerator .writeFieldName("ServerLaunchPath") .writeValue(fleetAttributes.getServerLaunchPath()); } if (fleetAttributes.getServerLaunchParameters() != null) { jsonGenerator .writeFieldName("ServerLaunchParameters") .writeValue(fleetAttributes.getServerLaunchParameters()); } java.util.List<String> logPathsList = fleetAttributes.getLogPaths(); if (logPathsList != null) { jsonGenerator.writeFieldName("LogPaths"); jsonGenerator.writeStartArray(); for (String logPathsListValue : logPathsList) { if (logPathsListValue != null) { jsonGenerator.writeValue(logPathsListValue); } } jsonGenerator.writeEndArray(); } if (fleetAttributes.getNewGameSessionProtectionPolicy() != null) { jsonGenerator .writeFieldName("NewGameSessionProtectionPolicy") .writeValue(fleetAttributes.getNewGameSessionProtectionPolicy()); } if (fleetAttributes.getOperatingSystem() != null) { jsonGenerator .writeFieldName("OperatingSystem") .writeValue(fleetAttributes.getOperatingSystem()); } if (fleetAttributes.getResourceCreationLimitPolicy() != null) { jsonGenerator.writeFieldName("ResourceCreationLimitPolicy"); ResourceCreationLimitPolicyJsonMarshaller.getInstance() .marshall(fleetAttributes.getResourceCreationLimitPolicy(), jsonGenerator); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
public Request<DescribePlayerSessionsRequest> marshall( DescribePlayerSessionsRequest describePlayerSessionsRequest) { if (describePlayerSessionsRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<DescribePlayerSessionsRequest> request = new DefaultRequest<DescribePlayerSessionsRequest>( describePlayerSessionsRequest, "AmazonGameLift"); request.addHeader("X-Amz-Target", "GameLift.DescribePlayerSessions"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(""); try { final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator(); jsonGenerator.writeStartObject(); if (describePlayerSessionsRequest.getGameSessionId() != null) { jsonGenerator .writeFieldName("GameSessionId") .writeValue(describePlayerSessionsRequest.getGameSessionId()); } if (describePlayerSessionsRequest.getPlayerId() != null) { jsonGenerator .writeFieldName("PlayerId") .writeValue(describePlayerSessionsRequest.getPlayerId()); } if (describePlayerSessionsRequest.getPlayerSessionId() != null) { jsonGenerator .writeFieldName("PlayerSessionId") .writeValue(describePlayerSessionsRequest.getPlayerSessionId()); } if (describePlayerSessionsRequest.getPlayerSessionStatusFilter() != null) { jsonGenerator .writeFieldName("PlayerSessionStatusFilter") .writeValue(describePlayerSessionsRequest.getPlayerSessionStatusFilter()); } if (describePlayerSessionsRequest.getLimit() != null) { jsonGenerator.writeFieldName("Limit").writeValue(describePlayerSessionsRequest.getLimit()); } if (describePlayerSessionsRequest.getNextToken() != null) { jsonGenerator .writeFieldName("NextToken") .writeValue(describePlayerSessionsRequest.getNextToken()); } jsonGenerator.writeEndObject(); byte[] content = jsonGenerator.getBytes(); request.setContent(new ByteArrayInputStream(content)); request.addHeader("Content-Length", Integer.toString(content.length)); request.addHeader("Content-Type", jsonGenerator.getContentType()); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } return request; }