Search in sources :

Example 1 with UpdateEndpointRequest

use of software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest in project aws-doc-sdk-examples by awsdocs.

the class UpdateEndpoint method createEndpoint.

// snippet-start:[pinpoint.java2.createendpoint.main]
// snippet-start:[pinpoint.java2.createendpoint.helper]
public static EndpointResponse createEndpoint(PinpointClient client, String appId) {
    String endpointId = UUID.randomUUID().toString();
    System.out.println("Endpoint ID: " + endpointId);
    try {
        EndpointRequest endpointRequest = createEndpointRequestData();
        UpdateEndpointRequest updateEndpointRequest = UpdateEndpointRequest.builder().applicationId(appId).endpointId(endpointId).endpointRequest(endpointRequest).build();
        UpdateEndpointResponse updateEndpointResponse = client.updateEndpoint(updateEndpointRequest);
        System.out.println("Update Endpoint Response: " + updateEndpointResponse.messageBody());
        GetEndpointRequest getEndpointRequest = GetEndpointRequest.builder().applicationId(appId).endpointId(endpointId).build();
        GetEndpointResponse getEndpointResponse = client.getEndpoint(getEndpointRequest);
        System.out.println(getEndpointResponse.endpointResponse().address());
        System.out.println(getEndpointResponse.endpointResponse().channelType());
        System.out.println(getEndpointResponse.endpointResponse().applicationId());
        System.out.println(getEndpointResponse.endpointResponse().endpointStatus());
        System.out.println(getEndpointResponse.endpointResponse().requestId());
        System.out.println(getEndpointResponse.endpointResponse().user());
        return getEndpointResponse.endpointResponse();
    } catch (PinpointException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    return null;
}
Also used : GetEndpointResponse(software.amazon.awssdk.services.pinpoint.model.GetEndpointResponse) UpdateEndpointResponse(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointResponse) PinpointException(software.amazon.awssdk.services.pinpoint.model.PinpointException) UpdateEndpointRequest(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest) GetEndpointRequest(software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest) UpdateEndpointRequest(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest) EndpointRequest(software.amazon.awssdk.services.pinpoint.model.EndpointRequest) GetEndpointRequest(software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest)

Example 2 with UpdateEndpointRequest

use of software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest in project aws-doc-sdk-examples by awsdocs.

the class AddExampleUser method updatePinpointEndpoint.

// snippet-start:[pinpoint.java2.update_endpoint.main]
public static void updatePinpointEndpoint(PinpointClient pinpoint, String applicationId, String endPointId) {
    try {
        List<String> wangXiList = new ArrayList<String>();
        wangXiList.add("cooking");
        wangXiList.add("running");
        wangXiList.add("swimming");
        Map myMapWang = new HashMap<String, List>();
        myMapWang.put("interests", wangXiList);
        List<String> myNameWang = new ArrayList<String>();
        myNameWang.add("Wang ");
        myNameWang.add("Xiulan");
        Map wangName = new HashMap<String, List>();
        wangName.put("name", myNameWang);
        EndpointUser wangMajor = EndpointUser.builder().userId("example_user_10").userAttributes(wangName).build();
        // Create an EndpointBatchItem object for Mary Major.
        EndpointRequest wangXiulanEndpoint = EndpointRequest.builder().channelType(ChannelType.EMAIL).address("wang_xiulan@example.com").attributes(myMapWang).user(wangMajor).build();
        // Adds multiple endpoint definitions to a single request object.
        UpdateEndpointRequest endpointList = UpdateEndpointRequest.builder().applicationId(applicationId).endpointRequest(wangXiulanEndpoint).endpointId(endPointId).build();
        UpdateEndpointResponse result = pinpoint.updateEndpoint(endpointList);
        System.out.format("Update endpoint result: %s\n", result.messageBody().message());
    } catch (PinpointException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : UpdateEndpointResponse(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointResponse) HashMap(java.util.HashMap) EndpointUser(software.amazon.awssdk.services.pinpoint.model.EndpointUser) PinpointException(software.amazon.awssdk.services.pinpoint.model.PinpointException) ArrayList(java.util.ArrayList) UpdateEndpointRequest(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest) Map(java.util.Map) HashMap(java.util.HashMap) UpdateEndpointRequest(software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest) EndpointRequest(software.amazon.awssdk.services.pinpoint.model.EndpointRequest)

Aggregations

EndpointRequest (software.amazon.awssdk.services.pinpoint.model.EndpointRequest)2 PinpointException (software.amazon.awssdk.services.pinpoint.model.PinpointException)2 UpdateEndpointRequest (software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest)2 UpdateEndpointResponse (software.amazon.awssdk.services.pinpoint.model.UpdateEndpointResponse)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 EndpointUser (software.amazon.awssdk.services.pinpoint.model.EndpointUser)1 GetEndpointRequest (software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest)1 GetEndpointResponse (software.amazon.awssdk.services.pinpoint.model.GetEndpointResponse)1