Avvia un modello flessibile
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Mostra come avviare un modello flessibile.
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","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)."]]