장기 실행 작업(Advanced)
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Cloud Translation API의 일부 메서드는 장기 실행 작업을 반환합니다.
이러한 메서드는 비동기적이며 메서드가 응답을 반환하면 작업이 완료되지 않을 수 있습니다. 작업 상태를 확인하거나 작업을 취소할 수 있습니다.
작업 상태
다음은 작업 상태를 폴링하는 방법을 보여줍니다.
REST
operation
리소스의 get
메서드를 호출합니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- PROJECT_NUMBER_OR_ID: Google Cloud 프로젝트의 숫자 또는 영숫자 ID
- location-id: Cloud Storage 버킷을 위해 선택한 위치
- operation-id: 위에서 받은 작업 ID
HTTP 메서드 및 URL:
GET https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id
요청을 보내려면 다음 옵션 중 하나를 펼칩니다.
cURL(Linux, macOS, Cloud Shell)
다음 명령어를 실행합니다.
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_NUMBER_OR_ID" \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id"
PowerShell(Windows)
다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_NUMBER_OR_ID" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
{
"name": "projects/project-number/locations/location-id/operations/operation-id",
"metadata": {
"@type": "type.googleapis.com/google.cloud.translation.v3.SomeOperationMetadata",
"state": "SUCCEEDED",
"submitTime": "2019-11-27T22:59:40Z"
}
}
작업이 완료되면 state
값 SUCCEEDED
이 반환됩니다.
작업 취소
다음은 작업을 취소하는 방법을 보여줍니다.
REST
operation
리소스에서 cancel
메서드를 호출합니다.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- PROJECT_NUMBER_OR_ID: Google Cloud 프로젝트의 숫자 또는 영숫자 ID
- LOCATION: 작업을 시작할 때 선택한 위치
- OPERATION_ID: 취소할 작업의 ID
HTTP 메서드 및 URL:
POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel
요청을 보내려면 다음 옵션 중 하나를 펼칩니다.
cURL(Linux, macOS, Cloud Shell)
다음 명령어를 실행합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_NUMBER_OR_ID" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel"
PowerShell(Windows)
다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_NUMBER_OR_ID" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel" | Select-Object -Expand Content
성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.
추가 리소스
- 일반적인 문제 또는 오류를 해결하는 데 도움이 필요하면 문제 해결 페이지를 참조하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-01-31(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-01-31(UTC)"],[],[]]