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 visitPython 2 support on Google Cloud.

Long-Running Operations Client

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

classgoogle.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.ClientInfoobject>)[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 bedesigned to return [Operation][google.api_core.operations_v1.Operation] to theclient, and the client can use this interface to receive the realresponse asynchronously by polling the operation resource, or passthe operation resource to another API (such as Google Cloud Pub/SubAPI) to receive the response. Any API service that returnslong-running operations should implement theOperationsinterface so developers can have a consistent client experience.

Instantiates the operations client.

Parameters
  • credentials (Optional[google.auth.credentials.Credentials]) – Theauthorization credentials to attach to requests. Thesecredentials identify the application to the service; if noneare specified, the client will attempt to ascertain thecredentials from the environment.

  • transport (Union[str,OperationsTransport]) – Thetransport to use. If set to None, a transport is chosenautomatically.

  • client_options (google.api_core.client_options.ClientOptions) – Custom options for theclient. It won’t take effect if atransport instance is provided.(1) Theapi_endpoint property can be used to override thedefault endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINTenvironment variable can also be used to override the endpoint:“always” (always use the default mTLS endpoint), “never” (alwaysuse the default regular endpoint) and “auto” (auto switch to thedefault mTLS endpoint if client certificate is present, this isthe default value). However, theapi_endpoint property takesprecedence if provided.(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variableis “true”, then theclient_cert_source property can be usedto provide client certificate for mutual TLS transport. Ifnot provided, the default SSL client certificate will be used ifpresent. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or notset, 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 withAPI requests. IfNone, then default info will be used.Generally, you only need to set this if you’re developingyour 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, butsuccess is not guaranteed. If the server doesn’t support thismethod, it returnsgoogle.rpc.Code.UNIMPLEMENTED. Clientscan use[Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation]or other methods to check whether the cancellation succeeded orwhether the operation completed despite cancellation. Onsuccessful cancellation, the operation is not deleted; instead,it becomes an operation with an[Operation.error][google.api_core.operations_v1.Operation.error] value witha [google.rpc.Status.code][google.rpc.Status.code] of 1,corresponding toCode.CANCELLED.

Parameters
  • name (str) –

    The name of the operation resource tobe cancelled.

    This corresponds to thename fieldon therequest instance; ifrequest is provided, thisshould 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 besent 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 theclient is no longer interested in the operation result. It doesnot cancel the operation. If the server doesn’t support thismethod, it returnsgoogle.rpc.Code.UNIMPLEMENTED.

Parameters
  • name (str) –

    The name of the operation resource tobe deleted.

    This corresponds to thename fieldon therequest instance; ifrequest is provided, thisshould 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 besent along with the request as metadata.

classmethodfrom_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 jsonfile.

  • args – Additional arguments to pass to the constructor.

  • kwargs – Additional arguments to pass to the constructor.

Returns

The constructed client.

Return type

AbstractOperationsClient

classmethodfrom_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

classmethodfrom_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 jsonfile.

  • 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 resultat 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 besent along with the request as metadata.

Returns

This resource represents a long-running operation that is the result of anetwork 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 returnsUNIMPLEMENTED.

NOTE: thename binding allows API services to override thebinding to use different resource name schemes, such asusers/*/operations. To override the binding, API servicescan add a binding such as"/v1/{name=users/*}/operations" totheir service configuration. For backwards compatibility, thedefault name includes the operations collection id, howeveroverriding users must ensure the name binding is the parentresource, without the operations collection id.

Parameters
  • name (str) – The name of the operation’s parentresource.

  • filter (str) – The standard list filter.This corresponds to thefilter fieldon therequest instance; ifrequest is provided, thisshould 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 besent 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 andresolve additional pages automatically.

Return type

google.api_core.operations_v1.pagers.ListOperationsPager

classgoogle.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.ClientInfoobject>)[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 bedesigned to return [Operation][google.api_core.operations_v1.Operation] to theclient, and the client can use this interface to receive the realresponse asynchronously by polling the operation resource, or passthe operation resource to another API (such as Google Cloud Pub/SubAPI) to receive the response. Any API service that returnslong-running operations should implement theOperationsinterface so developers can have a consistent client experience.

Instantiates the operations client.

Parameters
  • credentials (Optional[google.auth.aio.credentials.Credentials]) – Theauthorization credentials to attach to requests. Thesecredentials identify the application to the service; if noneare specified, the client will attempt to ascertain thecredentials from the environment.

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

  • client_options (google.api_core.client_options.ClientOptions) – Custom options for theclient. It won’t take effect if atransport instance is provided.(1) Theapi_endpoint property can be used to override thedefault endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINTenvironment variable can also be used to override the endpoint:“always” (always use the default mTLS endpoint), “never” (alwaysuse the default regular endpoint) and “auto” (auto switch to thedefault mTLS endpoint if client certificate is present, this isthe default value). However, theapi_endpoint property takesprecedence if provided.(2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variableis “true”, then theclient_cert_source property can be usedto provide client certificate for mutual TLS transport. Ifnot provided, the default SSL client certificate will be used ifpresent. If GOOGLE_API_USE_CLIENT_CERTIFICATE is “false” or notset, 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 withAPI requests. IfNone, then default info will be used.Generally, you only need to set this if you’re developingyour own client library.

Raises

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

asynccancel_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, butsuccess is not guaranteed. If the server doesn’t support thismethod, it returnsgoogle.rpc.Code.UNIMPLEMENTED. Clientscan use[Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation]or other methods to check whether the cancellation succeeded orwhether the operation completed despite cancellation. Onsuccessful cancellation, the operation is not deleted; instead,it becomes an operation with an[Operation.error][google.api_core.operations_v1.Operation.error] value witha [google.rpc.Status.code][google.rpc.Status.code] of 1,corresponding toCode.CANCELLED.

Parameters
  • name (str) –

    The name of the operation resource tobe cancelled.

    This corresponds to thename fieldon therequest instance; ifrequest is provided, thisshould not be set.

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

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

asyncdelete_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 theclient is no longer interested in the operation result. It doesnot cancel the operation. If the server doesn’t support thismethod, it returnsgoogle.rpc.Code.UNIMPLEMENTED.

Parameters
  • name (str) –

    The name of the operation resource tobe deleted.

    This corresponds to thename fieldon therequest instance; ifrequest is provided, thisshould not be set.

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

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

asyncget_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 resultat 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 besent along with the request as metadata.

Returns

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

Return type

google.longrunning.operations_pb2.Operation

asynclist_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 returnsUNIMPLEMENTED.

NOTE: thename binding allows API services to override thebinding to use different resource name schemes, such asusers/*/operations. To override the binding, API servicescan add a binding such as"/v1/{name=users/*}/operations" totheir service configuration. For backwards compatibility, thedefault name includes the operations collection id, howeveroverriding users must ensure the name binding is the parentresource, without the operations collection id.

Parameters
  • name (str) – The name of the operation’s parentresource.

  • filter (str) – The standard list filter.This corresponds to thefilter fieldon therequest instance; ifrequest is provided, thisshould not be set.

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

  • metadata (Sequence[Tuple[str,str]]) – Strings which should besent 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 andresolve additional pages automatically.

Return type

google.api_core.operations_v1.pagers.ListOperationsPager

classgoogle.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.ClientInfoobject>,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 bedesigned to return [Operation][google.api_core.operations_v1.Operation] to theclient, and the client can use this interface to receive the realresponse asynchronously by polling the operation resource, or passthe operation resource to another API (such as Google Cloud Pub/SubAPI) to receive the response. Any API service that returnslong-running operations should implement theOperationsinterface so developers can have a consistent client experience.

This class defines the same methods as the primary client, so theprimary client can load the underlying transport implementationand 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]) – Theauthorization credentials to attach to requests. Thesecredentials identify the application to the service; if noneare specified, the client will attempt to ascertain thecredentials from the environment.

  • credentials_file (Optional[str]) –

    Deprecated. A file with credentials that canbe loaded withgoogle.auth.load_credentials_from_file().This argument is ignored ifchannel is provided. This argument will beremoved in the next major version ofgoogle-api-core.

    Warning

    Important: If you accept a credential configuration (credential JSON/File/Stream)from an external source for authentication to Google Cloud Platform, you mustvalidate it before providing it to any Google API or client library. Providing anunvalidated credential configuration to Google APIs or libraries can compromisethe security of your systems and data. For more information, refer toValidate credential configurations from external sources.

    https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

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

  • always_use_jwt_access (Optional[bool]) – Whether self signed JWT shouldbe 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 overridethe defaults from operations.proto. Each method has an entrywith the corresponding http rules as value.

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

