As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Long-Running Operations Client

Package for interacting with the google.longrunning.operations meta-API.

class google.api_core.operations_v1.AbstractOperationsClient(*, credentials: typing.Optional[google.auth.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.api_core.operations_v1.transports.base.OperationsTransport]] = None, client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]

Bases: google.api_core.operations_v1.abstract_operations_base_client.AbstractOperationsBaseClient

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.api_core.operations_v1.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.

Instantiates the operations client.

Parameters
  • credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

  • transport (Union[str, OperationsTransport]) – The transport to use. If set to None, a transport is chosen automatically.

  • client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. It won’t take effect if a transport instance is provided. (1) The api_endpoint property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto switch to the default mTLS endpoint if client certificate is present, this is the default value). However, the api_endpoint property takes precedence if provided. (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the client_cert_source property can be used to provide client certificate for mutual TLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

Raises

google.auth.exceptions.MutualTLSChannelError – If mutual TLS transport creation failed for any reason.

cancel_operation(name: Optional[str] = None, *, retry: Union[google.api_core.retry.retry_unary.Retry, object] = _MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, compression: Optional[grpc.Compression] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None[source]

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.api_core.operations_v1.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.api_core.operations_v1.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to Code.CANCELLED.

Parameters
  • name (str) –

    The name of the operation resource to be cancelled.

    This corresponds to the name field on the request instance; if request is provided, this should not be set.

  • retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

delete_operation(name: str, *, retry: Union[google.api_core.retry.retry_unary.Retry, object] = _MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, compression: Optional[grpc.Compression] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) None[source]

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 (str) –

    The name of the operation resource to be deleted.

    This corresponds to the name field on the request instance; if request is provided, this should not be set.

  • retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

classmethod from_service_account_file(filename: str, *args, **kwargs)[source]
Creates an instance of this client using the provided credentials

file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AbstractOperationsClient

classmethod from_service_account_info(info: dict, *args, **kwargs)[source]
Creates an instance of this client using the provided credentials

info.

Parameters
  • info (dict) – The service account private key info.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AbstractOperationsClient

classmethod from_service_account_json(filename: str, *args, **kwargs)
Creates an instance of this client using the provided credentials

file.

Parameters
  • filename (str) – The path to the service account private key json file.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AbstractOperationsClient

get_operation(name: str, *, retry: Union[google.api_core.retry.retry_unary.Retry, object] = _MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, compression: Optional[grpc.Compression] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.longrunning.operations_pb2.Operation[source]

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 (str) – The name of the operation resource.

  • retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Returns

This resource represents a long- running operation that is the result of a network API call.

Return type

google.longrunning.operations_pb2.Operation

list_operations(name: str, filter_: Optional[str] = None, *, page_size: Optional[int] = None, page_token: Optional[str] = None, retry: Union[google.api_core.retry.retry_unary.Retry, object] = _MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, compression: Optional[grpc.Compression] = _MethodDefault._DEFAULT_VALUE, metadata: Sequence[Tuple[str, str]] = ()) google.api_core.operations_v1.pagers.ListOperationsPager[source]

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 (str) – The name of the operation’s parent resource.

  • filter (str) – The standard list filter. This corresponds to the filter field on the request instance; if request is provided, this should not be set.

  • retry (google.api_core.retry.Retry) – Designation of what errors, if any, should be retried.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Returns

The response message for [Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].

Iterating over this object will yield results and resolve additional pages automatically.

Return type

google.api_core.operations_v1.pagers.ListOperationsPager

class google.api_core.operations_v1.AsyncOperationsRestClient(*, credentials: typing.Optional[google.auth.aio.credentials.Credentials] = None, transport: typing.Optional[typing.Union[str, google.api_core.operations_v1.transports.base.OperationsTransport]] = None, client_options: typing.Optional[google.api_core.client_options.ClientOptions] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>)[source]

Bases: google.api_core.operations_v1.abstract_operations_base_client.AbstractOperationsBaseClient

Manages long-running operations with a REST API service for the asynchronous client.

When an API method normally takes long time to complete, it can be designed to return [Operation][google.api_core.operations_v1.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.

Instantiates the operations client.

Parameters
  • credentials (Optional[google.auth.aio.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

  • transport (Union[str, OperationsTransport]) – The transport to use. If set to None, this defaults to ‘rest_asyncio’.

  • client_options (google.api_core.client_options.ClientOptions) – Custom options for the client. It won’t take effect if a transport instance is provided. (1) The api_endpoint property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: “always” (always use the default mTLS endpoint), “never” (always use the default regular endpoint) and “auto” (auto switch to the default mTLS endpoint if client certificate is present, this is the default value). However, the api_endpoint property takes precedence if provided. (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is “true”, then the client_cert_source property can be used to provide client certificate for mutual TLS transport. If not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or not set, no client certificate will be used.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

Raises

google.auth.exceptions.MutualTLSChannelError – If mutual TLS transport creation failed for any reason.

async cancel_operation(name: Optional[str] = None, *, retry=_MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ()) None[source]

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.api_core.operations_v1.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.api_core.operations_v1.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to Code.CANCELLED.

Parameters
  • name (str) –

    The name of the operation resource to be cancelled.

    This corresponds to the name field on the request instance; if request is provided, this should not be set.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

async delete_operation(name: str, *, retry=_MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ()) None[source]

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 (str) –

    The name of the operation resource to be deleted.

    This corresponds to the name field on the request instance; if request is provided, this should not be set.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

async get_operation(name: str, *, retry=_MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ()) google.longrunning.operations_pb2.Operation[source]

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 (str) – The name of the operation resource.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Returns

This resource represents a long- running operation that is the result of a network API call.

Return type

google.longrunning.operations_pb2.Operation

async list_operations(name: str, filter_: Optional[str] = None, *, page_size: Optional[int] = None, page_token: Optional[str] = None, retry=_MethodDefault._DEFAULT_VALUE, timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = ()) google.api_core.operations_v1.pagers_async.ListOperationsAsyncPager[source]

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 (str) – The name of the operation’s parent resource.

  • filter (str) – The standard list filter. This corresponds to the filter field on the request instance; if request is provided, this should not be set.

  • timeout (float) – The timeout for this request.

  • metadata (Sequence[Tuple[str, str]]) – Strings which should be sent along with the request as metadata.

Returns

The response message for [Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].

Iterating over this object will yield results and resolve additional pages automatically.

Return type

google.api_core.operations_v1.pagers.ListOperationsPager

class google.api_core.operations_v1.AsyncOperationsRestTransport(*, host: str = 'longrunning.googleapis.com', credentials: typing.Optional[google.auth.aio.credentials.Credentials] = None, credentials_file: typing.Optional[str] = None, scopes: typing.Optional[typing.Sequence[str]] = None, client_cert_source_for_mtls: typing.Optional[typing.Callable[[], typing.Tuple[bytes, bytes]]] = None, quota_project_id: typing.Optional[str] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>, always_use_jwt_access: typing.Optional[bool] = False, url_scheme: str = 'https', http_options: typing.Optional[typing.Dict] = None, path_prefix: str = 'v1')[source]

Bases: google.api_core.operations_v1.transports.base.OperationsTransport

Asynchronous REST backend transport for Operations.

Manages async 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.api_core.operations_v1.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.

This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.

It sends JSON representations of protocol buffers over HTTP/1.1

Instantiate the transport.

Parameters
  • host (Optional[str]) – The hostname to connect to.

  • credentials (Optional[google.auth.aio.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

  • always_use_jwt_access (Optional[bool]) – Whether self signed JWT should be used for service account credentials.

  • url_scheme – the protocol scheme for the API endpoint. Normally “https”, but for testing or local servers, “http” can be specified.

  • http_options – a dictionary of http_options for transcoding, to override the defaults from operations.proto. Each method has an entry with the corresponding http rules as value.

  • path_prefix – path prefix (usually represents API version). Set to “v1” by default.

class google.api_core.operations_v1.OperationsAsyncClient(channel, client_config=None)[source]

Bases: object

Async client for interacting with long-running operations.

Parameters
  • channel (aio.Channel) – The gRPC AsyncIO channel associated with the service that implements the google.longrunning.operations interface.

  • client_config (dict) – A dictionary of call options for each method. If not specified the default configuration is used.

async cancel_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. Clients can use get_operation() or service- specific 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> api.cancel_operation(name)
Parameters
  • name (str) – The name of the operation resource to be cancelled.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

Raises
async delete_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

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.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> api.delete_operation(name)
Parameters
  • name (str) – The name of the operation resource to be deleted.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Raises
async get_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

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.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> response = await api.get_operation(name)
Parameters
  • name (str) – The name of the operation resource.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Returns

The state of the

operation.

Return type

google.longrunning.operations_pb2.Operation

Raises

google.api_core.exceptions.GoogleAPICallError – If an error occurred while invoking the RPC, the appropriate GoogleAPICallError subclass will be raised.

async list_operations(name, filter_, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

Lists operations that match the specified filter in the request.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>>
>>> # Iterate over all results
>>> for operation in await api.list_operations(name):
>>>   # process operation
>>>   pass
>>>
>>> # Or iterate over results one page at a time
>>> iter = await api.list_operations(name)
>>> for page in iter.pages:
>>>   for operation in page:
>>>     # process operation
>>>     pass
Parameters
  • name (str) – The name of the operation collection.

  • filter (str) – The standard list filter.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Returns

An iterator that yields

google.longrunning.operations_pb2.Operation instances.

Return type

google.api_core.page_iterator.Iterator

Raises
class google.api_core.operations_v1.OperationsClient(channel, client_config=None)[source]

Bases: object

Client for interacting with long-running operations within a service.

Parameters
  • channel (grpc.Channel) – The gRPC channel associated with the service that implements the google.longrunning.operations interface.

  • client_config (dict) – A dictionary of call options for each method. If not specified the default configuration is used.

cancel_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. Clients can use get_operation() or service- specific 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 value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> api.cancel_operation(name)
Parameters
  • name (str) – The name of the operation resource to be cancelled.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Raises
delete_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

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.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> api.delete_operation(name)
Parameters
  • name (str) – The name of the operation resource to be deleted.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Raises
get_operation(name, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

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.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>> response = api.get_operation(name)
Parameters
  • name (str) – The name of the operation resource.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Returns

The state of the

operation.

Return type

google.longrunning.operations_pb2.Operation

Raises

google.api_core.exceptions.GoogleAPICallError – If an error occurred while invoking the RPC, the appropriate GoogleAPICallError subclass will be raised.

list_operations(name, filter_, retry=_MethodDefault._DEFAULT_VALUE, timeout=_MethodDefault._DEFAULT_VALUE, compression=_MethodDefault._DEFAULT_VALUE, metadata=None)[source]

Lists operations that match the specified filter in the request.

Example

>>> from google.api_core import operations_v1
>>> api = operations_v1.OperationsClient()
>>> name = ''
>>>
>>> # Iterate over all results
>>> for operation in api.list_operations(name):
>>>   # process operation
>>>   pass
>>>
>>> # Or iterate over results one page at a time
>>> iter = api.list_operations(name)
>>> for page in iter.pages:
>>>   for operation in page:
>>>     # process operation
>>>     pass
Parameters
  • name (str) – The name of the operation collection.

  • filter (str) – The standard list filter.

  • retry (google.api_core.retry.Retry) – The retry strategy to use when invoking the RPC. If unspecified, the default retry from the client configuration will be used. If None, then this method will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPC to complete. Note that if retry is used, this timeout applies to each individual attempt and the overall time it takes for this method to complete may be longer. If unspecified, the the default timeout in the client configuration is used. If None, then the RPC method will not time out.

  • compression (grpc.Compression) – An element of grpc.compression e.g. grpc.compression.Gzip.

  • metadata (Optional[List[Tuple[str, str]]]) – Additional gRPC metadata.

Returns

An iterator that yields

google.longrunning.operations_pb2.Operation instances.

Return type

google.api_core.page_iterator.Iterator

Raises
class google.api_core.operations_v1.OperationsRestTransport(*, host: str = 'longrunning.googleapis.com', credentials: typing.Optional[google.auth.credentials.Credentials] = None, credentials_file: typing.Optional[str] = None, scopes: typing.Optional[typing.Sequence[str]] = None, client_cert_source_for_mtls: typing.Optional[typing.Callable[[], typing.Tuple[bytes, bytes]]] = None, quota_project_id: typing.Optional[str] = None, client_info: google.api_core.gapic_v1.client_info.ClientInfo = <google.api_core.gapic_v1.client_info.ClientInfo object>, always_use_jwt_access: typing.Optional[bool] = False, url_scheme: str = 'https', http_options: typing.Optional[typing.Dict] = None, path_prefix: str = 'v1')[source]

Bases: google.api_core.operations_v1.transports.base.OperationsTransport

REST backend transport for Operations.

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.api_core.operations_v1.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.

This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation and call it.

It sends JSON representations of protocol buffers over HTTP/1.1

Instantiate the transport.

Parameters
  • host (Optional[str]) – The hostname to connect to.

  • credentials (Optional[google.auth.credentials.Credentials]) – The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment.

  • credentials_file (Optional[str]) – A file with credentials that can be loaded with google.auth.load_credentials_from_file(). This argument is ignored if channel is provided.

  • scopes (Optional(Sequence[str])) – A list of scopes. This argument is ignored if channel is provided.

  • client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]) – Client certificate to configure mutual TLS HTTP channel. It is ignored if channel is provided.

  • quota_project_id (Optional[str]) – An optional project to use for billing and quota.

  • client_info (google.api_core.gapic_v1.client_info.ClientInfo) – The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you’re developing your own client library.

  • always_use_jwt_access (Optional[bool]) – Whether self signed JWT should be used for service account credentials.

  • url_scheme – the protocol scheme for the API endpoint. Normally “https”, but for testing or local servers, “http” can be specified.

  • http_options – a dictionary of http_options for transcoding, to override the defaults from operations.proto. Each method has an entry with the corresponding http rules as value.

  • path_prefix – path prefix (usually represents API version). Set to “v1” by default.