public Request<DeleteIdentitiesRequest> marshall(
      DeleteIdentitiesRequest deleteIdentitiesRequest) {

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

    Request<DeleteIdentitiesRequest> request =
        new DefaultRequest<DeleteIdentitiesRequest>(
            deleteIdentitiesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.DeleteIdentities");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      java.util.List<String> identityIdsToDeleteList =
          deleteIdentitiesRequest.getIdentityIdsToDelete();
      if (identityIdsToDeleteList != null) {
        jsonGenerator.writeFieldName("IdentityIdsToDelete");
        jsonGenerator.writeStartArray();
        for (String identityIdsToDeleteListValue : identityIdsToDeleteList) {
          if (identityIdsToDeleteListValue != null) {
            jsonGenerator.writeValue(identityIdsToDeleteListValue);
          }
        }
        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;
  }
コード例 #2
0
  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;
  }