Obtenir un modèle
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Explique comment obtenir des métadonnées et des métadonnées d'exécution sur un modèle.
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code examples demonstrating how to retrieve metadata and runtime metadata about a Dataflow template.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples are available in C#, Go, Java, Python, and Ruby, showcasing the process in different programming languages.\u003c/p\u003e\n"],["\u003cp\u003eEach code example requires setting up Application Default Credentials for authentication with Dataflow.\u003c/p\u003e\n"],["\u003cp\u003eThe examples all use \u003ccode\u003eGetTemplateRequest\u003c/code\u003e in some way to get a \u003ccode\u003eGetTemplateResponse\u003c/code\u003e, in order to obtain the requested metadata from a Dataflow template.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets are templates and require modifications, including correct value inputs and regional endpoints.\u003c/p\u003e\n"]]],[],null,["# Get a template\n\nDemonstrates how to get metadata and runtime metadata about 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 GetTemplate\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 GetTemplateRequestObject()\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.GetTemplateRequest.html request = new https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateRequest.html\n {\n ProjectId = \"\",\n GcsPath = \"\",\n View = https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateRequest.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateRequest.Types.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateRequest.Types.TemplateView.html.https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateRequest.Types.TemplateView.html#Google_Cloud_Dataflow_V1Beta3_GetTemplateRequest_Types_TemplateView_MetadataOnly,\n Location = \"\",\n };\n // Make the request\n https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Dataflow.V1Beta3/latest/Google.Cloud.Dataflow.V1Beta3.GetTemplateResponse.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_GetTemplate_Google_Cloud_Dataflow_V1Beta3_GetTemplateRequest_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.GetTemplateRequest{\n \t\t// TODO: Fill request struct fields.\n \t\t// See https://pkg.go.dev/cloud.google.com/go/dataflow/apiv1beta3/dataflowpb#GetTemplateRequest.\n \t}\n \tresp, err := c.GetTemplate(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.GetTemplateRequest;\n import com.google.dataflow.v1beta3.GetTemplateResponse;\n import com.google.dataflow.v1beta3.TemplatesServiceClient;\n\n public class SyncGetTemplate {\n\n public static void main(String[] args) throws Exception {\n syncGetTemplate();\n }\n\n public static void syncGetTemplate() 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 GetTemplateRequest request =\n GetTemplateRequest.newBuilder()\n .setProjectId(\"projectId-894832108\")\n .setLocation(\"location1901043637\")\n .build();\n GetTemplateResponse response = templatesServiceClient.getTemplate(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_get_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.GetTemplateRequest.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_get_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 get_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#get_template.\n #\n def get_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::GetTemplateRequest.new\n\n # Call the get_template method.\n result = client.get_template request\n\n # The returned object is of type Google::Cloud::Dataflow::V1beta3::GetTemplateResponse.\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)."]]