Search in sources :

Example 1 with UpdateEndpointsBatchResult

use of com.amazonaws.services.pinpoint.model.UpdateEndpointsBatchResult in project aws-doc-sdk-examples by awsdocs.

the class AddExampleEndpoints method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "AddExampleEndpoints - Adds example endpoints to an Amazon Pinpoint application." + "Usage: AddExampleEndpoints <applicationId>" + "Where:\n" + "  applicationId - The ID of the Amazon Pinpoint application to add the example endpoints to.";
    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String applicationId = args[0];
    // Initializes an endpoint definition with channel type, address, and ID.
    EndpointBatchItem richardRoesEmailEndpoint = new EndpointBatchItem().withChannelType(ChannelType.EMAIL).withAddress("richard_roe@example.com").withId("example_endpoint_1");
    // Adds custom attributes to the endpoint.
    richardRoesEmailEndpoint.addAttributesEntry("interests", Arrays.asList("music", "books"));
    // Adds custom metrics to the endpoint.
    richardRoesEmailEndpoint.addMetricsEntry("music_interest_level", 3.0);
    richardRoesEmailEndpoint.addMetricsEntry("books_interest_level", 7.0);
    // Initializes a user definition with a user ID.
    EndpointUser richardRoe = new EndpointUser().withUserId("example_user_1");
    // Adds custom user attributes.
    richardRoe.addUserAttributesEntry("name", Arrays.asList("Richard", "Roe"));
    // Adds the user definition to the endpoint.
    richardRoesEmailEndpoint.setUser(richardRoe);
    // Initializes an endpoint definition with channel type, address, and ID.
    EndpointBatchItem maryMajorsSmsEndpoint = new EndpointBatchItem().withChannelType(ChannelType.SMS).withAddress("+16145550100").withId("example_endpoint_2");
    // Adds custom attributes to the endpoint.
    maryMajorsSmsEndpoint.addAttributesEntry("interests", Arrays.asList("cooking", "politics", "finance"));
    // Adds custom metrics to the endpoint.
    maryMajorsSmsEndpoint.addMetricsEntry("cooking_interest_level", 5.0);
    maryMajorsSmsEndpoint.addMetricsEntry("politics_interest_level", 8.0);
    maryMajorsSmsEndpoint.addMetricsEntry("finance_interest_level", 4.0);
    // Initializes a user definition with a user ID.
    EndpointUser maryMajor = new EndpointUser().withUserId("example_user_2");
    // Adds custom user attributes.
    maryMajor.addUserAttributesEntry("name", Arrays.asList("Mary", "Major"));
    // Adds the user definition to the endpoint.
    maryMajorsSmsEndpoint.setUser(maryMajor);
    // Adds multiple endpoint definitions to a single request object.
    EndpointBatchRequest endpointList = new EndpointBatchRequest().withItem(richardRoesEmailEndpoint).withItem(maryMajorsSmsEndpoint);
    // Initializes the Amazon Pinpoint client.
    AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
    // Updates or creates the endpoints with Amazon Pinpoint.
    UpdateEndpointsBatchResult result = pinpointClient.updateEndpointsBatch(new UpdateEndpointsBatchRequest().withApplicationId(applicationId).withEndpointBatchRequest(endpointList));
    System.out.format("Update endpoints batch result: %s\n", result.getMessageBody().getMessage());
}
Also used : UpdateEndpointsBatchRequest(com.amazonaws.services.pinpoint.model.UpdateEndpointsBatchRequest) UpdateEndpointsBatchResult(com.amazonaws.services.pinpoint.model.UpdateEndpointsBatchResult) EndpointBatchRequest(com.amazonaws.services.pinpoint.model.EndpointBatchRequest) EndpointUser(com.amazonaws.services.pinpoint.model.EndpointUser) AmazonPinpoint(com.amazonaws.services.pinpoint.AmazonPinpoint) EndpointBatchItem(com.amazonaws.services.pinpoint.model.EndpointBatchItem)

Aggregations

AmazonPinpoint (com.amazonaws.services.pinpoint.AmazonPinpoint)1 EndpointBatchItem (com.amazonaws.services.pinpoint.model.EndpointBatchItem)1 EndpointBatchRequest (com.amazonaws.services.pinpoint.model.EndpointBatchRequest)1 EndpointUser (com.amazonaws.services.pinpoint.model.EndpointUser)1 UpdateEndpointsBatchRequest (com.amazonaws.services.pinpoint.model.UpdateEndpointsBatchRequest)1 UpdateEndpointsBatchResult (com.amazonaws.services.pinpoint.model.UpdateEndpointsBatchResult)1