public Request<SetIdentityPoolRolesRequest> marshall(
      SetIdentityPoolRolesRequest setIdentityPoolRolesRequest) {

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

    Request<SetIdentityPoolRolesRequest> request =
        new DefaultRequest<SetIdentityPoolRolesRequest>(
            setIdentityPoolRolesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.SetIdentityPoolRoles");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonWriter.object();

      if (setIdentityPoolRolesRequest.getIdentityPoolId() != null) {
        jsonWriter.key("IdentityPoolId").value(setIdentityPoolRolesRequest.getIdentityPoolId());
      }

      java.util.Map<String, String> rolesMap = setIdentityPoolRolesRequest.getRoles();
      if (rolesMap != null) {
        jsonWriter.key("Roles");
        jsonWriter.object();

        for (Map.Entry<String, String> rolesMapValue : rolesMap.entrySet()) {
          if (rolesMapValue.getValue() != null) {
            jsonWriter.key(rolesMapValue.getKey());

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

    return request;
  }
  public Request<UnlinkIdentityRequest> marshall(UnlinkIdentityRequest unlinkIdentityRequest) {

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

    Request<UnlinkIdentityRequest> request =
        new DefaultRequest<UnlinkIdentityRequest>(unlinkIdentityRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.UnlinkIdentity");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (unlinkIdentityRequest.getIdentityId() != null) {
        jsonGenerator
            .writeFieldName("IdentityId")
            .writeValue(unlinkIdentityRequest.getIdentityId());
      }

      java.util.Map<String, String> loginsMap = unlinkIdentityRequest.getLogins();
      if (loginsMap != null) {
        jsonGenerator.writeFieldName("Logins");
        jsonGenerator.writeStartObject();

        for (Map.Entry<String, String> loginsMapValue : loginsMap.entrySet()) {
          if (loginsMapValue.getValue() != null) {
            jsonGenerator.writeFieldName(loginsMapValue.getKey());

            jsonGenerator.writeValue(loginsMapValue.getValue());
          }
        }
        jsonGenerator.writeEndObject();
      }

      java.util.List<String> loginsToRemoveList = unlinkIdentityRequest.getLoginsToRemove();
      if (loginsToRemoveList != null) {
        jsonGenerator.writeFieldName("LoginsToRemove");
        jsonGenerator.writeStartArray();
        for (String loginsToRemoveListValue : loginsToRemoveList) {
          if (loginsToRemoveListValue != null) {
            jsonGenerator.writeValue(loginsToRemoveListValue);
          }
        }
        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;
  }