コード例 #1
0
  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;
  }
  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;
  }