Create a client to initiate a Dataproc workflow template

Creates a client using application default credentials to initiate a Dataproc workflow template. Use either the global or a regional endpoint.

Code sample

Python

Before trying this sample, follow the Python setup instructions in the Dataproc Quickstart Using Client Libraries. For more information, see the Dataproc Python API reference documentation.

if global_region:
    region = "global"
    # Use the default gRPC global endpoints.
    dataproc_workflow_client = dataproc_v1.WorkflowTemplateServiceClient()
else:
    region = get_region_from_zone(zone)
    # Use a regional gRPC endpoint. See:
    # https://cloud.google.com/dataproc/docs/concepts/regional-endpoints
    client_transport = workflow_template_service_grpc_transport.WorkflowTemplateServiceGrpcTransport(
        address="{}-dataproc.googleapis.com:443".format(region)
    )
    dataproc_workflow_client = dataproc_v1.WorkflowTemplateServiceClient(
        client_transport
    )