Search in sources :

Example 1 with GetEndpointRequest

use of software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest 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 GetEndpointRequest

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

the class LookUpEndpoint method lookupPinpointEndpoint.

// snippet-start:[pinpoint.java2.lookup.main]
public static void lookupPinpointEndpoint(PinpointClient pinpoint, String appId, String endpoint) {
    try {
        GetEndpointRequest appRequest = GetEndpointRequest.builder().applicationId(appId).endpointId(endpoint).build();
        GetEndpointResponse result = pinpoint.getEndpoint(appRequest);
        EndpointResponse endResponse = result.endpointResponse();
        // Uses the Google Gson library to pretty print the endpoint JSON.
        Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting().create();
        String endpointJson = gson.toJson(endResponse);
        System.out.println(endpointJson);
    } catch (PinpointException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    System.out.println("Done");
}
Also used : GetEndpointResponse(software.amazon.awssdk.services.pinpoint.model.GetEndpointResponse) EndpointResponse(software.amazon.awssdk.services.pinpoint.model.EndpointResponse) GetEndpointResponse(software.amazon.awssdk.services.pinpoint.model.GetEndpointResponse) GsonBuilder(com.google.gson.GsonBuilder) PinpointException(software.amazon.awssdk.services.pinpoint.model.PinpointException) Gson(com.google.gson.Gson) GetEndpointRequest(software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest)

Aggregations

GetEndpointRequest (software.amazon.awssdk.services.pinpoint.model.GetEndpointRequest)2 GetEndpointResponse (software.amazon.awssdk.services.pinpoint.model.GetEndpointResponse)2 PinpointException (software.amazon.awssdk.services.pinpoint.model.PinpointException)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 EndpointRequest (software.amazon.awssdk.services.pinpoint.model.EndpointRequest)1 EndpointResponse (software.amazon.awssdk.services.pinpoint.model.EndpointResponse)1 UpdateEndpointRequest (software.amazon.awssdk.services.pinpoint.model.UpdateEndpointRequest)1 UpdateEndpointResponse (software.amazon.awssdk.services.pinpoint.model.UpdateEndpointResponse)1