Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Einige Methoden der Cloud Translation API lösen einen Vorgang mit langer Ausführungszeit aus.
Diese Methoden sind asynchron und der Vorgang ist möglicherweise noch nicht abgeschlossen, wenn die Methode eine Antwort zurückgibt. Sie können den Status eines Vorgangs überprüfen oder einen Vorgang auch abbrechen.
Vorgangsstatus
Das folgende Beispiel zeigt, wie Sie den Status eines Vorgangs abrufen.
REST
Rufen Sie die Methode get für die Ressource operation auf.
Ersetzen Sie diese Werte in den folgenden Anfragedaten:
PROJECT_NUMBER_OR_ID: Die numerische oder alphanumerische ID Ihres Google Cloud-Projekts
location-id: Der Standort, den Sie für Ihren Cloud Storage-Bucket ausgewählt haben
operation-id: die Vorgangs-ID, die Sie oben erhalten haben
HTTP-Methode und URL:
GET https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/location-id/operations/operation-id
Wenn Sie die Anfrage senden möchten, maximieren Sie eine der folgenden Optionen:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-02-01 (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."]]