Show / Hide Table of Contents

Class OperationsClient

Operations client wrapper, for convenient use.

Inheritance
System.Object
OperationsClient
OperationsClientImpl
Inherited Members
System.Object.ToString()
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.LongRunning
Assembly: Google.LongRunning.dll
Syntax
public abstract class OperationsClient

Properties

Clock

The clock used for timeouts, retries and polling.

Declaration
public virtual IClock Clock { get; }
Property Value
Type Description
IClock

DefaultEndpoint

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

Declaration
public static ServiceEndpoint DefaultEndpoint { get; }
Property Value
Type Description
ServiceEndpoint

DefaultPollSettings

The poll settings used by default for repeated polling operations. May be null if no defaults have been set.

Declaration
public virtual PollSettings DefaultPollSettings { get; }
Property Value
Type Description
PollSettings

DefaultScopes

The default Operations scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.String>
Remarks

The default Operations scopes are:

    GrpcClient

    The underlying gRPC Operations client.

    Declaration
    public virtual Operations.OperationsClient GrpcClient { get; }
    Property Value
    Type Description
    Operations.OperationsClient

    Scheduler

    The scheduler used for timeouts, retries and polling.

    Declaration
    public virtual IScheduler Scheduler { get; }
    Property Value
    Type Description
    IScheduler

    Methods

    CancelOperation(CancelOperationRequest, CallSettings)

    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.

    Declaration
    public virtual void CancelOperation(CancelOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    CancelOperationRequest request

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

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    CancelOperation(String, CallSettings)

    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.

    Declaration
    public virtual void CancelOperation(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be cancelled.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    CancelOperationAsync(CancelOperationRequest, CallSettings)

    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.

    Declaration
    public virtual Task CancelOperationAsync(CancelOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    CancelOperationRequest request

    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
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    CancelOperationAsync(CancelOperationRequest, 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.

    Declaration
    public virtual Task CancelOperationAsync(CancelOperationRequest request, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancelOperationRequest request

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

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    CancelOperationAsync(String, CallSettings)

    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.

    Declaration
    public virtual Task CancelOperationAsync(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be cancelled.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    CancelOperationAsync(String, 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.

    Declaration
    public virtual Task CancelOperationAsync(string name, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be cancelled.

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    Create(ServiceEndpoint, OperationsSettings)

    Synchronously creates a OperationsClient, applying defaults for all unspecified settings, and creating a channel connecting to the given endpoint with application default credentials where necessary. See the example for how to use custom credentials.

    Declaration
    public static OperationsClient Create(ServiceEndpoint endpoint = null, OperationsSettings settings = null)
    Parameters
    Type Name Description
    ServiceEndpoint endpoint

    Optional ServiceEndpoint.

    OperationsSettings settings

    Optional OperationsSettings.

    Returns
    Type Description
    OperationsClient

    The created OperationsClient.

    Examples

    This sample shows how to create a client using default credentials:

    using Google.LongRunning;
    ...
    // When running on Google Cloud Platform this will use the project Compute Credential.
    // Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON
    // credential file to use that credential.
    OperationsClient client = OperationsClient.Create();

    This sample shows how to create a client using credentials loaded from a JSON file:

    using Google.LongRunning;
    using Google.Apis.Auth.OAuth2;
    using Grpc.Auth;
    using Grpc.Core;
    ...
    GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json");
    Channel channel = new Channel(
        OperationsClient.DefaultEndpoint.Host, OperationsClient.DefaultEndpoint.Port, cred.ToChannelCredentials());
    OperationsClient client = OperationsClient.Create(channel);
    ...
    // Shutdown the channel when it is no longer required.
    channel.ShutdownAsync().Wait();

    Create(CallInvoker, OperationsSettings)

    Creates a OperationsClient which uses the specified call invoker for remote operations.

    Declaration
    public static OperationsClient Create(CallInvoker callInvoker, OperationsSettings settings = null)
    Parameters
    Type Name Description
    CallInvoker callInvoker

    The CallInvoker for remote operations. Must not be null.

    OperationsSettings settings

    Optional OperationsSettings.

    Returns
    Type Description
    OperationsClient

    The created OperationsClient.

    Create(Channel, OperationsSettings)

    Creates a OperationsClient which uses the specified channel for remote operations.

    Declaration
    public static OperationsClient Create(Channel channel, OperationsSettings settings = null)
    Parameters
    Type Name Description
    Channel channel

    The Channel for remote operations. Must not be null.

    OperationsSettings settings

    Optional OperationsSettings.

    Returns
    Type Description
    OperationsClient

    The created OperationsClient.

    CreateAsync(ServiceEndpoint, OperationsSettings)

    Asynchronously creates a OperationsClient, applying defaults for all unspecified settings, and creating a channel connecting to the given endpoint with application default credentials where necessary. See the example for how to use custom credentials.

    Declaration
    public static Task<OperationsClient> CreateAsync(ServiceEndpoint endpoint = null, OperationsSettings settings = null)
    Parameters
    Type Name Description
    ServiceEndpoint endpoint

    Optional ServiceEndpoint.

    OperationsSettings settings

    Optional OperationsSettings.

    Returns
    Type Description
    System.Threading.Tasks.Task<OperationsClient>

    The task representing the created OperationsClient.

    Examples

    This sample shows how to create a client using default credentials:

    using Google.LongRunning;
    ...
    // When running on Google Cloud Platform this will use the project Compute Credential.
    // Or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a JSON
    // credential file to use that credential.
    OperationsClient client = await OperationsClient.CreateAsync();

    This sample shows how to create a client using credentials loaded from a JSON file:

    using Google.LongRunning;
    using Google.Apis.Auth.OAuth2;
    using Grpc.Auth;
    using Grpc.Core;
    ...
    GoogleCredential cred = GoogleCredential.FromFile("/path/to/credentials.json");
    Channel channel = new Channel(
        OperationsClient.DefaultEndpoint.Host, OperationsClient.DefaultEndpoint.Port, cred.ToChannelCredentials());
    OperationsClient client = OperationsClient.Create(channel);
    ...
    // Shutdown the channel when it is no longer required.
    await channel.ShutdownAsync();

    DeleteOperation(DeleteOperationRequest, CallSettings)

    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.

    Declaration
    public virtual void DeleteOperation(DeleteOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    DeleteOperationRequest request

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

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    DeleteOperation(String, CallSettings)

    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.

    Declaration
    public virtual void DeleteOperation(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be deleted.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    DeleteOperationAsync(DeleteOperationRequest, CallSettings)

    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.

    Declaration
    public virtual Task DeleteOperationAsync(DeleteOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    DeleteOperationRequest request

    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
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    DeleteOperationAsync(DeleteOperationRequest, 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.

    Declaration
    public virtual Task DeleteOperationAsync(DeleteOperationRequest request, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    DeleteOperationRequest request

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

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    DeleteOperationAsync(String, CallSettings)

    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.

    Declaration
    public virtual Task DeleteOperationAsync(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be deleted.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    DeleteOperationAsync(String, 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.

    Declaration
    public virtual Task DeleteOperationAsync(string name, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource to be deleted.

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A Task that completes when the RPC has completed.

    GetEffectiveCallSettingsForGetOperation(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.

    Declaration
    protected virtual CallSettings GetEffectiveCallSettingsForGetOperation(CallSettings callSettings)
    Parameters
    Type Name Description
    CallSettings callSettings

    The per-call override, if any.

    Returns
    Type Description
    CallSettings

    The effective call settings for a GetOperation RPC.

    Remarks

    This method is used when polling, to determine the appropriate timeout and cancellation token to use for each call.

    GetOperation(GetOperationRequest, CallSettings)

    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.

    Declaration
    public virtual Operation GetOperation(GetOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    GetOperationRequest request

    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.

    GetOperation(String, CallSettings)

    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.

    Declaration
    public virtual Operation GetOperation(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    Operation

    The RPC response.

    GetOperationAsync(GetOperationRequest, CallSettings)

    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.

    Declaration
    public virtual Task<Operation> GetOperationAsync(GetOperationRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    GetOperationRequest request

    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
    System.Threading.Tasks.Task<Operation>

    A Task containing the RPC response.

    GetOperationAsync(GetOperationRequest, 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.

    Declaration
    public virtual Task<Operation> GetOperationAsync(GetOperationRequest request, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    GetOperationRequest request

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

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task<Operation>

    A Task containing the RPC response.

    GetOperationAsync(String, CallSettings)

    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.

    Declaration
    public virtual Task<Operation> GetOperationAsync(string name, CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    System.Threading.Tasks.Task<Operation>

    A Task containing the RPC response.

    GetOperationAsync(String, 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.

    Declaration
    public virtual Task<Operation> GetOperationAsync(string name, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    System.String name

    The name of the operation resource.

    System.Threading.CancellationToken cancellationToken

    A System.Threading.CancellationToken to use for this RPC.

    Returns
    Type Description
    System.Threading.Tasks.Task<Operation>

    A Task containing the RPC response.

    ListOperations(ListOperationsRequest, CallSettings)

    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 &quot;/v1/{name=users/*}/operations&quot; 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.

    Declaration
    public virtual PagedEnumerable<ListOperationsResponse, Operation> ListOperations(ListOperationsRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    ListOperationsRequest request

    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
    PagedEnumerable<ListOperationsResponse, Operation>

    A pageable sequence of Operation resources.

    ListOperations(String, String, String, Nullable<Int32>, CallSettings)

    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 &quot;/v1/{name=users/*}/operations&quot; 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.

    Declaration
    public virtual PagedEnumerable<ListOperationsResponse, Operation> ListOperations(string name, string filter, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation's parent resource.

    System.String filter

    The standard list filter.

    System.String pageToken

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

    System.Nullable<System.Int32> pageSize

    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.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    PagedEnumerable<ListOperationsResponse, Operation>

    A pageable sequence of Operation resources.

    ListOperationsAsync(ListOperationsRequest, CallSettings)

    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 &quot;/v1/{name=users/*}/operations&quot; 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.

    Declaration
    public virtual PagedAsyncEnumerable<ListOperationsResponse, Operation> ListOperationsAsync(ListOperationsRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    ListOperationsRequest request

    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
    PagedAsyncEnumerable<ListOperationsResponse, Operation>

    A pageable asynchronous sequence of Operation resources.

    ListOperationsAsync(String, String, String, Nullable<Int32>, CallSettings)

    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 &quot;/v1/{name=users/*}/operations&quot; 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.

    Declaration
    public virtual PagedAsyncEnumerable<ListOperationsResponse, Operation> ListOperationsAsync(string name, string filter, string pageToken = null, int? pageSize = default(int? ), CallSettings callSettings = null)
    Parameters
    Type Name Description
    System.String name

    The name of the operation's parent resource.

    System.String filter

    The standard list filter.

    System.String pageToken

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

    System.Nullable<System.Int32> pageSize

    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.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    PagedAsyncEnumerable<ListOperationsResponse, Operation>

    A pageable asynchronous sequence of Operation resources.

    ShutdownDefaultChannelsAsync()

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

    Declaration
    public static Task ShutdownDefaultChannelsAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A task representing the asynchronous shutdown operation.

    Remarks

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

    Back to top