Vorlage starten (asynchron)
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Zeigt, wie eine Vorlage gestartet wird.
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"]],[],[[["\u003cp\u003eThis content demonstrates how to use the \u003ccode\u003eLaunchTemplate\u003c/code\u003e function, using code examples in C#, Java, Node.js, and Python, to launch a template in Google Cloud Dataflow.\u003c/p\u003e\n"],["\u003cp\u003eEach code example provides guidance on setting up authentication for Dataflow using Application Default Credentials, along with a link to further instructions.\u003c/p\u003e\n"],["\u003cp\u003eThe code examples are provided as templates that may need modification to work, such as inputting correct values for project ID, file path and location.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLaunchTemplate\u003c/code\u003e function requires a \u003ccode\u003eLaunchTemplateRequest\u003c/code\u003e object to be initialized, which includes parameters like \u003ccode\u003eprojectId\u003c/code\u003e, \u003ccode\u003evalidateOnly\u003c/code\u003e, and \u003ccode\u003egcsPath\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach sample directs users to additional documentation and the Google Cloud sample browser for more code examples and filtering options.\u003c/p\u003e\n"]]],[],null,["# Launch a template (async)\n\nDemonstrates how to launch a template.\n\nCode sample\n-----------\n\n### C#\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n using https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.html;\n using System.Threading.Tasks;\n\n public sealed partial class GeneratedTemplatesServiceClientSnippets\n {\n /// \u003csummary\u003eSnippet for LaunchTemplateAsync\u003c/summary\u003e\n /// \u003cremarks\u003e\n /// This snippet has been automatically generated and should be regarded as a code template only.\n /// It will require modifications to work:\n /// - It may require correct/in-range values for request initialization.\n /// - It may require specifying regional endpoints when creating the service client as shown in\n /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.\n /// \u003c/remarks\u003e\n public async Task LaunchTemplateRequestObjectAsync()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html templatesServiceClient = await https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html#Google_Cloud_Dataflow_V1Beta3_TemplatesServiceClient_CreateAsync_System_Threading_CancellationToken_();\n // Initialize request argument(s)\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchTemplateRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchTemplateRequest.html\n {\n ProjectId = \"\",\n ValidateOnly = false,\n GcsPath = \"\",\n LaunchParameters = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchTemplateParameters.html(),\n Location = \"\",\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchTemplateResponse.html response = await templatesServiceClient.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html#Google_Cloud_Dataflow_V1Beta3_TemplatesServiceClient_LaunchTemplateAsync_Google_Cloud_Dataflow_V1Beta3_LaunchTemplateRequest_Google_Api_Gax_Grpc_CallSettings_(request);\n }\n }\n\n### Java\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.api.core.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.ApiFuture.html;\n import com.google.dataflow.v1beta3.LaunchTemplateParameters;\n import com.google.dataflow.v1beta3.LaunchTemplateRequest;\n import com.google.dataflow.v1beta3.LaunchTemplateResponse;\n import com.google.dataflow.v1beta3.TemplatesServiceClient;\n\n public class AsyncLaunchTemplate {\n\n public static void main(String[] args) throws Exception {\n asyncLaunchTemplate();\n }\n\n public static void asyncLaunchTemplate() throws Exception {\n // This snippet has been automatically generated and should be regarded as a code template only.\n // It will require modifications to work:\n // - It may require correct/in-range values for request initialization.\n // - It may require specifying regional endpoints when creating the service client as shown in\n // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library\n try (TemplatesServiceClient templatesServiceClient = TemplatesServiceClient.https://cloud.google.com/java/docs/reference/api-common/latest/com.google.api.core.SettableApiFuture.html#com_google_api_core_SettableApiFuture__V_create__()) {\n LaunchTemplateRequest request =\n LaunchTemplateRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setValidateOnly(true)\n .setLaunchParameters(LaunchTemplateParameters.newBuilder().build())\n .setLocation(\"location1901043637\")\n .build();\n ApiFuture\u003cLaunchTemplateResponse\u003e future =\n templatesServiceClient.launchTemplateCallable().futureCall(request);\n // Do something.\n LaunchTemplateResponse response = future.get();\n }\n }\n }\n\n### Node.js\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n /**\n * This snippet has been automatically generated and should be regarded as a code template only.\n * It will require modifications to work.\n * It may require correct/in-range values for request initialization.\n * TODO(developer): Uncomment these variables before running the sample.\n */\n /**\n * Required. The ID of the Cloud Platform project that the job belongs to.\n */\n // const projectId = 'abc123'\n /**\n * If true, the request is validated but not actually executed.\n * Defaults to false.\n */\n // const validateOnly = true\n /**\n * A Cloud Storage path to the template to use to create\n * the job.\n * Must be valid Cloud Storage URL, beginning with `gs://`.\n */\n // const gcsPath = 'abc123'\n /**\n * Parameters for launching a dynamic template.\n */\n // const dynamicTemplate = {}\n /**\n * The parameters of the template to launch. Part of the\n * body of the POST request.\n */\n // const launchParameters = {}\n /**\n * The regional endpoint \n * (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) to\n * which to direct the request.\n */\n // const location = 'abc123'\n\n // Imports the Dataflow library\n const {TemplatesServiceClient} = require('https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html').v1beta3;\n\n // Instantiates a client\n const dataflowClient = new https://cloud.google.com/nodejs/docs/reference/dataflow/latest/overview.html();\n\n async function callLaunchTemplate() {\n // Construct request\n const request = {\n };\n\n // Run request\n const response = await dataflowClient.launchTemplate(request);\n console.log(response);\n }\n\n callLaunchTemplate();\n\n### Python\n\n\nTo authenticate to Dataflow, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n # This snippet has been automatically generated and should be regarded as a\n # code template only.\n # It will require modifications to work:\n # - It may require correct/in-range values for request initialization.\n # - It may require specifying regional endpoints when creating the service\n # client as shown in:\n # https://googleapis.dev/python/google-api-core/latest/client_options.html\n from google.cloud import https://cloud.google.com/python/docs/reference/dataflow/latest/\n\n\n async def sample_launch_template():\n # Create a client\n client = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.templates_service.TemplatesServiceAsyncClient.html()\n\n # Initialize request argument(s)\n request = https://cloud.google.com/python/docs/reference/dataflow/latest/.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.types.LaunchTemplateRequest.html(\n gcs_path=\"gcs_path_value\",\n )\n\n # Make the request\n response = await client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.templates_service.TemplatesServiceAsyncClient.html#google_cloud_dataflow_v1beta3_services_templates_service_TemplatesServiceAsyncClient_launch_template(request=request)\n\n # Handle the response\n print(response)\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=dataflow)."]]