Flexible Vorlage asynchron starten

Zeigt, wie eine flexible Vorlage asynchron gestartet wird.

Codebeispiel

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 GeneratedFlexTemplatesServiceClientSnippets
{
    /// <summary>Snippet for LaunchFlexTemplateAsync</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 LaunchFlexTemplateRequestObjectAsync()
    {
        // Create client
        FlexTemplatesServiceClient flexTemplatesServiceClient = await FlexTemplatesServiceClient.CreateAsync();
        // Initialize request argument(s)
        LaunchFlexTemplateRequest request = new LaunchFlexTemplateRequest
        {
            ProjectId = "",
            LaunchParameter = new LaunchFlexTemplateParameter(),
            Location = "",
            ValidateOnly = false,
        };
        // Make the request
        LaunchFlexTemplateResponse response = await flexTemplatesServiceClient.LaunchFlexTemplateAsync(request);
    }
}

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.FlexTemplatesServiceClient;
import com.google.dataflow.v1beta3.LaunchFlexTemplateParameter;
import com.google.dataflow.v1beta3.LaunchFlexTemplateRequest;
import com.google.dataflow.v1beta3.LaunchFlexTemplateResponse;

public class AsyncLaunchFlexTemplate {

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

  public static void asyncLaunchFlexTemplate() 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 (FlexTemplatesServiceClient flexTemplatesServiceClient =
        FlexTemplatesServiceClient.create()) {
      LaunchFlexTemplateRequest request =
          LaunchFlexTemplateRequest.newBuilder()
              .setProjectId("projectId-894832108")
              .setLaunchParameter(LaunchFlexTemplateParameter.newBuilder().build())
              .setLocation("location1901043637")
              .setValidateOnly(true)
              .build();
      ApiFuture<LaunchFlexTemplateResponse> future =
          flexTemplatesServiceClient.launchFlexTemplateCallable().futureCall(request);
      // Do something.
      LaunchFlexTemplateResponse response = future.get();
    }
  }
}

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. Parameter to launch a job form Flex Template.
 */
// const launchParameter = {}
/**
 *  Required. The regional endpoint 
 *  (https://cloud.google.com/dataflow/docs/concepts/regional-endpoints) to
 *  which to direct the request. E.g., us-central1, us-west1.
 */
// const location = 'abc123'
/**
 *  If true, the request is validated but not actually executed.
 *  Defaults to false.
 */
// const validateOnly = true

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

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

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

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

callLaunchFlexTemplate();

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_launch_flex_template():
    # Create a client
    client = dataflow_v1beta3.FlexTemplatesServiceAsyncClient()

    # Initialize request argument(s)
    request = dataflow_v1beta3.LaunchFlexTemplateRequest(
    )

    # Make the request
    response = await client.launch_flex_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.