AWS SDK を使用して MediaConvert トランスコードジョブを一覧表示する - AWS SDK コードサンプル

Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS GitHub

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS SDK を使用して MediaConvert トランスコードジョブを一覧表示する

次のコード例は、AWS Elemental MediaConvert トランスコーディングジョブを一覧表示する方法を示しています。

.NET
AWS SDK for .NET
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

エンドポイントを取得し、クライアントを設定します。

// 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"]; // Load the customer endpoint, if it is known. // When you know what your Region-specific endpoint is, set it here, or set it in your settings.local.json file. var mediaConvertEndpoint = _configuration["mediaConvertEndpoint"]; Console.WriteLine("Welcome to the MediaConvert Create Job example."); // If you don't have the customer-specific endpoint, request it here. if (string.IsNullOrEmpty(mediaConvertEndpoint)) { Console.WriteLine("Getting customer-specific MediaConvert endpoint."); AmazonMediaConvertClient client = new AmazonMediaConvertClient(); DescribeEndpointsRequest describeRequest = new DescribeEndpointsRequest(); DescribeEndpointsResponse describeResponse = await client.DescribeEndpointsAsync(describeRequest); mediaConvertEndpoint = describeResponse.Endpoints[0].Url; } Console.WriteLine(new string('-', 80)); Console.WriteLine($"Using endpoint {mediaConvertEndpoint}."); Console.WriteLine(new string('-', 80)); // Because you have a service URL for MediaConvert, you don't // need to set RegionEndpoint. If you do, the ServiceURL will // be overwritten. AmazonMediaConvertConfig mcConfig = new AmazonMediaConvertConfig { ServiceURL = mediaConvertEndpoint, }; AmazonMediaConvertClient mcClient = new AmazonMediaConvertClient(mcConfig); var wrapper = new MediaConvertWrapper(mcClient);

特定のステータスのジョブを一覧表示します。

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}."); });

ページネーターを使用してジョブを一覧表示します。

/// <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; }
  • API の詳細については、「 API リファレンスListJobs」の「」を参照してください。 AWS SDK for .NET

C++
SDK for C++
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

//! 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; }
  • API の詳細については、「 API リファレンスListJobs」の「」を参照してください。 AWS SDK for C++

CLI
AWS CLI

リージョン内のすべてのジョブの詳細を取得するには

次の例は、指定されたリージョンのすべてのジョブの情報をリクエストします。

aws mediaconvert list-jobs \ --endpoint-url https://abcd1234.mediaconvert.region-name-1.amazonaws.com \ --region region-name-1

アカウント固有のエンドポイントを取得するには、describe-endpoints を使用するか、エンドポイントを指定せずにコマンドを送信します。このサービスは、エラーとエンドポイントを返します。

詳細については、「 Elemental AWS ユーザーガイド」の「 Elemental MediaConvert ジョブの使用」を参照してください。 AWS MediaConvert

  • API の詳細については、「 コマンドリファレンスListJobs」の「」を参照してください。 AWS CLI

Java
SDK for Java 2.x
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

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 { 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 JOB ARN is : " + job.arn()); } } catch (MediaConvertException e) { System.out.println(e.toString()); System.exit(0); } } }
  • API の詳細については、「 API リファレンスListJobs」の「」を参照してください。 AWS SDK for Java 2.x

Kotlin
SDK for Kotlin
注記

には他にもがあります GitHub。用例一覧を検索し、AWS コードサンプルリポジトリでの設定と実行の方法を確認してください。

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}") } } }
  • API の詳細については、ListJobsAWS「 SDK for Kotlin API リファレンス」の「」を参照してください。