AWS SDK를 사용하여 AWS Glue 작업 실행 가져오기
다음 코드 예제는 AWS Glue 작업 실행을 가져오는 방법을 보여줍니다.
- .NET
-
- AWS SDK for .NET
-
참고 GitHub에 더 많은 내용이 있습니다. AWS코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. /// <summary> /// Retrieves information about an AWS Glue job. /// </summary> /// <param name="glueClient">The initialized AWS Glue client.</param> /// <param name="jobName">The AWS Glue object for which to retrieve run /// information.</param> /// <returns>A Boolean value indicating whether information about /// the AWS Glue job runs was retrieved successfully.</returns> public static async Task<bool> GetJobRunsAsync(AmazonGlueClient glueClient, string jobName) { var runsRequest = new GetJobRunsRequest { JobName = jobName, MaxResults = 20, }; var response = await glueClient.GetJobRunsAsync(runsRequest); var jobRuns = response.JobRuns; if (jobRuns.Count > 0) { foreach (JobRun jobRun in jobRuns) { Console.WriteLine($"Job run state is {jobRun.JobRunState}"); Console.WriteLine($"Job run Id is {jobRun.Id}"); Console.WriteLine($"The Glue version is {jobRun.GlueVersion}"); } return true; } else { Console.WriteLine("No jobs found."); return false; } }
-
API에 대한 세부 정보는 AWS SDK for .NET API 참조의 GetJobRuns를 참조하세요.
-
- C++
-
- SDK for C++
-
참고 GitHub에 더 많은 내용이 있습니다. AWS코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region in which the bucket was created (overrides config file). // clientConfig.region = "us-east-1"; Aws::Glue::GlueClient client(clientConfig); Aws::Glue::Model::GetJobRunsRequest getJobRunsRequest; getJobRunsRequest.SetJobName(jobName); Aws::Glue::Model::GetJobRunsOutcome jobRunsOutcome = client.GetJobRuns( getJobRunsRequest); if (jobRunsOutcome.IsSuccess()) { std::vector<Aws::Glue::Model::JobRun> jobRuns = jobRunsOutcome.GetResult().GetJobRuns(); std::cout << "There are " << jobRuns.size() << " runs in the job '" << jobName << "'." << std::endl; for (size_t i = 0; i < jobRuns.size(); ++i) { std::cout << " " << i + 1 << ". " << jobRuns[i].GetJobName() << std::endl; } int runIndex = askQuestionForIntRange( Aws::String("Enter a number between 1 and ") + std::to_string(jobRuns.size()) + " to see details for a run: ", 1, static_cast<int>(jobRuns.size())); jobRunID = jobRuns[runIndex - 1].GetId(); } else { std::cerr << "Error getting job runs. " << jobRunsOutcome.GetError().GetMessage() << std::endl; }
-
API에 대한 세부 정보는 AWS SDK for C++ API 참조의 GetJobRuns를 참조하세요.
-
- JavaScript
-
- JavaScript V3용 SDK
-
참고 GitHub에 더 많은 내용이 있습니다. AWS코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. const getJobRuns = (jobName) => { const client = new GlueClient({ region: DEFAULT_REGION }); const command = new GetJobRunsCommand({ JobName: jobName, }); return client.send(command); };
-
API에 대한 세부 정보는 AWS SDK for JavaScript API 참조의 GetJobRuns를 참조하세요.
-
- PHP
-
- PHP용 SDK
-
참고 GitHub에 더 많은 내용이 있습니다. AWS코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. $jobName = 'test-job-' . $uniqid; $jobRuns = $glueService->getJobRuns($jobName); public function getJobRuns($jobName, $maxResults = 0, $nextToken = ''): Result { $arguments = ['JobName' => $jobName]; if ($maxResults) { $arguments['MaxResults'] = $maxResults; } if ($nextToken) { $arguments['NextToken'] = $nextToken; } return $this->glueClient->getJobRuns($arguments); }
-
API에 대한 세부 정보는 AWS SDK for PHP API 참조의 GetJobRuns를 참조하세요.
-
- Python
-
- Python용 SDK(Boto3)
-
참고 GitHub에 더 많은 내용이 있습니다. AWS코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. class GlueWrapper: """Encapsulates AWS Glue actions.""" def __init__(self, glue_client): """ :param glue_client: A Boto3 Glue client. """ self.glue_client = glue_client def get_job_runs(self, job_name): """ Gets information about runs that have been performed for a specific job definition. :param job_name: The name of the job definition to look up. :return: The list of job runs. """ try: response = self.glue_client.get_job_runs(JobName=job_name) except ClientError as err: logger.error( "Couldn't get job runs for %s. Here's why: %s: %s", job_name, err.response['Error']['Code'], err.response['Error']['Message']) raise else: return response['JobRuns']
-
API에 대한 세부 정보는 Python용 AWS SDK(Boto3) API 참조의 GetJobRuns를 참조하세요.
-
AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 AWS Glue와 AWS SDK 사용 섹션을 참조하세요. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.