classgoogle.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 theservice that implements thegoogle.longrunning.operationsinterface.

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

asynccancel_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 isnot guaranteed. Clients can useget_operation() or service-specific methods to check whether the cancellation succeeded or whetherthe operation completed despite cancellation. On successfulcancellation, the operation is not deleted; instead, it becomes anoperation with anOperation.error value with agoogle.rpc.Status.code of1, corresponding toCode.CANCELLED.

Example

>>>fromgoogle.api_coreimportoperations_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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

Raises
asyncdelete_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 theoperation result. It does not cancel the operation.

Example

>>>fromgoogle.api_coreimportoperations_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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

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

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

Raises
asyncget_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 intervalsas recommended by the API service.

Example

>>>fromgoogle.api_coreimportoperations_v1>>>api=operations_v1.OperationsClient()>>>name=''>>>response=awaitapi.get_operation(name)
Parameters
  • name (str) – The name of the operation resource.

  • retry (google.api_core.retry.Retry) – The retry strategy to usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

  • compression (grpc.Compression) – An element of grpc.compressione.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 appropriateGoogleAPICallError subclass will be raised.

asynclist_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

>>>fromgoogle.api_coreimportoperations_v1>>>api=operations_v1.OperationsClient()>>>name=''>>>>>># Iterate over all results>>>foroperationinawaitapi.list_operations(name):>>># process operation>>>pass>>>>>># Or iterate over results one page at a time>>>iter=awaitapi.list_operations(name)>>>forpageiniter.pages:>>>foroperationinpage:>>># 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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

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

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

