There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListJobs with an AWS SDK or CLI
The following code examples show how to use ListJobs.
- .NET
-
- SDK for .NET
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. Set up the file locations, client, and wrapper.
// MediaConvert role Amazon Resource Name (ARN). // For information on creating this role, see // https://docs.aws.amazon.com/mediaconvert/latest/ug/creating-the-iam-role-in-mediaconvert-configured.html. var mediaConvertRole = _configuration["mediaConvertRoleARN"]; // Include the file input and output locations in settings.json or settings.local.json. var fileInput = _configuration["fileInput"]; var fileOutput = _configuration["fileOutput"]; AmazonMediaConvertClient mcClient = new AmazonMediaConvertClient(); var wrapper = new MediaConvertWrapper(mcClient);List the jobs with a particular status.
Console.WriteLine(new string('-', 80)); Console.WriteLine($"Listing all complete jobs."); var completeJobs = await wrapper.ListAllJobsByStatus(JobStatus.COMPLETE); completeJobs.ForEach(j => { Console.WriteLine($"Job {j.Id} created on {j.CreatedAt:d} has status {j.Status}."); });List the jobs using a paginator.
/// <summary> /// List all of the jobs with a particular status using a paginator. /// </summary> /// <param name="status">The status to use when listing jobs.</param> /// <returns>The list of jobs matching the status.</returns> public async Task<List<Job>> ListAllJobsByStatus(JobStatus? status = null) { var returnedJobs = new List<Job>(); var paginatedJobs = _amazonMediaConvert.Paginators.ListJobs( new ListJobsRequest { Status = status }); // Get the entire list using the paginator. await foreach (var job in paginatedJobs.Jobs) { returnedJobs.Add(job); } return returnedJobs; }-
For API details, see ListJobs in AWS SDK for .NET API Reference.
-
- C++
-
- SDK for C++
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. //! Retrieve a list of created jobs. /*! \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::MediaConvert::listJobs( const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::MediaConvert::MediaConvertClient client(clientConfiguration); bool result = true; Aws::String nextToken; // Used to handle paginated results. do { Aws::MediaConvert::Model::ListJobsRequest request; if (!nextToken.empty()) { request.SetNextToken(nextToken); } const Aws::MediaConvert::Model::ListJobsOutcome outcome = client.ListJobs( request); if (outcome.IsSuccess()) { const Aws::Vector<Aws::MediaConvert::Model::Job> &jobs = outcome.GetResult().GetJobs(); std::cout << jobs.size() << " jobs retrieved." << std::endl; for (const Aws::MediaConvert::Model::Job &job: jobs) { std::cout << " " << job.Jsonize().View().WriteReadable() << std::endl; } nextToken = outcome.GetResult().GetNextToken(); } else { std::cerr << "DescribeEndpoints error - " << outcome.GetError().GetMessage() << std::endl; result = false; break; } } while (!nextToken.empty()); return result; }-
For API details, see ListJobs in AWS SDK for C++ API Reference.
-
- CLI
-
- AWS CLI
-
To get details for all jobs in a region
The following
list-jobsexample requests the information for all of your jobs in the specified region.aws mediaconvert list-jobs \ --endpoint-urlhttps://abcd1234.mediaconvert.region-name-1.amazonaws.comTo get your account-specific endpoint, use
describe-endpoints, or send the command without the endpoint. The service returns an error and your endpoint.Output:
{ "Jobs": [ { "AccelerationStatus": "NOT_APPLICABLE", "Arn": "arn:aws:mediaconvert:region-name-1:123456789012:jobs/1234567891234-abc123", "CreatedAt": "2024-04-01T17:35:12+00:00", "Id": "1234567891234-abc123", "Priority": 0, "Queue": "arn:aws:mediaconvert:region-name-1:123456789012:queues/Default", "Role": "arn:aws:iam::123456789012:role/MediaConvertServiceRole", "Settings": { "Inputs": [ { "FileInput": "s3://amzn-s3-demo-bucket/input/file-name.mp4" } ], "OutputGroups": [ { "Name": "File Group", "OutputGroupSettings": { "Type": "FILE_GROUP_SETTINGS", "FileGroupSettings": { "Destination": "s3://amzn-s3-demo-bucket/output/" } }, "Outputs": [ { "ContainerSettings": { "Container": "MP4", "Mp4Settings": { "CslgAtom": "INCLUDE", "FreeSpaceBox": "EXCLUDE", "MoovPlacement": "PROGRESSIVE_DOWNLOAD" } }, "VideoDescription": { "Width": 1920, "Height": 1080, "CodecSettings": { "Codec": "H_264", "H264Settings": { "MaxBitrate": 10000000, "RateControlMode": "QVBR" } } }, "AudioDescriptions": [ { "CodecSettings": { "Codec": "AAC", "AacSettings": { "Bitrate": 96000, "CodingMode": "CODING_MODE_2_0", "SampleRate": 48000 } } } ] } ] } ] }, "Status": "PROGRESSING", "StatusUpdateInterval": "SECONDS_60", "Timing": { "StartTime": "2024-04-01T17:35:14+00:00", "SubmitTime": "2024-04-01T17:35:12+00:00" }, "UserMetadata": {}, "CurrentPhase": "TRANSCODING", "JobPercentComplete": 45 }, { "AccelerationStatus": "NOT_APPLICABLE", "Arn": "arn:aws:mediaconvert:region-name-1:123456789012:jobs/1234567890987-1ab2c3", "CreatedAt": "2024-04-01T16:20:01+00:00", "Id": "1234567890987-1ab2c3", "Priority": 0, "Queue": "arn:aws:mediaconvert:region-name-1:123456789012:queues/Default", "Role": "arn:aws:iam::123456789012:role/MediaConvertServiceRole", "Settings": { "Inputs": [ { "FileInput": "s3://amzn-s3-demo-bucket/input/file-name.mp4" } ], "OutputGroups": [ { "Name": "File Group", "OutputGroupSettings": { "Type": "FILE_GROUP_SETTINGS", "FileGroupSettings": { "Destination": "s3://amzn-s3-demo-bucket/output/" } }, "Outputs": [ { "ContainerSettings": { "Container": "MP4", "Mp4Settings": { "CslgAtom": "INCLUDE", "FreeSpaceBox": "EXCLUDE", "MoovPlacement": "PROGRESSIVE_DOWNLOAD" } }, "VideoDescription": { "Width": 1920, "Height": 1080, "CodecSettings": { "Codec": "H_264", "H264Settings": { "MaxBitrate": 10000000, "RateControlMode": "QVBR" } } }, "AudioDescriptions": [ { "CodecSettings": { "Codec": "AAC", "AacSettings": { "Bitrate": 96000, "CodingMode": "CODING_MODE_2_0", "SampleRate": 48000 } } } ] } ] } ] }, "Status": "COMPLETE", "StatusUpdateInterval": "SECONDS_60", "Timing": { "FinishTime": "2024-04-01T16:22:48+00:00", "StartTime": "2024-04-01T16:20:03+00:00", "SubmitTime": "2024-04-01T16:20:01+00:00" }, "UserMetadata": {} } ] }For more information, see Working with jobs in the AWS Elemental MediaConvert User Guide.
-
For API details, see ListJobs
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. 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 software.amazon.awssdk.services.mediaconvert.model.MediaConvertException; import java.net.URI; import java.util.List; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListJobs { public static void main(String[] args) { Region region = Region.US_WEST_2; MediaConvertClient mc = MediaConvertClient.builder() .region(region) .build(); listCompleteJobs(mc); mc.close(); } public static void listCompleteJobs(MediaConvertClient mc) { try { // Create the ListJobsRequest ListJobsRequest jobsRequest = ListJobsRequest.builder() .maxResults(10) .status("COMPLETE") .build(); // Call the listJobs operation ListJobsResponse jobsResponse = mc.listJobs(jobsRequest); List<Job> jobs = jobsResponse.jobs(); for (Job job : jobs) { System.out.println("The JOB ARN is : " + job.arn()); } } catch (MediaConvertException e) { System.out.println(e.toString()); System.exit(0); } } }-
For API details, see ListJobs in AWS SDK for Java 2.x API Reference.
-
- Kotlin
-
- SDK for Kotlin
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. suspend fun listCompleteJobs(mcClient: MediaConvertClient) { val describeEndpoints = DescribeEndpointsRequest { maxResults = 20 } val res = mcClient.describeEndpoints(describeEndpoints) if (res.endpoints?.size!! <= 0) { println("Cannot find MediaConvert service endpoint URL!") exitProcess(0) } val endpointURL = res.endpoints!![0].url!! val mediaConvert = MediaConvertClient.fromEnvironment { region = "us-west-2" endpointProvider = MediaConvertEndpointProvider { Endpoint(endpointURL) } } val jobsRequest = ListJobsRequest { maxResults = 10 status = JobStatus.fromValue("COMPLETE") } val jobsResponse = mediaConvert.listJobs(jobsRequest) val jobs = jobsResponse.jobs if (jobs != null) { for (job in jobs) { println("The JOB ARN is ${job.arn}") } } }-
For API details, see ListJobs
in AWS SDK for Kotlin API reference.
-