public void marshall(Schedule schedule, AwsJsonWriter jsonWriter) throws Exception {
   jsonWriter.beginObject();
   if (schedule.getEndTime() != null) {
     String endTime = schedule.getEndTime();
     jsonWriter.name("EndTime");
     jsonWriter.value(endTime);
   }
   if (schedule.getFrequency() != null) {
     String frequency = schedule.getFrequency();
     jsonWriter.name("Frequency");
     jsonWriter.value(frequency);
   }
   if (schedule.getIsLocalTime() != null) {
     Boolean isLocalTime = schedule.getIsLocalTime();
     jsonWriter.name("IsLocalTime");
     jsonWriter.value(isLocalTime);
   }
   if (schedule.getQuietTime() != null) {
     QuietTime quietTime = schedule.getQuietTime();
     jsonWriter.name("QuietTime");
     QuietTimeJsonMarshaller.getInstance().marshall(quietTime, jsonWriter);
   }
   if (schedule.getStartTime() != null) {
     String startTime = schedule.getStartTime();
     jsonWriter.name("StartTime");
     jsonWriter.value(startTime);
   }
   if (schedule.getTimezone() != null) {
     String timezone = schedule.getTimezone();
     jsonWriter.name("Timezone");
     jsonWriter.value(timezone);
   }
   jsonWriter.endObject();
 }
 public void marshall(KeyListEntry keyListEntry, AwsJsonWriter jsonWriter) throws Exception {
   jsonWriter.beginObject();
   if (keyListEntry.getKeyId() != null) {
     String keyId = keyListEntry.getKeyId();
     jsonWriter.name("KeyId");
     jsonWriter.value(keyId);
   }
   if (keyListEntry.getKeyArn() != null) {
     String keyArn = keyListEntry.getKeyArn();
     jsonWriter.name("KeyArn");
     jsonWriter.value(keyArn);
   }
   jsonWriter.endObject();
 }
  public Request<RetireGrantRequest> marshall(RetireGrantRequest retireGrantRequest) {
    if (retireGrantRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(RetireGrantRequest)");
    }

    Request<RetireGrantRequest> request =
        new DefaultRequest<RetireGrantRequest>(retireGrantRequest, "AWSKMS");
    String target = "TrentService.RetireGrant";
    request.addHeader("X-Amz-Target", target);
    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/";
    request.setResourcePath(uriResourcePath);
    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
      jsonWriter.beginObject();

      if (retireGrantRequest.getGrantToken() != null) {
        String grantToken = retireGrantRequest.getGrantToken();
        jsonWriter.name("GrantToken");
        jsonWriter.value(grantToken);
      }
      if (retireGrantRequest.getKeyId() != null) {
        String keyId = retireGrantRequest.getKeyId();
        jsonWriter.name("KeyId");
        jsonWriter.value(keyId);
      }
      if (retireGrantRequest.getGrantId() != null) {
        String grantId = retireGrantRequest.getGrantId();
        jsonWriter.name("GrantId");
        jsonWriter.value(grantId);
      }

      jsonWriter.endObject();
      jsonWriter.close();
      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    }

    return request;
  }
 public void marshall(AttributeDefinition attributeDefinition, AwsJsonWriter jsonWriter)
     throws Exception {
   jsonWriter.beginObject();
   if (attributeDefinition.getAttributeName() != null) {
     String attributeName = attributeDefinition.getAttributeName();
     jsonWriter.name("AttributeName");
     jsonWriter.value(attributeName);
   }
   if (attributeDefinition.getAttributeType() != null) {
     String attributeType = attributeDefinition.getAttributeType();
     jsonWriter.name("AttributeType");
     jsonWriter.value(attributeType);
   }
   jsonWriter.endObject();
 }
 public void marshall(LambdaAction lambdaAction, AwsJsonWriter jsonWriter) throws Exception {
   jsonWriter.beginObject();
   if (lambdaAction.getFunctionArn() != null) {
     String functionArn = lambdaAction.getFunctionArn();
     jsonWriter.name("functionArn");
     jsonWriter.value(functionArn);
   }
   jsonWriter.endObject();
 }
  public Request<GetRecordsRequest> marshall(GetRecordsRequest getRecordsRequest) {
    if (getRecordsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(GetRecordsRequest)");
    }

    Request<GetRecordsRequest> request =
        new DefaultRequest<GetRecordsRequest>(getRecordsRequest, "AmazonKinesis");
    String target = "Kinesis_20131202.GetRecords";
    request.addHeader("X-Amz-Target", target);
    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/";
    request.setResourcePath(uriResourcePath);
    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
      jsonWriter.beginObject();

      if (getRecordsRequest.getShardIterator() != null) {
        String shardIterator = getRecordsRequest.getShardIterator();
        jsonWriter.name("ShardIterator");
        jsonWriter.value(shardIterator);
      }
      if (getRecordsRequest.getLimit() != null) {
        Integer limit = getRecordsRequest.getLimit();
        jsonWriter.name("Limit");
        jsonWriter.value(limit);
      }

      jsonWriter.endObject();
      jsonWriter.close();
      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    }

    return request;
  }
 public void marshall(Session session, AwsJsonWriter jsonWriter) throws Exception {
   jsonWriter.beginObject();
   if (session.getId() != null) {
     String id = session.getId();
     jsonWriter.name("id");
     jsonWriter.value(id);
   }
   if (session.getDuration() != null) {
     Long duration = session.getDuration();
     jsonWriter.name("duration");
     jsonWriter.value(duration);
   }
   if (session.getStartTimestamp() != null) {
     String startTimestamp = session.getStartTimestamp();
     jsonWriter.name("startTimestamp");
     jsonWriter.value(startTimestamp);
   }
   if (session.getStopTimestamp() != null) {
     String stopTimestamp = session.getStopTimestamp();
     jsonWriter.name("stopTimestamp");
     jsonWriter.value(stopTimestamp);
   }
   jsonWriter.endObject();
 }
  @Test
  public void testStringJsonUnmarshaller() throws Exception {

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("s");
    jw.value("String");
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller sUnmarshaller =
        SimpleTypeJsonUnmarshallers.StringJsonUnmarshaller.getInstance();
    assertEquals(sUnmarshaller.unmarshall(context), "String");
  }
  @Test
  public void testFloatJsonUnmarshaller() throws Exception {
    Float f = new Float(5.5);

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("f");
    jw.value(f);
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.FloatJsonUnmarshaller fUnmarshaller =
        SimpleTypeJsonUnmarshallers.FloatJsonUnmarshaller.getInstance();
    Float unmarshalledF = fUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledF.floatValue(), 5.5, .001);
  }
  @Test
  public void testByteBufferJsonUnmarshaller() throws Exception {

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("bb");
    jw.value(Base64.encodeAsString("byte".getBytes()));
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.ByteBufferJsonUnmarshaller bbUnmarshaller =
        SimpleTypeJsonUnmarshallers.ByteBufferJsonUnmarshaller.getInstance();
    ByteBuffer unmarshalledBb = bbUnmarshaller.unmarshall(context);
    ByteBuffer expected = ByteBuffer.wrap("byte".getBytes());
    assertTrue(unmarshalledBb.equals(expected));
  }
  @Test
  public void testBooleanJsonUnmarshaller() throws Exception {

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("boolean");
    jw.value("true");
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.BooleanJsonUnmarshaller bUnmarshaller =
        SimpleTypeJsonUnmarshallers.BooleanJsonUnmarshaller.getInstance();
    Boolean unmarshalledB = bUnmarshaller.unmarshall(context);

    assertTrue(unmarshalledB);
  }
  @Test
  public void testBigIntegerJsonUnmarshaller() throws Exception {
    BigInteger bi = new BigInteger("13459712934871293847891231293874");

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("bi");
    jw.value(bi.toString());
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.BigIntegerJsonUnmarshaller biUnmarshaller =
        SimpleTypeJsonUnmarshallers.BigIntegerJsonUnmarshaller.getInstance();
    BigInteger unmarshalledBI = biUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledBI.toString(), bi.toString());
  }
  @Test
  public void testBigDecimalJsonUnmarshaller() throws Exception {
    BigDecimal bd = new BigDecimal("1.5");

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("bd");
    jw.value(bd.toPlainString());
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.BigDecimalJsonUnmarshaller bdUnmarshaller =
        SimpleTypeJsonUnmarshallers.BigDecimalJsonUnmarshaller.getInstance();
    BigDecimal unmarshalledBD = bdUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledBD.toPlainString(), bd.toPlainString());
  }
  @Test
  public void testLongJsonUnmarshaller() throws Exception {
    Long l = new Long(5L);

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("l");
    jw.value(l);
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.LongJsonUnmarshaller lUnmarshaller =
        SimpleTypeJsonUnmarshallers.LongJsonUnmarshaller.getInstance();
    Long unmarshalledL = lUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledL.longValue(), 5L);
  }
  @Test
  public void testIntegerJsonUnmarshaller() throws Exception {
    Integer i = new Integer(5);

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("i");
    jw.value(i);
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.IntegerJsonUnmarshaller iUnmarshaller =
        SimpleTypeJsonUnmarshallers.IntegerJsonUnmarshaller.getInstance();
    Integer unmarshalledI = iUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledI.intValue(), 5);
  }
  @Test
  public void testByteJsonUnmarshaller() throws Exception {

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("b");
    jw.value(Byte.valueOf("127"));
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.ByteJsonUnmarshaller bUnmarshaller =
        SimpleTypeJsonUnmarshallers.ByteJsonUnmarshaller.getInstance();
    Byte unmarshalledB = bUnmarshaller.unmarshall(context);
    Byte expected = Byte.valueOf("127");
    assertTrue(unmarshalledB.equals(expected));
  }
  @Test
  public void testDoubleJsonUnmarshaller() throws Exception {
    Double dub = new Double(5.5);

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("dub");
    jw.value(dub);
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.DoubleJsonUnmarshaller dubUnmarshaller =
        SimpleTypeJsonUnmarshallers.DoubleJsonUnmarshaller.getInstance();
    Double unmarshalledDub = dubUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledDub.doubleValue(), 5.5, .001);
  }
  @Test
  public void testDateJsonUnmarshaller() throws Exception {
    Date date = new Date();
    date.setTime(1000);

    StringWriter sw = new StringWriter();
    AwsJsonWriter jw = JsonUtils.getJsonWriter(sw);
    jw.beginObject();
    jw.name("date");
    jw.value(date);
    jw.endObject();
    String json = sw.toString();

    StringReader sr = new StringReader(json);
    AwsJsonReader jr = JsonUtils.getJsonReader(sr);
    JsonUnmarshallerContext context = new JsonUnmarshallerContext(jr);
    context.getReader().beginObject();
    context.getReader().nextName();

    SimpleTypeJsonUnmarshallers.DateJsonUnmarshaller dateUnmarshaller =
        SimpleTypeJsonUnmarshallers.DateJsonUnmarshaller.getInstance();
    Date unmarshalledDate = dateUnmarshaller.unmarshall(context);
    assertEquals(unmarshalledDate.getTime(), date.getTime());
  }
  public Request<ListUsersRequest> marshall(ListUsersRequest listUsersRequest) {
    if (listUsersRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(ListUsersRequest)");
    }

    Request<ListUsersRequest> request =
        new DefaultRequest<ListUsersRequest>(listUsersRequest, "AmazonCognitoIdentityProvider");
    String target = "AWSCognitoIdentityProviderService.ListUsers";
    request.addHeader("X-Amz-Target", target);
    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/";
    request.setResourcePath(uriResourcePath);
    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
      jsonWriter.beginObject();

      if (listUsersRequest.getUserPoolId() != null) {
        String userPoolId = listUsersRequest.getUserPoolId();
        jsonWriter.name("UserPoolId");
        jsonWriter.value(userPoolId);
      }
      if (listUsersRequest.getAttributesToGet() != null) {
        java.util.List<String> attributesToGet = listUsersRequest.getAttributesToGet();
        jsonWriter.name("AttributesToGet");
        jsonWriter.beginArray();
        for (String attributesToGetItem : attributesToGet) {
          if (attributesToGetItem != null) {
            jsonWriter.value(attributesToGetItem);
          }
        }
        jsonWriter.endArray();
      }
      if (listUsersRequest.getLimit() != null) {
        Integer limit = listUsersRequest.getLimit();
        jsonWriter.name("Limit");
        jsonWriter.value(limit);
      }
      if (listUsersRequest.getPaginationToken() != null) {
        String paginationToken = listUsersRequest.getPaginationToken();
        jsonWriter.name("PaginationToken");
        jsonWriter.value(paginationToken);
      }
      if (listUsersRequest.getFilter() != null) {
        String filter = listUsersRequest.getFilter();
        jsonWriter.name("Filter");
        jsonWriter.value(filter);
      }

      jsonWriter.endObject();
      jsonWriter.close();
      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    }

    return request;
  }