Use GetJob with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use GetJob with an AWS SDK or CLI

The following code examples show how to use GetJob.

.NET
AWS 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);

Get a job by its ID.

Console.WriteLine(new string('-', 80)); Console.WriteLine($"Getting job information for Job ID {jobId}"); var job = await wrapper.GetJobById(jobId); Console.WriteLine($"Job {job.Id} created on {job.CreatedAt:d} has status {job.Status}."); Console.WriteLine(new string('-', 80));
/// <summary> /// Get the job information for a job by its ID. /// </summary> /// <param name="jobId">The ID of the job.</param> /// <returns>The Job object.</returns> public async Task<Job> GetJobById(string jobId) { var jobResponse = await _amazonMediaConvert.GetJobAsync( new GetJobRequest { Id = jobId }); return jobResponse.Job; }
  • For API details, see GetJob 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 the information for a specific completed transcoding job. /*! \param jobID: A job ID. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::MediaConvert::getJob(const Aws::String &jobID, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::MediaConvert::MediaConvertClient client(clientConfiguration); Aws::MediaConvert::Model::GetJobRequest request; request.SetId(jobID); const Aws::MediaConvert::Model::GetJobOutcome outcome = client.GetJob( request); if (outcome.IsSuccess()) { std::cout << outcome.GetResult().GetJob().Jsonize().View().WriteReadable() << std::endl; } else { std::cerr << "DescribeEndpoints error - " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • For API details, see GetJob in AWS SDK for C++ API Reference.

CLI
AWS CLI

To get details for a particular job

The following example requests the information for the job with ID 1234567890987-1ab2c3, which in this example ended in an error.

aws mediaconvert get-job \ --endpoint-url https://abcd1234.mediaconvert.region-name-1.amazonaws.com \ --region region-name-1 \ --id 1234567890987-1ab2c3

To get your account-specific endpoint, use describe-endpoints, or send the command without the endpoint. The service returns an error and your endpoint.

If your request is successful, the service returns a JSON file with job information, including job settings, any returned errors, and other job data, as follows:

{ "Job": { "Status": "ERROR", "Queue": "arn:aws:mediaconvert:region-name-1:012345678998:queues/Queue1", "Settings": { ...<truncated for brevity>... }, "ErrorMessage": "Unable to open input file [s3://my-input-bucket/file-name.mp4]: [Failed probe/open: [Failed to read data: AssumeRole failed]]", "ErrorCode": 1434, "Role": "arn:aws:iam::012345678998:role/MediaConvertServiceRole", "Arn": "arn:aws:mediaconvert:us-west-1:012345678998:jobs/1234567890987-1ab2c3", "UserMetadata": {}, "Timing": { "FinishTime": 1517442131, "SubmitTime": 1517442103, "StartTime": 1517442104 }, "Id": "1234567890987-1ab2c3", "CreatedAt": 1517442103 } }

For more information, see Working with AWS Elemental MediaConvert Jobs in the AWS Elemental MediaConvert User Guide.

  • For API details, see GetJob 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.model.DescribeEndpointsResponse; import software.amazon.awssdk.services.mediaconvert.model.GetJobRequest; import software.amazon.awssdk.services.mediaconvert.model.DescribeEndpointsRequest; import software.amazon.awssdk.services.mediaconvert.model.GetJobResponse; import software.amazon.awssdk.services.mediaconvert.model.MediaConvertException; import software.amazon.awssdk.services.mediaconvert.MediaConvertClient; import java.net.URI; /** * 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 GetJob { public static void main(String[] args) { final String usage = "\n" + " <jobId> \n\n" + "Where:\n" + " jobId - The job id value.\n\n"; if (args.length != 1) { System.out.println(usage); System.exit(1); } String jobId = args[0]; Region region = Region.US_WEST_2; MediaConvertClient mc = MediaConvertClient.builder() .region(region) .build(); getSpecificJob(mc, jobId); mc.close(); } public static void getSpecificJob(MediaConvertClient mc, String jobId) { 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(); GetJobRequest jobRequest = GetJobRequest.builder() .id(jobId) .build(); GetJobResponse response = emc.getJob(jobRequest); System.out.println("The ARN of the job is " + response.job().arn()); } catch (MediaConvertException e) { System.out.println(e.toString()); System.exit(0); } } }
  • For API details, see GetJob 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 getSpecificJob( mcClient: MediaConvertClient, jobId: String?, ) { 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!!.get(0).url!! val mediaConvert = MediaConvertClient.fromEnvironment { region = "us-west-2" endpointProvider = MediaConvertEndpointProvider { Endpoint(endpointURL) } } val jobRequest = GetJobRequest { id = jobId } val response: GetJobResponse = mediaConvert.getJob(jobRequest) println("The ARN of the job is ${response.job?.arn}.") }
  • For API details, see GetJob in AWS SDK for Kotlin API reference.