启动 Flex 模板
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code examples in C#, Go, Java, Python, and Ruby that demonstrate how to launch a Flex Template using the Dataflow API.\u003c/p\u003e\n"],["\u003cp\u003eEach code sample requires users to set up Application Default Credentials for authentication to Dataflow, with a link provided for detailed instructions.\u003c/p\u003e\n"],["\u003cp\u003eThe code snippets provided are meant to serve as templates and will likely need modifications for project specific initialization values and potential regional endpoint specification.\u003c/p\u003e\n"],["\u003cp\u003eThe provided sample code showcases how to create a client and build a request object for the launchFlexTemplate function.\u003c/p\u003e\n"],["\u003cp\u003eAfter the method is called the snippet returns a response and an error, which the user must handle.\u003c/p\u003e\n"]]],[],null,["# Launch a Flex Template\n\nDemonstrates how to launch a Flex 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 GeneratedFlexTemplatesServiceClientSnippets\n {\n /// \u003csummary\u003eSnippet for LaunchFlexTemplate\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 LaunchFlexTemplateRequestObject()\n {\n // Create client\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.FlexTemplatesServiceClient.html flexTemplatesServiceClient = https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.FlexTemplatesServiceClient.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.FlexTemplatesServiceClient.html#Google_Cloud_Dataflow_V1Beta3_FlexTemplatesServiceClient_Create();\n // Initialize request argument(s)\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchFlexTemplateRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchFlexTemplateRequest.html\n {\n ProjectId = \"\",\n LaunchParameter = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchFlexTemplateParameter.html(),\n Location = \"\",\n ValidateOnly = false,\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.LaunchFlexTemplateResponse.html response = flexTemplatesServiceClient.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.FlexTemplatesServiceClient.html#Google_Cloud_Dataflow_V1Beta3_FlexTemplatesServiceClient_LaunchFlexTemplate_Google_Cloud_Dataflow_V1Beta3_LaunchFlexTemplateRequest_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_FlexTemplatesClient_NewFlexTemplatesClient(ctx)\n \tif err != nil {\n \t\t// TODO: Handle error.\n \t}\n \tdefer c.Close()\n\n \treq := &dataflowpb.LaunchFlexTemplateRequest{\n \t\t// TODO: Fill request struct fields.\n \t\t// See https://pkg.go.dev/cloud.google.com/go/dataflow/apiv1beta3/dataflowpb#LaunchFlexTemplateRequest.\n \t}\n \tresp, err := c.LaunchFlexTemplate(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.FlexTemplatesServiceClient;\n import com.google.dataflow.v1beta3.LaunchFlexTemplateParameter;\n import com.google.dataflow.v1beta3.LaunchFlexTemplateRequest;\n import com.google.dataflow.v1beta3.LaunchFlexTemplateResponse;\n\n public class SyncLaunchFlexTemplate {\n\n public static void main(String[] args) throws Exception {\n syncLaunchFlexTemplate();\n }\n\n public static void syncLaunchFlexTemplate() 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 (FlexTemplatesServiceClient flexTemplatesServiceClient =\n FlexTemplatesServiceClient.create()) {\n LaunchFlexTemplateRequest request =\n LaunchFlexTemplateRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setLaunchParameter(LaunchFlexTemplateParameter.newBuilder().build())\n .setLocation(\"location1901043637\")\n .setValidateOnly(true)\n .build();\n LaunchFlexTemplateResponse response = flexTemplatesServiceClient.launchFlexTemplate(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_flex_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.flex_templates_service.FlexTemplatesServiceClient.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.LaunchFlexTemplateRequest.html(\n )\n\n # Make the request\n response = client.https://cloud.google.com/python/docs/reference/dataflow/latest/google.cloud.dataflow_v1beta3.services.flex_templates_service.FlexTemplatesServiceClient.html#google_cloud_dataflow_v1beta3_services_flex_templates_service_FlexTemplatesServiceClient_launch_flex_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_flex_template call in the FlexTemplatesService 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::FlexTemplatesService::Client#launch_flex_template.\n #\n def launch_flex_template\n # Create a client object. The client can be reused for multiple calls.\n client = Google::Cloud::Dataflow::V1beta3::FlexTemplatesService::Client.new\n\n # Create a request. To set request fields, pass in keyword arguments.\n request = Google::Cloud::Dataflow::V1beta3::LaunchFlexTemplateRequest.new\n\n # Call the launch_flex_template method.\n result = client.launch_flex_template request\n\n # The returned object is of type Google::Cloud::Dataflow::V1beta3::LaunchFlexTemplateResponse.\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)."]]