Vorlage starten
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 document provides code examples in C#, Go, Java, Python, and Ruby that demonstrate how to launch a Dataflow template.\u003c/p\u003e\n"],["\u003cp\u003eEach code example requires setting up Application Default Credentials for authentication to Dataflow.\u003c/p\u003e\n"],["\u003cp\u003eThe examples show how to create a \u003ccode\u003eLaunchTemplateRequest\u003c/code\u003e and use the \u003ccode\u003eLaunchTemplate\u003c/code\u003e method to initiate the template launch.\u003c/p\u003e\n"],["\u003cp\u003eAll snippets provided are templates that require modifications, such as specifying correct values for request initialization and configuring regional endpoints.\u003c/p\u003e\n"],["\u003cp\u003eThe document references the Google Cloud sample browser for additional code samples for other google products.\u003c/p\u003e\n"]]],[],null,["# Launch a template\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\n public sealed partial class GeneratedTemplatesServiceClientSnippets\n {\n /// \u003csummary\u003eSnippet for LaunchTemplate\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 void LaunchTemplateRequestObject()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html templatesServiceClient = 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_Create();\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 = templatesServiceClient.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.TemplatesServiceClient.html#Google_Cloud_Dataflow_V1Beta3_TemplatesServiceClient_LaunchTemplate_Google_Cloud_Dataflow_V1Beta3_LaunchTemplateRequest_Google_Api_Gax_Grpc_CallSettings_(request);\n }\n }\n\n### Go\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 package main\n\n import (\n \t\"context\"\n\n \tdataflow \"cloud.google.com/go/dataflow/apiv1beta3\"\n \tdataflowpb \"cloud.google.com/go/dataflow/apiv1beta3/dataflowpb\"\n )\n\n func main() {\n \tctx := context.Background()\n \t// This snippet has been automatically generated and should be regarded as a code template only.\n \t// It will require modifications to work:\n \t// - It may require correct/in-range values for request initialization.\n \t// - It may require specifying regional endpoints when creating the service client as shown in:\n \t// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options\n \tc, err := dataflow.https://cloud.google.com/go/docs/reference/cloud.google.com/go/dataflow/latest/apiv1beta3.html#cloud_google_com_go_dataflow_apiv1beta3_TemplatesClient_NewTemplatesClient(ctx)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \tdefer c.Close()\n\n \treq := &dataflowpb.LaunchTemplateRequest{\n \t\t// TODO: Fill request struct fields.\n \t\t// See https://pkg.go.dev/cloud.google.com/go/dataflow/apiv1beta3/dataflowpb#LaunchTemplateRequest.\n \t}\n \tresp, err := c.LaunchTemplate(ctx, req)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \t// TODO: Use resp.\n \t_ = resp\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.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 SyncLaunchTemplate {\n\n public static void main(String[] args) throws Exception {\n syncLaunchTemplate();\n }\n\n public static void syncLaunchTemplate() 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.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 LaunchTemplateResponse response = templatesServiceClient.launchTemplate(request);\n }\n }\n }\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 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.TemplatesServiceClient.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 = client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.templates_service.TemplatesServiceClient.html#google_cloud_dataflow_v1beta3_services_templates_service_TemplatesServiceClient_launch_template(request=request)\n\n # Handle the response\n print(response)\n\n### Ruby\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 require \"google/cloud/dataflow/v1beta3\"\n\n ##\n # Snippet for the launch_template call in the TemplatesService service\n #\n # This snippet has been automatically generated and should be regarded as a code\n # template only. 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 https://cloud.google.com/ruby/docs/reference.\n #\n # This is an auto-generated example demonstrating basic usage of\n # Google::Cloud::Dataflow::V1beta3::TemplatesService::Client#launch_template.\n #\n def launch_template\n # Create a client object. The client can be reused for multiple calls.\n client = Google::Cloud::Dataflow::V1beta3::TemplatesService::Client.new\n\n # Create a request. To set request fields, pass in keyword arguments.\n request = Google::Cloud::Dataflow::V1beta3::LaunchTemplateRequest.new\n\n # Call the launch_template method.\n result = client.launch_template request\n\n # The returned object is of type Google::Cloud::Dataflow::V1beta3::LaunchTemplateResponse.\n p result\n end\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)."]]