ListJobs.java - AWS Code Sample

ListJobs.java

ListJobs.java demonstrates how to get information about all completed AWS Elemental MediaConvert jobs.

/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://aws.amazon.com/apache2.0 * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES * OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and * limitations under the License. */ package com.example.mediaconvert; import software.amazon.awssdk.core.exception.SdkException; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.mediaconvert.MediaConvertClient; import software.amazon.awssdk.services.mediaconvert.model.ListJobsRequest; import software.amazon.awssdk.services.mediaconvert.model.DescribeEndpointsResponse; import software.amazon.awssdk.services.mediaconvert.model.DescribeEndpointsRequest; import software.amazon.awssdk.services.mediaconvert.model.ListJobsResponse; import software.amazon.awssdk.services.mediaconvert.model.Job; import java.net.URI; import java.util.List; public class ListJobs { public static void main(String[] args) { Region region = Region.US_WEST_2; MediaConvertClient mc = MediaConvertClient.builder() .region(region) .build(); listCompleteJobs(mc); } public static void listCompleteJobs(MediaConvertClient mc) { try { DescribeEndpointsResponse res = mc.describeEndpoints(DescribeEndpointsRequest.builder() .maxResults(20) .build()); if (res.endpoints().size() <= 0) { System.out.println("Cannot find MediaConvert service endpoint URL!"); System.exit(1); } String endpointURL = res.endpoints().get(0).url(); MediaConvertClient emc = MediaConvertClient.builder() .region(Region.US_WEST_2) .endpointOverride(URI.create(endpointURL)) .build(); ListJobsRequest jobsRequest = ListJobsRequest.builder() .maxResults(10) .status("COMPLETE") .build(); ListJobsResponse jobsResponse = emc.listJobs(jobsRequest); List<Job> jobs = jobsResponse.jobs(); for (Job job: jobs) { System.out.println("The ARN of the job is : "+job.arn()); } } catch (SdkException e) { System.out.println(e.toString()); } } }

Sample Details

Service: AWS Elemental MediaConvert

Last tested: 7/30/2020

Author: smacdon - AWS

Type: full-example