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

    Request<CreateIdentityPoolRequest> request =
        new DefaultRequest<CreateIdentityPoolRequest>(
            createIdentityPoolRequest, "AmazonCognitoIdentity");
    String target = "AWSCognitoIdentityService.CreateIdentityPool";
    request.addHeader("X-Amz-Target", target);

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

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

      jsonWriter.object();

      if (createIdentityPoolRequest.getIdentityPoolName() != null) {
        jsonWriter.key("IdentityPoolName").value(createIdentityPoolRequest.getIdentityPoolName());
      }
      if (createIdentityPoolRequest.isAllowUnauthenticatedIdentities() != null) {
        jsonWriter
            .key("AllowUnauthenticatedIdentities")
            .value(createIdentityPoolRequest.isAllowUnauthenticatedIdentities());
      }
      if (createIdentityPoolRequest.getSupportedLoginProviders() != null) {
        jsonWriter.key("SupportedLoginProviders");
        jsonWriter.object();
        for (Map.Entry<String, String> supportedLoginProvidersListValue :
            createIdentityPoolRequest.getSupportedLoginProviders().entrySet()) {
          if (supportedLoginProvidersListValue.getValue() != null) {
            jsonWriter.key(supportedLoginProvidersListValue.getKey());

            jsonWriter.value(supportedLoginProvidersListValue.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;
  }
  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<MergeDeveloperIdentitiesRequest> marshall(
      MergeDeveloperIdentitiesRequest mergeDeveloperIdentitiesRequest) {

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

    Request<MergeDeveloperIdentitiesRequest> request =
        new DefaultRequest<MergeDeveloperIdentitiesRequest>(
            mergeDeveloperIdentitiesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.MergeDeveloperIdentities");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (mergeDeveloperIdentitiesRequest.getSourceUserIdentifier() != null) {
        jsonGenerator
            .writeFieldName("SourceUserIdentifier")
            .writeValue(mergeDeveloperIdentitiesRequest.getSourceUserIdentifier());
      }
      if (mergeDeveloperIdentitiesRequest.getDestinationUserIdentifier() != null) {
        jsonGenerator
            .writeFieldName("DestinationUserIdentifier")
            .writeValue(mergeDeveloperIdentitiesRequest.getDestinationUserIdentifier());
      }
      if (mergeDeveloperIdentitiesRequest.getDeveloperProviderName() != null) {
        jsonGenerator
            .writeFieldName("DeveloperProviderName")
            .writeValue(mergeDeveloperIdentitiesRequest.getDeveloperProviderName());
      }
      if (mergeDeveloperIdentitiesRequest.getIdentityPoolId() != null) {
        jsonGenerator
            .writeFieldName("IdentityPoolId")
            .writeValue(mergeDeveloperIdentitiesRequest.getIdentityPoolId());
      }

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

    return request;
  }
  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;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      IdentityDescription identityDescription, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

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

      java.util.List<String> loginsList = identityDescription.getLogins();
      if (loginsList != null) {
        jsonGenerator.writeFieldName("Logins");
        jsonGenerator.writeStartArray();
        for (String loginsListValue : loginsList) {
          if (loginsListValue != null) {
            jsonGenerator.writeValue(loginsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (identityDescription.getCreationDate() != null) {
        jsonGenerator
            .writeFieldName("CreationDate")
            .writeValue(identityDescription.getCreationDate());
      }
      if (identityDescription.getLastModifiedDate() != null) {
        jsonGenerator
            .writeFieldName("LastModifiedDate")
            .writeValue(identityDescription.getLastModifiedDate());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
コード例 #6
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;
  }