Übersetzungsanfrage mit einem Callback-Endpunkt validieren
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Validiert Übersetzungsanfragen durch Unterstützung eines Callback-Endpunkts, der darauf wartet, dass HTTP-Anfragen an diesem Endpunkt ankommen, und die Ausführung des Workflows zu einem späteren Zeitpunkt fortsetzt.
Weitere Informationen
Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["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"]],[],[],[],null,["# Validate a translation request using a callback endpoint\n\nValidates translation requests by supporting a callback endpoint that waits for HTTP requests to arrive at that endpoint, resuming the execution of the workflow at a later point in time.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Create a human-in-the-loop workflow using callbacks](/workflows/docs/tutorials/callbacks-firestore)\n\nCode sample\n-----------\n\n### YAML\n\n main:\n params: [translation_request]\n steps:\n - log_request:\n call: sys.log\n args:\n text: ${translation_request}\n - vars:\n assign:\n - exec_id: ${sys.get_env(\"GOOGLE_CLOUD_WORKFLOW_EXECUTION_ID\")}\n - text_to_translate: ${translation_request.text}\n - database_root: ${\"projects/\" + sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\") + \"/databases/(default)/documents/translations/\"}\n - log_translation_request:\n call: sys.log\n args:\n text: ${text_to_translate}\n\n - store_translation_request:\n call: googleapis.firestore.v1.projects.databases.documents.patch\n args:\n name: ${database_root + exec_id}\n updateMask:\n fieldPaths: ['text']\n body:\n fields:\n text:\n stringValue: ${text_to_translate}\n result: store_translation_request_result\n\n - translate:\n call: googleapis.translate.v2.translations.translate\n args:\n query:\n q: ${text_to_translate}\n target: \"FR\"\n format: \"text\"\n source: \"EN\"\n result: translation_result\n - assign_translation:\n assign:\n - translation: ${translation_result.data.translations[0].translatedText} \n - log_translation_result:\n call: sys.log\n args:\n text: ${translation}\n\n - store_translated_text:\n call: googleapis.firestore.v1.projects.databases.documents.patch\n args:\n name: ${database_root + exec_id}\n updateMask:\n fieldPaths: ['translation']\n body:\n fields:\n translation:\n stringValue: ${translation}\n result: store_translation_request_result \n\n - create_callback:\n call: events.create_callback_endpoint\n args:\n http_callback_method: \"POST\"\n result: callback_details\n - log_callback_details:\n call: sys.log\n args:\n text: ${callback_details}\n\n - store_callback_details:\n call: googleapis.firestore.v1.projects.databases.documents.patch\n args:\n name: ${database_root + exec_id}\n updateMask:\n fieldPaths: ['callback']\n body:\n fields:\n callback:\n stringValue: ${callback_details.url}\n result: store_callback_details_result\n\n - await_callback:\n call: events.await_callback\n args:\n callback: ${callback_details}\n timeout: 3600\n result: callback_request\n - assign_approval:\n assign:\n - approved: ${callback_request.http_request.body.approved}\n\n - store_approval:\n call: googleapis.firestore.v1.projects.databases.documents.patch\n args:\n name: ${database_root + exec_id}\n updateMask:\n fieldPaths: ['approved']\n body:\n fields:\n approved:\n booleanValue: ${approved}\n result: store_approval_result\n\n - return_outcome:\n return:\n text: ${text_to_translate}\n translation: ${translation}\n approved: ${approved}\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]