Get a template

Stay organized with collections Save and categorize content based on your preferences.

Demonstrates how to get metadata and runtime metadata about a template.

Code sample

C#

using Google.Cloud.Dataflow.V1Beta3;

public sealed partial class GeneratedTemplatesServiceClientSnippets
{
    /// <summary>Snippet for GetTemplate</summary>
    /// <remarks>
    /// This snippet has been automatically generated for illustrative purposes only.
    /// It may require modifications to work in your environment.
    /// </remarks>
    public void GetTemplateRequestObject()
    {
        // Create client
        TemplatesServiceClient templatesServiceClient = TemplatesServiceClient.Create();
        // Initialize request argument(s)
        GetTemplateRequest request = new GetTemplateRequest
        {
            ProjectId = "",
            GcsPath = "",
            View = GetTemplateRequest.Types.TemplateView.MetadataOnly,
            Location = "",
        };
        // Make the request
        GetTemplateResponse response = templatesServiceClient.GetTemplate(request);
    }
}

Go


package main

import (
	"context"

	dataflow "cloud.google.com/go/dataflow/apiv1beta3"
	"cloud.google.com/go/dataflow/apiv1beta3/dataflowpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataflow.NewTemplatesClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataflowpb.GetTemplateRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataflow/apiv1beta3/dataflowpb#GetTemplateRequest.
	}
	resp, err := c.GetTemplate(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Ruby

require "google/cloud/dataflow/v1beta3"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Dataflow::V1beta3::TemplatesService::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Dataflow::V1beta3::GetTemplateRequest.new

# Call the get_template method.
result = client.get_template request

# The returned object is of type Google::Cloud::Dataflow::V1beta3::GetTemplateResponse.
p result

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.