Vorlage abrufen (asynchron)

Zeigt, wie Metadaten und Laufzeitmetadaten zu einer Vorlage abgerufen werden.

Codebeispiel

C#

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Dataflow zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

using Google.Cloud.Dataflow.V1Beta3;
using System.Threading.Tasks;

public sealed partial class GeneratedTemplatesServiceClientSnippets
{
    /// <summary>Snippet for GetTemplateAsync</summary>
    /// <remarks>
    /// 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://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task GetTemplateRequestObjectAsync()
    {
        // Create client
        TemplatesServiceClient templatesServiceClient = await TemplatesServiceClient.CreateAsync();
        // Initialize request argument(s)
        GetTemplateRequest request = new GetTemplateRequest
        {
            ProjectId = "",
            GcsPath = "",
            View = GetTemplateRequest.Types.TemplateView.MetadataOnly,
            Location = "",
        };
        // Make the request
        GetTemplateResponse response = await templatesServiceClient.GetTemplateAsync(request);
    }
}

Java

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Dataflow zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import com.google.api.core.ApiFuture;
import com.google.dataflow.v1beta3.GetTemplateRequest;
import com.google.dataflow.v1beta3.GetTemplateResponse;
import com.google.dataflow.v1beta3.TemplatesServiceClient;

public class AsyncGetTemplate {

  public static void main(String[] args) throws Exception {
    asyncGetTemplate();
  }

  public static void asyncGetTemplate() throws Exception {
    // 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://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (TemplatesServiceClient templatesServiceClient = TemplatesServiceClient.create()) {
      GetTemplateRequest request =
          GetTemplateRequest.newBuilder()
              .setProjectId("projectId-894832108")
              .setLocation("location1901043637")
              .build();
      ApiFuture<GetTemplateResponse> future =
          templatesServiceClient.getTemplateCallable().futureCall(request);
      // Do something.
      GetTemplateResponse response = future.get();
    }
  }
}

Node.js

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Dataflow zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * 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.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The ID of the Cloud Platform project that the job belongs to.
 */
// const projectId = 'abc123'
/**
 *  Required. A Cloud Storage path to the template from which to
 *  create the job.
 *  Must be valid Cloud Storage URL, beginning with 'gs://'.
 */
// const gcsPath = 'abc123'
/**
 *  The view to retrieve. Defaults to METADATA_ONLY.
 */
// const view = {}
/**
 *  The regional endpoint
 *  (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) to
 *  which to direct the request.
 */
// const location = 'abc123'

// Imports the Dataflow library
const {TemplatesServiceClient} = require('@google-cloud/dataflow').v1beta3;

// Instantiates a client
const dataflowClient = new TemplatesServiceClient();

async function callGetTemplate() {
  // Construct request
  const request = {
  };

  // Run request
  const response = await dataflowClient.getTemplate(request);
  console.log(response);
}

callGetTemplate();

Python

Richten Sie die Standardanmeldedaten für Anwendungen ein, um sich bei Dataflow zu authentifizieren. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

# 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://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataflow_v1beta3

async def sample_get_template():
    # Create a client
    client = dataflow_v1beta3.TemplatesServiceAsyncClient()

    # Initialize request argument(s)
    request = dataflow_v1beta3.GetTemplateRequest(
        gcs_path="gcs_path_value",
    )

    # Make the request
    response = await client.get_template(request=request)

    # Handle the response
    print(response)

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.