Cloud Run Admin v2 API - Class TasksClient (2.4.0)

public abstract class TasksClient

Reference documentation and code samples for the Cloud Run Admin v2 API class TasksClient.

Tasks client wrapper, for convenient use.

Inheritance

object > TasksClient

Derived Types

Namespace

Google.Cloud.Run.V2

Assembly

Google.Cloud.Run.V2.dll

Remarks

Cloud Run Task Control Plane API.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the Tasks service, which is a host of "run.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default Tasks scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

The default Tasks scopes are:

GrpcClient

public virtual Tasks.TasksClient GrpcClient { get; }

The underlying gRPC Tasks client

Property Value
TypeDescription
TasksTasksClient

LocationsClient

public virtual LocationsClient LocationsClient { get; }

The LocationsClient associated with this client.

Property Value
TypeDescription
LocationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

Create()

public static TasksClient Create()

Synchronously creates a TasksClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TasksClientBuilder.

Returns
TypeDescription
TasksClient

The created TasksClient.

CreateAsync(CancellationToken)

public static Task<TasksClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a TasksClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use TasksClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskTasksClient

The task representing the created TasksClient.

GetTask(GetTaskRequest, CallSettings)

public virtual Task GetTask(GetTaskRequest request, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
requestGetTaskRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

The RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
gcrv::GetTaskRequest request = new gcrv::GetTaskRequest
{
    TaskName = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]"),
};
// Make the request
gcrv::Task response = tasksClient.GetTask(request);

GetTask(TaskName, CallSettings)

public virtual Task GetTask(TaskName name, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
nameTaskName

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

The RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
gcrv::TaskName name = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]");
// Make the request
gcrv::Task response = tasksClient.GetTask(name);

GetTask(string, CallSettings)

public virtual Task GetTask(string name, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
namestring

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
Task

The RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/jobs/[JOB]/executions/[EXECUTION]/tasks/[TASK]";
// Make the request
gcrv::Task response = tasksClient.GetTask(name);

GetTaskAsync(GetTaskRequest, CallSettings)

public virtual Task<Task> GetTaskAsync(GetTaskRequest request, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
requestGetTaskRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::GetTaskRequest request = new gcrv::GetTaskRequest
{
    TaskName = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]"),
};
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(request);

GetTaskAsync(GetTaskRequest, CancellationToken)

public virtual Task<Task> GetTaskAsync(GetTaskRequest request, CancellationToken cancellationToken)

Gets information about a Task.

Parameters
NameDescription
requestGetTaskRequest

The request object containing all of the parameters for the API call.

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::GetTaskRequest request = new gcrv::GetTaskRequest
{
    TaskName = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]"),
};
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(request);

GetTaskAsync(TaskName, CallSettings)

public virtual Task<Task> GetTaskAsync(TaskName name, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
nameTaskName

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::TaskName name = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]");
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(name);

GetTaskAsync(TaskName, CancellationToken)

public virtual Task<Task> GetTaskAsync(TaskName name, CancellationToken cancellationToken)

Gets information about a Task.

Parameters
NameDescription
nameTaskName

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::TaskName name = gcrv::TaskName.FromProjectLocationJobExecutionTask("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]", "[TASK]");
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(name);

GetTaskAsync(string, CallSettings)

public virtual Task<Task> GetTaskAsync(string name, CallSettings callSettings = null)

Gets information about a Task.

Parameters
NameDescription
namestring

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/jobs/[JOB]/executions/[EXECUTION]/tasks/[TASK]";
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(name);

GetTaskAsync(string, CancellationToken)

public virtual Task<Task> GetTaskAsync(string name, CancellationToken cancellationToken)

Gets information about a Task.

Parameters
NameDescription
namestring

Required. The full name of the Task. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}/tasks/{task}

cancellationTokenCancellationToken

A CancellationToken to use for this RPC.

Returns
TypeDescription
TaskTask

