コード例 #1
0
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      CodeDeliveryDetailsType codeDeliveryDetailsType, StructuredJsonGenerator jsonGenerator) {

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

    try {
      jsonGenerator.writeStartObject();

      if (codeDeliveryDetailsType.getDestination() != null) {
        jsonGenerator
            .writeFieldName("Destination")
            .writeValue(codeDeliveryDetailsType.getDestination());
      }
      if (codeDeliveryDetailsType.getDeliveryMedium() != null) {
        jsonGenerator
            .writeFieldName("DeliveryMedium")
            .writeValue(codeDeliveryDetailsType.getDeliveryMedium());
      }
      if (codeDeliveryDetailsType.getAttributeName() != null) {
        jsonGenerator
            .writeFieldName("AttributeName")
            .writeValue(codeDeliveryDetailsType.getAttributeName());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<AdminUpdateDeviceStatusRequest> marshall(
      AdminUpdateDeviceStatusRequest adminUpdateDeviceStatusRequest) {

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

    Request<AdminUpdateDeviceStatusRequest> request =
        new DefaultRequest<AdminUpdateDeviceStatusRequest>(
            adminUpdateDeviceStatusRequest, "AWSCognitoIdentityProvider");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityProviderService.AdminUpdateDeviceStatus");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (adminUpdateDeviceStatusRequest.getUserPoolId() != null) {
        jsonGenerator
            .writeFieldName("UserPoolId")
            .writeValue(adminUpdateDeviceStatusRequest.getUserPoolId());
      }
      if (adminUpdateDeviceStatusRequest.getUsername() != null) {
        jsonGenerator
            .writeFieldName("Username")
            .writeValue(adminUpdateDeviceStatusRequest.getUsername());
      }
      if (adminUpdateDeviceStatusRequest.getDeviceKey() != null) {
        jsonGenerator
            .writeFieldName("DeviceKey")
            .writeValue(adminUpdateDeviceStatusRequest.getDeviceKey());
      }
      if (adminUpdateDeviceStatusRequest.getDeviceRememberedStatus() != null) {
        jsonGenerator
            .writeFieldName("DeviceRememberedStatus")
            .writeValue(adminUpdateDeviceStatusRequest.getDeviceRememberedStatus());
      }

      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;
  }
コード例 #3
0
  public Request<ListDevicesRequest> marshall(ListDevicesRequest listDevicesRequest) {

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

    Request<ListDevicesRequest> request =
        new DefaultRequest<ListDevicesRequest>(listDevicesRequest, "AWSCognitoIdentityProvider");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityProviderService.ListDevices");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (listDevicesRequest.getAccessToken() != null) {
        jsonGenerator.writeFieldName("AccessToken").writeValue(listDevicesRequest.getAccessToken());
      }
      if (listDevicesRequest.getLimit() != null) {
        jsonGenerator.writeFieldName("Limit").writeValue(listDevicesRequest.getLimit());
      }
      if (listDevicesRequest.getPaginationToken() != null) {
        jsonGenerator
            .writeFieldName("PaginationToken")
            .writeValue(listDevicesRequest.getPaginationToken());
      }

      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;
  }
コード例 #4
0
  public Request<SignUpRequest> marshall(SignUpRequest signUpRequest) {

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

    Request<SignUpRequest> request =
        new DefaultRequest<SignUpRequest>(signUpRequest, "AWSCognitoIdentityProvider");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityProviderService.SignUp");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (signUpRequest.getClientId() != null) {
        jsonGenerator.writeFieldName("ClientId").writeValue(signUpRequest.getClientId());
      }
      if (signUpRequest.getSecretHash() != null) {
        jsonGenerator.writeFieldName("SecretHash").writeValue(signUpRequest.getSecretHash());
      }
      if (signUpRequest.getUsername() != null) {
        jsonGenerator.writeFieldName("Username").writeValue(signUpRequest.getUsername());
      }
      if (signUpRequest.getPassword() != null) {
        jsonGenerator.writeFieldName("Password").writeValue(signUpRequest.getPassword());
      }

      java.util.List<AttributeType> userAttributesList = signUpRequest.getUserAttributes();
      if (userAttributesList != null) {
        jsonGenerator.writeFieldName("UserAttributes");
        jsonGenerator.writeStartArray();
        for (AttributeType userAttributesListValue : userAttributesList) {
          if (userAttributesListValue != null) {

            AttributeTypeJsonMarshaller.getInstance()
                .marshall(userAttributesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      java.util.List<AttributeType> validationDataList = signUpRequest.getValidationData();
      if (validationDataList != null) {
        jsonGenerator.writeFieldName("ValidationData");
        jsonGenerator.writeStartArray();
        for (AttributeType validationDataListValue : validationDataList) {
          if (validationDataListValue != null) {

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

    return request;
  }
  public Request<AdminInitiateAuthRequest> marshall(
      AdminInitiateAuthRequest adminInitiateAuthRequest) {

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

    Request<AdminInitiateAuthRequest> request =
        new DefaultRequest<AdminInitiateAuthRequest>(
            adminInitiateAuthRequest, "AWSCognitoIdentityProvider");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityProviderService.AdminInitiateAuth");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (adminInitiateAuthRequest.getUserPoolId() != null) {
        jsonGenerator
            .writeFieldName("UserPoolId")
            .writeValue(adminInitiateAuthRequest.getUserPoolId());
      }
      if (adminInitiateAuthRequest.getClientId() != null) {
        jsonGenerator.writeFieldName("ClientId").writeValue(adminInitiateAuthRequest.getClientId());
      }
      if (adminInitiateAuthRequest.getAuthFlow() != null) {
        jsonGenerator.writeFieldName("AuthFlow").writeValue(adminInitiateAuthRequest.getAuthFlow());
      }

      java.util.Map<String, String> authParametersMap =
          adminInitiateAuthRequest.getAuthParameters();
      if (authParametersMap != null) {
        jsonGenerator.writeFieldName("AuthParameters");
        jsonGenerator.writeStartObject();

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

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

      java.util.Map<String, String> clientMetadataMap =
          adminInitiateAuthRequest.getClientMetadata();
      if (clientMetadataMap != null) {
        jsonGenerator.writeFieldName("ClientMetadata");
        jsonGenerator.writeStartObject();

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

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

      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;
  }