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 Request<CreateKeyRequest> marshall(CreateKeyRequest createKeyRequest) {

    if (createKeyRequest == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateKeyRequest> request =
        new DefaultRequest<CreateKeyRequest>(createKeyRequest, "AWSKMS");
    request.addHeader("X-Amz-Target", "TrentService.CreateKey");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (createKeyRequest.getPolicy() != null) {
        jsonGenerator.writeFieldName("Policy").writeValue(createKeyRequest.getPolicy());
      }
      if (createKeyRequest.getDescription() != null) {
        jsonGenerator.writeFieldName("Description").writeValue(createKeyRequest.getDescription());
      }
      if (createKeyRequest.getKeyUsage() != null) {
        jsonGenerator.writeFieldName("KeyUsage").writeValue(createKeyRequest.getKeyUsage());
      }
      if (createKeyRequest.getOrigin() != null) {
        jsonGenerator.writeFieldName("Origin").writeValue(createKeyRequest.getOrigin());
      }
      if (createKeyRequest.getBypassPolicyLockoutSafetyCheck() != null) {
        jsonGenerator
            .writeFieldName("BypassPolicyLockoutSafetyCheck")
            .writeValue(createKeyRequest.getBypassPolicyLockoutSafetyCheck());
      }

      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<ListKeyPoliciesRequest> marshall(ListKeyPoliciesRequest listKeyPoliciesRequest) {
    if (listKeyPoliciesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListKeyPoliciesRequest> request =
        new DefaultRequest<ListKeyPoliciesRequest>(listKeyPoliciesRequest, "AWSKMS");
    String target = "TrentService.ListKeyPolicies";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);

      jsonWriter.beginObject();

      if (listKeyPoliciesRequest.getKeyId() != null) {
        jsonWriter.name("KeyId").value(listKeyPoliciesRequest.getKeyId());
      }
      if (listKeyPoliciesRequest.getLimit() != null) {
        jsonWriter.name("Limit").value(listKeyPoliciesRequest.getLimit());
      }
      if (listKeyPoliciesRequest.getMarker() != null) {
        jsonWriter.name("Marker").value(listKeyPoliciesRequest.getMarker());
      }

      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));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<RevokeGrantRequest> marshall(RevokeGrantRequest revokeGrantRequest) {

    if (revokeGrantRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<RevokeGrantRequest> request =
        new DefaultRequest<RevokeGrantRequest>(revokeGrantRequest, "AWSKMS");
    request.addHeader("X-Amz-Target", "TrentService.RevokeGrant");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (revokeGrantRequest.getKeyId() != null) {
        jsonWriter.key("KeyId").value(revokeGrantRequest.getKeyId());
      }

      if (revokeGrantRequest.getGrantId() != null) {
        jsonWriter.key("GrantId").value(revokeGrantRequest.getGrantId());
      }

      jsonWriter.endObject();

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

    return request;
  }