A Task containing the RPC response.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
string name = "projects/[PROJECT]/locations/[LOCATION]/jobs/[JOB]/executions/[EXECUTION]/tasks/[TASK]";
// Make the request
gcrv::Task response = await tasksClient.GetTaskAsync(name);

ListTasks(ExecutionName, string, int?, CallSettings)

public virtual PagedEnumerable<ListTasksResponse, Task> ListTasks(ExecutionName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
parentExecutionName

Required. The Execution from which the Tasks should be listed. To list all Tasks across Executions of a Job, use "-" instead of Execution name. To list all Tasks across Jobs, use "-" instead of Job name. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListTasksResponseTask

A pageable sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
gcrv::ExecutionName parent = gcrv::ExecutionName.FromProjectLocationJobExecution("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]");
// Make the request
PagedEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasks(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (gcrv::Task item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (gcrv::ListTasksResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTasks(ListTasksRequest, CallSettings)

public virtual PagedEnumerable<ListTasksResponse, Task> ListTasks(ListTasksRequest request, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
requestListTasksRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListTasksResponseTask

A pageable sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
gcrv::ListTasksRequest request = new gcrv::ListTasksRequest
{
    ParentAsExecutionName = gcrv::ExecutionName.FromProjectLocationJobExecution("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]"),
    ShowDeleted = false,
};
// Make the request
PagedEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasks(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (gcrv::Task item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (gcrv::ListTasksResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTasks(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListTasksResponse, Task> ListTasks(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
parentstring

Required. The Execution from which the Tasks should be listed. To list all Tasks across Executions of a Job, use "-" instead of Execution name. To list all Tasks across Jobs, use "-" instead of Job name. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableListTasksResponseTask

A pageable sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = gcrv::TasksClient.Create();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/jobs/[JOB]/executions/[EXECUTION]";
// Make the request
PagedEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasks(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (gcrv::Task item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (gcrv::ListTasksResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTasksAsync(ExecutionName, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTasksResponse, Task> ListTasksAsync(ExecutionName parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
parentExecutionName

Required. The Execution from which the Tasks should be listed. To list all Tasks across Executions of a Job, use "-" instead of Execution name. To list all Tasks across Jobs, use "-" instead of Job name. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListTasksResponseTask

A pageable asynchronous sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::ExecutionName parent = gcrv::ExecutionName.FromProjectLocationJobExecution("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]");
// Make the request
PagedAsyncEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasksAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((gcrv::Task item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((gcrv::ListTasksResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTasksAsync(ListTasksRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListTasksResponse, Task> ListTasksAsync(ListTasksRequest request, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
requestListTasksRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListTasksResponseTask

A pageable asynchronous sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
gcrv::ListTasksRequest request = new gcrv::ListTasksRequest
{
    ParentAsExecutionName = gcrv::ExecutionName.FromProjectLocationJobExecution("[PROJECT]", "[LOCATION]", "[JOB]", "[EXECUTION]"),
    ShowDeleted = false,
};
// Make the request
PagedAsyncEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasksAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((gcrv::Task item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((gcrv::ListTasksResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListTasksAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListTasksResponse, Task> ListTasksAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists Tasks from an Execution of a Job.

Parameters
NameDescription
parentstring

Required. The Execution from which the Tasks should be listed. To list all Tasks across Executions of a Job, use "-" instead of Execution name. To list all Tasks across Jobs, use "-" instead of Job name. Format: projects/{project}/locations/{location}/jobs/{job}/executions/{execution}

pageTokenstring

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSizeint

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableListTasksResponseTask

A pageable asynchronous sequence of Task resources.

Example
// Create client
gcrv::TasksClient tasksClient = await gcrv::TasksClient.CreateAsync();
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]/jobs/[JOB]/executions/[EXECUTION]";
// Make the request
PagedAsyncEnumerable<gcrv::ListTasksResponse, gcrv::Task> response = tasksClient.ListTasksAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((gcrv::Task item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((gcrv::ListTasksResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (gcrv::Task item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<gcrv::Task> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (gcrv::Task item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.