Search in sources :

Example 1 with SegmentResponse

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

the class ListSegments method listSegs.

// snippet-start:[pinpoint.java2.listsegments.main]
public static void listSegs(PinpointClient pinpoint, String appId) {
    try {
        GetSegmentsRequest request = GetSegmentsRequest.builder().applicationId(appId).build();
        GetSegmentsResponse response = pinpoint.getSegments(request);
        List<SegmentResponse> segments = response.segmentsResponse().item();
        for (SegmentResponse segment : segments) {
            System.out.println("Segement " + segment.id() + " " + segment.name() + " " + segment.lastModifiedDate());
        }
    } catch (PinpointException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : GetSegmentsRequest(software.amazon.awssdk.services.pinpoint.model.GetSegmentsRequest) PinpointException(software.amazon.awssdk.services.pinpoint.model.PinpointException) GetSegmentsResponse(software.amazon.awssdk.services.pinpoint.model.GetSegmentsResponse) SegmentResponse(software.amazon.awssdk.services.pinpoint.model.SegmentResponse)

Example 2 with SegmentResponse

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

the class CreateSegment method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage: " + "CreateSegment <appId>\n\n" + "Where:\n" + "  appId - the application ID to create a segment for.\n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String appId = args[0];
    PinpointClient pinpoint = PinpointClient.builder().region(Region.US_EAST_1).build();
    SegmentResponse result = createSegment(pinpoint, appId);
    System.out.println("Segment " + result.name() + " created.");
    System.out.println(result.segmentType());
    pinpoint.close();
}
Also used : PinpointClient(software.amazon.awssdk.services.pinpoint.PinpointClient) SegmentResponse(software.amazon.awssdk.services.pinpoint.model.SegmentResponse) CreateSegmentResponse(software.amazon.awssdk.services.pinpoint.model.CreateSegmentResponse)

Aggregations

SegmentResponse (software.amazon.awssdk.services.pinpoint.model.SegmentResponse)2 PinpointClient (software.amazon.awssdk.services.pinpoint.PinpointClient)1 CreateSegmentResponse (software.amazon.awssdk.services.pinpoint.model.CreateSegmentResponse)1 GetSegmentsRequest (software.amazon.awssdk.services.pinpoint.model.GetSegmentsRequest)1 GetSegmentsResponse (software.amazon.awssdk.services.pinpoint.model.GetSegmentsResponse)1 PinpointException (software.amazon.awssdk.services.pinpoint.model.PinpointException)1