public abstract class OperationsClient
Reference documentation and code samples for the Google.LongRunning class OperationsClient.
Operations client wrapper, for convenient use.
Derived Types
Namespace
Google.LongRunningAssembly
Google.LongRunning.dll
Remarks
Manages long-running operations with an API service.
When an API method normally takes long time to complete, it can be designed
to return [Operation][google.longrunning.Operation] to the client, and the client can use this
interface to receive the real response asynchronously by polling the
operation resource, or pass the operation resource to another API (such as
Google Cloud Pub/Sub API) to receive the response. Any API service that
returns long-running operations should implement the Operations
interface
so developers can have a consistent client experience.
Properties
Clock
public virtual IClock Clock { get; }
The clock used for timeouts, retries and polling.
Property Value | |
---|---|
Type | Description |
IClock |
DefaultEndpoint
public static string DefaultEndpoint { get; }
The default endpoint for the Operations service, which is a host of "longrunning.googleapis.com" and a port of 443.
Property Value | |
---|---|
Type | Description |
string |
DefaultPollSettings
public virtual PollSettings DefaultPollSettings { get; }
The poll settings used by default for repeated polling operations. May be null if no defaults have been set.
Property Value | |
---|---|
Type | Description |
PollSettings |
DefaultScopes
public static IReadOnlyList<string> DefaultScopes { get; }
The default Operations scopes.
Property Value | |
---|---|
Type | Description |
IReadOnlyListstring |
The default Operations scopes are:
GrpcClient
public virtual Operations.OperationsClient GrpcClient { get; }
The underlying gRPC Operations client
Property Value | |
---|---|
Type | Description |
OperationsOperationsClient |
Scheduler
public virtual IScheduler Scheduler { get; }
The scheduler used for timeouts, retries and polling.
Property Value | |
---|---|
Type | Description |
IScheduler |
ServiceMetadata
public static ServiceMetadata ServiceMetadata { get; }
The service metadata associated with this client type.
Property Value | |
---|---|
Type | Description |
ServiceMetadata |
Methods
CancelOperation(CancelOperationRequest, CallSettings)
public virtual void CancelOperation(CancelOperationRequest request, CallSettings callSettings = null)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
CancelOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
CancelOperationRequest request = new CancelOperationRequest { Name = "", };
// Make the request
operationsClient.CancelOperation(request);
CancelOperation(string, CallSettings)
public virtual void CancelOperation(string name, CallSettings callSettings = null)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be cancelled. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
operationsClient.CancelOperation(name);
CancelOperationAsync(CancelOperationRequest, CallSettings)
public virtual Task CancelOperationAsync(CancelOperationRequest request, CallSettings callSettings = null)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
CancelOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
CancelOperationRequest request = new CancelOperationRequest { Name = "", };
// Make the request
await operationsClient.CancelOperationAsync(request);
CancelOperationAsync(CancelOperationRequest, CancellationToken)
public virtual Task CancelOperationAsync(CancelOperationRequest request, CancellationToken cancellationToken)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
request |
CancelOperationRequest The request object containing all of the parameters for the API call. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
CancelOperationRequest request = new CancelOperationRequest { Name = "", };
// Make the request
await operationsClient.CancelOperationAsync(request);
CancelOperationAsync(string, CallSettings)
public virtual Task CancelOperationAsync(string name, CallSettings callSettings = null)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be cancelled. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
await operationsClient.CancelOperationAsync(name);
CancelOperationAsync(string, CancellationToken)
public virtual Task CancelOperationAsync(string name, CancellationToken cancellationToken)
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
corresponding to Code.CANCELLED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be cancelled. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
await operationsClient.CancelOperationAsync(name);
Create()
public static OperationsClient Create()
Synchronously creates a OperationsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use OperationsClientBuilder.
Returns | |
---|---|
Type | Description |
OperationsClient |
The created OperationsClient. |
CreateAsync(CancellationToken)
public static Task<OperationsClient> CreateAsync(CancellationToken cancellationToken = default)
Asynchronously creates a OperationsClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use OperationsClientBuilder.
Parameter | |
---|---|
Name | Description |
cancellationToken |
CancellationToken The CancellationToken to use while creating the client. |
Returns | |
---|---|
Type | Description |
TaskOperationsClient |
The task representing the created OperationsClient. |
DeleteOperation(DeleteOperationRequest, CallSettings)
public virtual void DeleteOperation(DeleteOperationRequest request, CallSettings callSettings = null)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
DeleteOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
DeleteOperationRequest request = new DeleteOperationRequest { Name = "", };
// Make the request
operationsClient.DeleteOperation(request);
DeleteOperation(string, CallSettings)
public virtual void DeleteOperation(string name, CallSettings callSettings = null)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be deleted. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
operationsClient.DeleteOperation(name);
DeleteOperationAsync(DeleteOperationRequest, CallSettings)
public virtual Task DeleteOperationAsync(DeleteOperationRequest request, CallSettings callSettings = null)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
DeleteOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
DeleteOperationRequest request = new DeleteOperationRequest { Name = "", };
// Make the request
await operationsClient.DeleteOperationAsync(request);
DeleteOperationAsync(DeleteOperationRequest, CancellationToken)
public virtual Task DeleteOperationAsync(DeleteOperationRequest request, CancellationToken cancellationToken)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
request |
DeleteOperationRequest The request object containing all of the parameters for the API call. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
DeleteOperationRequest request = new DeleteOperationRequest { Name = "", };
// Make the request
await operationsClient.DeleteOperationAsync(request);
DeleteOperationAsync(string, CallSettings)
public virtual Task DeleteOperationAsync(string name, CallSettings callSettings = null)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be deleted. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
await operationsClient.DeleteOperationAsync(name);
DeleteOperationAsync(string, CancellationToken)
public virtual Task DeleteOperationAsync(string name, CancellationToken cancellationToken)
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource to be deleted. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
Task |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
await operationsClient.DeleteOperationAsync(name);
GetEffectiveCallSettingsForGetOperation(CallSettings)
protected virtual CallSettings GetEffectiveCallSettingsForGetOperation(CallSettings callSettings)
Return the CallSettings that would be used by a call to GetOperation(GetOperationRequest, CallSettings), using the base settings of this client and the specified per-call overrides.
Parameter | |
---|---|
Name | Description |
callSettings |
CallSettings The per-call override, if any. |
Returns | |
---|---|
Type | Description |
CallSettings |
The effective call settings for a GetOperation RPC. |
This method is used when polling, to determine the appropriate timeout and cancellation token to use for each call.
GetOperation(GetOperationRequest, CallSettings)
public virtual Operation GetOperation(GetOperationRequest request, CallSettings callSettings = null)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
GetOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Operation |
The RPC response. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
GetOperationRequest request = new GetOperationRequest { Name = "", };
// Make the request
Operation response = operationsClient.GetOperation(request);
GetOperation(string, CallSettings)
public virtual Operation GetOperation(string name, CallSettings callSettings = null)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Operation |
The RPC response. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
Operation response = operationsClient.GetOperation(name);
GetOperationAsync(GetOperationRequest, CallSettings)
public virtual Task<Operation> GetOperationAsync(GetOperationRequest request, CallSettings callSettings = null)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
GetOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
GetOperationRequest request = new GetOperationRequest { Name = "", };
// Make the request
Operation response = await operationsClient.GetOperationAsync(request);
GetOperationAsync(GetOperationRequest, CancellationToken)
public virtual Task<Operation> GetOperationAsync(GetOperationRequest request, CancellationToken cancellationToken)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
request |
GetOperationRequest The request object containing all of the parameters for the API call. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
GetOperationRequest request = new GetOperationRequest { Name = "", };
// Make the request
Operation response = await operationsClient.GetOperationAsync(request);
GetOperationAsync(string, CallSettings)
public virtual Task<Operation> GetOperationAsync(string name, CallSettings callSettings = null)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Operation response = await operationsClient.GetOperationAsync(name);
GetOperationAsync(string, CancellationToken)
public virtual Task<Operation> GetOperationAsync(string name, CancellationToken cancellationToken)
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation resource. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Operation response = await operationsClient.GetOperationAsync(name);
ListOperations(ListOperationsRequest, CallSettings)
public virtual PagedEnumerable<ListOperationsResponse, Operation> ListOperations(ListOperationsRequest request, CallSettings callSettings = null)
Lists operations that match the specified filter in the request. If the
server doesn't support this method, it returns UNIMPLEMENTED
.
NOTE: the name
binding allows API services to override the binding
to use different resource name schemes, such as users/*/operations
. To
override the binding, API services can add a binding such as
"/v1/{name=users/*}/operations"
to their service configuration.
For backwards compatibility, the default name includes the operations
collection id, however overriding users must ensure the name binding
is the parent resource, without the operations collection id.
Parameters | |
---|---|
Name | Description |
request |
ListOperationsRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedEnumerableListOperationsResponseOperation |
A pageable sequence of Operation resources. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
ListOperationsRequest request = new ListOperationsRequest { Filter = "", Name = "", };
// Make the request
PagedEnumerable<ListOperationsResponse, Operation> response = operationsClient.ListOperations(request);
// Iterate over all response items, lazily performing RPCs as required
foreach (Operation 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 (ListOperationsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Operation 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<Operation> 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 (Operation 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;
ListOperations(string, string, string, int?, CallSettings)
public virtual PagedEnumerable<ListOperationsResponse, Operation> ListOperations(string name, string filter, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)
Lists operations that match the specified filter in the request. If the
server doesn't support this method, it returns UNIMPLEMENTED
.
NOTE: the name
binding allows API services to override the binding
to use different resource name schemes, such as users/*/operations
. To
override the binding, API services can add a binding such as
"/v1/{name=users/*}/operations"
to their service configuration.
For backwards compatibility, the default name includes the operations
collection id, however overriding users must ensure the name binding
is the parent resource, without the operations collection id.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation's parent resource. |
filter |
string The standard list filter. |
pageToken |
string The token returned from the previous request. A value of |
pageSize |
int The size of page to request. The response will not be larger than this, but may be smaller. A value of
|
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedEnumerableListOperationsResponseOperation |
A pageable sequence of Operation resources. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
string name = "";
string filter = "";
// Make the request
PagedEnumerable<ListOperationsResponse, Operation> response = operationsClient.ListOperations(name, filter);
// Iterate over all response items, lazily performing RPCs as required
foreach (Operation 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 (ListOperationsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Operation 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<Operation> 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 (Operation 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;
ListOperationsAsync(ListOperationsRequest, CallSettings)
public virtual PagedAsyncEnumerable<ListOperationsResponse, Operation> ListOperationsAsync(ListOperationsRequest request, CallSettings callSettings = null)
Lists operations that match the specified filter in the request. If the
server doesn't support this method, it returns UNIMPLEMENTED
.
NOTE: the name
binding allows API services to override the binding
to use different resource name schemes, such as users/*/operations
. To
override the binding, API services can add a binding such as
"/v1/{name=users/*}/operations"
to their service configuration.
For backwards compatibility, the default name includes the operations
collection id, however overriding users must ensure the name binding
is the parent resource, without the operations collection id.
Parameters | |
---|---|
Name | Description |
request |
ListOperationsRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedAsyncEnumerableListOperationsResponseOperation |
A pageable asynchronous sequence of Operation resources. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
ListOperationsRequest request = new ListOperationsRequest { Filter = "", Name = "", };
// Make the request
PagedAsyncEnumerable<ListOperationsResponse, Operation> response = operationsClient.ListOperationsAsync(request);
// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Operation 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((ListOperationsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Operation 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<Operation> 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 (Operation 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;
ListOperationsAsync(string, string, string, int?, CallSettings)
public virtual PagedAsyncEnumerable<ListOperationsResponse, Operation> ListOperationsAsync(string name, string filter, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)
Lists operations that match the specified filter in the request. If the
server doesn't support this method, it returns UNIMPLEMENTED
.
NOTE: the name
binding allows API services to override the binding
to use different resource name schemes, such as users/*/operations
. To
override the binding, API services can add a binding such as
"/v1/{name=users/*}/operations"
to their service configuration.
For backwards compatibility, the default name includes the operations
collection id, however overriding users must ensure the name binding
is the parent resource, without the operations collection id.
Parameters | |
---|---|
Name | Description |
name |
string The name of the operation's parent resource. |
filter |
string The standard list filter. |
pageToken |
string The token returned from the previous request. A value of |
pageSize |
int The size of page to request. The response will not be larger than this, but may be smaller. A value of
|
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedAsyncEnumerableListOperationsResponseOperation |
A pageable asynchronous sequence of Operation resources. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
string name = "";
string filter = "";
// Make the request
PagedAsyncEnumerable<ListOperationsResponse, Operation> response = operationsClient.ListOperationsAsync(name, filter);
// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Operation 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((ListOperationsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Operation 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<Operation> 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 (Operation 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 | |
---|---|
Type | Description |
Task |
A task representing the asynchronous shutdown operation. |
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.
WaitOperation(WaitOperationRequest, CallSettings)
public virtual Operation WaitOperation(WaitOperationRequest request, CallSettings callSettings = null)
Waits until the specified long-running operation is done or reaches at most
a specified timeout, returning the latest state. If the operation is
already done, the latest state is immediately returned. If the timeout
specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
timeout is used. If the server does not support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Note that this method is on a best-effort basis. It may return the latest
state before the specified timeout (including immediately), meaning even an
immediate response is no guarantee that the operation is done.
Parameters | |
---|---|
Name | Description |
request |
WaitOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
Operation |
The RPC response. |
// Create client
OperationsClient operationsClient = OperationsClient.Create();
// Initialize request argument(s)
WaitOperationRequest request = new WaitOperationRequest
{
Name = "",
Timeout = new Duration(),
};
// Make the request
Operation response = operationsClient.WaitOperation(request);
WaitOperationAsync(WaitOperationRequest, CallSettings)
public virtual Task<Operation> WaitOperationAsync(WaitOperationRequest request, CallSettings callSettings = null)
Waits until the specified long-running operation is done or reaches at most
a specified timeout, returning the latest state. If the operation is
already done, the latest state is immediately returned. If the timeout
specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
timeout is used. If the server does not support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Note that this method is on a best-effort basis. It may return the latest
state before the specified timeout (including immediately), meaning even an
immediate response is no guarantee that the operation is done.
Parameters | |
---|---|
Name | Description |
request |
WaitOperationRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
WaitOperationRequest request = new WaitOperationRequest
{
Name = "",
Timeout = new Duration(),
};
// Make the request
Operation response = await operationsClient.WaitOperationAsync(request);
WaitOperationAsync(WaitOperationRequest, CancellationToken)
public virtual Task<Operation> WaitOperationAsync(WaitOperationRequest request, CancellationToken cancellationToken)
Waits until the specified long-running operation is done or reaches at most
a specified timeout, returning the latest state. If the operation is
already done, the latest state is immediately returned. If the timeout
specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
timeout is used. If the server does not support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Note that this method is on a best-effort basis. It may return the latest
state before the specified timeout (including immediately), meaning even an
immediate response is no guarantee that the operation is done.
Parameters | |
---|---|
Name | Description |
request |
WaitOperationRequest The request object containing all of the parameters for the API call. |
cancellationToken |
CancellationToken A CancellationToken to use for this RPC. |
Returns | |
---|---|
Type | Description |
TaskOperation |
A Task containing the RPC response. |
// Create client
OperationsClient operationsClient = await OperationsClient.CreateAsync();
// Initialize request argument(s)
WaitOperationRequest request = new WaitOperationRequest
{
Name = "",
Timeout = new Duration(),
};
// Make the request
Operation response = await operationsClient.WaitOperationAsync(request);