public Request<UpdateRecordsRequest> marshall(UpdateRecordsRequest updateRecordsRequest) {
    if (updateRecordsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<UpdateRecordsRequest> request =
        new DefaultRequest<UpdateRecordsRequest>(updateRecordsRequest, "AmazonCognitoSync");
    String target = "AWSCognitoSyncService.UpdateRecords";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    if (updateRecordsRequest.getClientContext() != null)
      request.addHeader(
          "x-amz-Client-Context", StringUtils.fromString(updateRecordsRequest.getClientContext()));

    String uriResourcePath = RESOURCE_PATH_TEMPLATE;

    if (DYNAMIC_QUERY_PARAMS.containsKey("IdentityPoolId")) {
      String name = DYNAMIC_QUERY_PARAMS.get("IdentityPoolId");
      String value =
          (updateRecordsRequest.getIdentityPoolId() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getIdentityPoolId());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{IdentityPoolId}",
              (updateRecordsRequest.getIdentityPoolId() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getIdentityPoolId()));
    }

    if (DYNAMIC_QUERY_PARAMS.containsKey("IdentityId")) {
      String name = DYNAMIC_QUERY_PARAMS.get("IdentityId");
      String value =
          (updateRecordsRequest.getIdentityId() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getIdentityId());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{IdentityId}",
              (updateRecordsRequest.getIdentityId() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getIdentityId()));
    }

    if (DYNAMIC_QUERY_PARAMS.containsKey("DatasetName")) {
      String name = DYNAMIC_QUERY_PARAMS.get("DatasetName");
      String value =
          (updateRecordsRequest.getDatasetName() == null)
              ? null
              : StringUtils.fromString(updateRecordsRequest.getDatasetName());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }
    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{DatasetName}",
              (updateRecordsRequest.getDatasetName() == null)
                  ? ""
                  : StringUtils.fromString(updateRecordsRequest.getDatasetName()));
    }

    request.setResourcePath(uriResourcePath.replaceAll("//", "/"));

    for (Map.Entry<String, String> entry : STATIC_QUERY_PARAMS.entrySet()) {
      request.addParameter(entry.getKey(), entry.getValue());
    }

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

      jsonWriter.object();

      com.amazonaws.internal.ListWithAutoConstructFlag<RecordPatch> recordPatchesList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<RecordPatch>)
              (updateRecordsRequest.getRecordPatches());
      if (recordPatchesList != null
          && !(recordPatchesList.isAutoConstruct() && recordPatchesList.isEmpty())) {

        jsonWriter.key("RecordPatches");
        jsonWriter.array();

        for (RecordPatch recordPatchesListValue : recordPatchesList) {
          if (recordPatchesListValue != null) {
            jsonWriter.object();
            if (recordPatchesListValue.getOp() != null) {
              jsonWriter.key("Op").value(recordPatchesListValue.getOp());
            }
            if (recordPatchesListValue.getKey() != null) {
              jsonWriter.key("Key").value(recordPatchesListValue.getKey());
            }
            if (recordPatchesListValue.getValue() != null) {
              jsonWriter.key("Value").value(recordPatchesListValue.getValue());
            }
            if (recordPatchesListValue.getSyncCount() != null) {
              jsonWriter.key("SyncCount").value(recordPatchesListValue.getSyncCount());
            }
            if (recordPatchesListValue.getDeviceLastModifiedDate() != null) {
              jsonWriter
                  .key("DeviceLastModifiedDate")
                  .value(recordPatchesListValue.getDeviceLastModifiedDate());
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }
      if (updateRecordsRequest.getSyncSessionToken() != null) {
        jsonWriter.key("SyncSessionToken").value(updateRecordsRequest.getSyncSessionToken());
      }

      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.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<SetCognitoEventsRequest> marshall(
      SetCognitoEventsRequest setCognitoEventsRequest) {
    if (setCognitoEventsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<SetCognitoEventsRequest> request =
        new DefaultRequest<SetCognitoEventsRequest>(setCognitoEventsRequest, "AmazonCognitoSync");
    String target = "AWSCognitoSyncService.SetCognitoEvents";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    String uriResourcePath = RESOURCE_PATH_TEMPLATE;

    if (DYNAMIC_QUERY_PARAMS.containsKey("IdentityPoolId")) {
      String name = DYNAMIC_QUERY_PARAMS.get("IdentityPoolId");

      String value =
          (setCognitoEventsRequest.getIdentityPoolId() == null)
              ? null
              : StringUtils.fromString(setCognitoEventsRequest.getIdentityPoolId());

      if (!(value == null || value.isEmpty())) {
        request.addParameter(name, value);
      }

    } else {
      uriResourcePath =
          uriResourcePath.replace(
              "{IdentityPoolId}",
              (setCognitoEventsRequest.getIdentityPoolId() == null)
                  ? ""
                  : StringUtils.fromString(setCognitoEventsRequest.getIdentityPoolId()));
    }

    request.setResourcePath(uriResourcePath.replaceAll("//", "/"));

    for (Map.Entry<String, String> entry : STATIC_QUERY_PARAMS.entrySet()) {
      request.addParameter(entry.getKey(), entry.getValue());
    }

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

      jsonWriter.object();

      if (setCognitoEventsRequest.getEvents() != null) {
        jsonWriter.key("Events");
        jsonWriter.object();
        for (Map.Entry<String, String> eventsListValue :
            setCognitoEventsRequest.getEvents().entrySet()) {
          if (eventsListValue.getValue() != null) {
            jsonWriter.key(eventsListValue.getKey());

            jsonWriter.value(eventsListValue.getValue());
          }
        }
        jsonWriter.endObject();
      }

      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.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }