Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Beberapa metode Cloud Translation API menampilkan operasi yang berjalan lama.
Metode ini bersifat asinkron, dan operasi mungkin tidak diselesaikan saat
metode menampilkan respons. Anda dapat memeriksa status operasi, atau membatalkan operasi.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Long-running operations (Advanced)\n\nSome methods of the Cloud Translation API return a long-running operation.\nThese methods are asynchronous, and the operation may not be completed when\nthe method returns a response. You can check on the status of an operation,\nor cancel an operation.\n\nOperation status\n----------------\n\nThe following shows how to poll an operation's status. \n\n### REST\n\nCall the `get` method for the\n[`operation`](/translate/docs/reference/rest/v3/projects.locations.operations)\nresource.\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e: the numeric or alphanumeric ID of your Google Cloud project\n- \u003cvar translate=\"no\"\u003elocation-id\u003c/var\u003e: the location you chose for your Cloud Storage bucket\n- \u003cvar translate=\"no\"\u003eoperation-id\u003c/var\u003e: operation ID you received above\n\n\nHTTP method and URL:\n\n```\nGET https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id\n```\n\nTo send your request, expand one of these options:\n\n#### curl (Linux, macOS, or Cloud Shell)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\ncurl -X GET \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_NUMBER_OR_ID\" \\\n \"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id\"\n```\n\n#### PowerShell (Windows)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_NUMBER_OR_ID\" }\n\nInvoke-WebRequest `\n -Method GET `\n -Headers $headers `\n -Uri \"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"name\": \"projects/project-number/locations/location-id/operations/operation-id\",\n \"metadata\": {\n \"@type\": \"type.googleapis.com/google.cloud.translation.v3.SomeOperationMetadata\",\n \"state\": \"SUCCEEDED\",\n \"submitTime\": \"2019-11-27T22:59:40Z\"\n }\n}\n```\n\nWhen the operation has completed,\na `state` value of `SUCCEEDED` is returned.\n\n\u003cbr /\u003e\n\nOperation cancellation\n----------------------\n\nThe following shows how to cancel an operation. \n\n### REST\n\nCall the `cancel` method on the [`operation`](/translate/docs/reference/rest/v3/projects.locations.operations)\nresource.\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e: the numeric or alphanumeric ID of your Google Cloud project.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: The location you chose when you started the operation.\n- \u003cvar translate=\"no\"\u003eOPERATION_ID\u003c/var\u003e: The ID of the operation to cancel.\n\n\nHTTP method and URL:\n\n```\nPOST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel\n```\n\nTo send your request, expand one of these options:\n\n#### curl (Linux, macOS, or Cloud Shell)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_NUMBER_OR_ID\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d \"\" \\\n \"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel\"\n```\n\n#### PowerShell (Windows)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_NUMBER_OR_ID\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -Uri \"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION_ID/operations/OPERATION_ID:cancel\" | Select-Object -Expand Content\n```\n\nYou should receive a successful status code (2xx) and an empty response.\n\n\u003cbr /\u003e\n\nAdditional resources\n--------------------\n\n- For help on resolving common issues or errors, see the [Troubleshooting](/translate/troubleshooting) page."]]