Returns

An iterator that yields

google.longrunning.operations_pb2.Operation instances.

Return type

google.api_core.page_iterator.Iterator

Raises
classgoogle.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 servicethat implements thegoogle.longrunning.operations interface.

  • client_config (dict) – A dictionary of call options for each method. If not specifiedthe 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 isnot guaranteed. Clients can useget_operation() or service-specific methods to check whether the cancellation succeeded or whetherthe operation completed despite cancellation. On successfulcancellation, the operation is not deleted; instead, it becomes anoperation with anOperation.error value with agoogle.rpc.Status.code of1, corresponding toCode.CANCELLED.

Example

>>>fromgoogle.api_coreimportoperations_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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

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

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

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 theoperation result. It does not cancel the operation.

Example

>>>fromgoogle.api_coreimportoperations_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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

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

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

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 intervalsas recommended by the API service.

Example

>>>fromgoogle.api_coreimportoperations_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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

  • compression (grpc.Compression) – An element of grpc.compressione.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 appropriateGoogleAPICallError 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

>>>fromgoogle.api_coreimportoperations_v1>>>api=operations_v1.OperationsClient()>>>name=''>>>>>># Iterate over all results>>>foroperationinapi.list_operations(name):>>># process operation>>>pass>>>>>># Or iterate over results one page at a time>>>iter=api.list_operations(name)>>>forpageiniter.pages:>>>foroperationinpage:>>># 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 usewhen invoking the RPC. If unspecified, the default retry fromthe client configuration will be used. IfNone, then thismethod will not retry the RPC at all.

  • timeout (float) – The amount of time in seconds to wait for the RPCto complete. Note that ifretry is used, this timeoutapplies to each individual attempt and the overall time ittakes for this method to complete may be longer. Ifunspecified, the the default timeout in the clientconfiguration is used. IfNone, then the RPC method willnot time out.

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

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

Returns

An iterator that yields

google.longrunning.operations_pb2.Operation instances.

Return type

google.api_core.page_iterator.Iterator

Raises
classgoogle.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.ClientInfoobject>,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 bedesigned to return [Operation][google.api_core.operations_v1.Operation] to theclient, and the client can use this interface to receive the realresponse asynchronously by polling the operation resource, or passthe operation resource to another API (such as Google Cloud Pub/SubAPI) to receive the response. Any API service that returnslong-running operations should implement theOperationsinterface so developers can have a consistent client experience.

This class defines the same methods as the primary client, so theprimary client can load the underlying transport implementationand 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]) – Theauthorization credentials to attach to requests. Thesecredentials identify the application to the service; if noneare specified, the client will attempt to ascertain thecredentials from the environment.

  • credentials_file (Optional[str]) –

    Deprecated. A file with credentials that canbe loaded withgoogle.auth.load_credentials_from_file().This argument is ignored ifchannel is provided. This argument will beremoved in the next major version ofgoogle-api-core.

    Warning

    Important: If you accept a credential configuration (credential JSON/File/Stream)from an external source for authentication to Google Cloud Platform, you mustvalidate it before providing it to any Google API or client library. Providing anunvalidated credential configuration to Google APIs or libraries can compromisethe security of your systems and data. For more information, refer toValidate credential configuration from external sources.

    https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

  • scopes (Optional(Sequence[str])) – A list of scopes. This argument isignored ifchannel is provided.

  • client_cert_source_for_mtls (Callable[[],Tuple[bytes,bytes]]) – Clientcertificate to configure mutual TLS HTTP channel. It is ignoredifchannel is provided.

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

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

  • always_use_jwt_access (Optional[bool]) – Whether self signed JWT shouldbe 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 overridethe defaults from operations.proto. Each method has an entrywith the corresponding http rules as value.

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