
    (ph{#                     |    % S r SSKJr  SSKJr  SSKJr  Sr0 r\\	\
4   \S'   \4S jrSS	 jrS
 r " S S\5      rg)z=Wrap long-running operations returned from Google Cloud APIs.    )Dict)operations_pb2)json_formatztype.googleapis.com_TYPE_URL_MAPc                 @    U R                   R                  nU< SU< 3$ )zCompute a type URL for a klass.

:type klass: type
:param klass: class to be used as a factory for the given type

:type prefix: str
:param prefix: URL prefix for the type

:rtype: str
:returns: the URL, prefixed as appropriate
/)
DESCRIPTOR	full_name)klassprefixnames      R/var/www/html/venv/lib/python3.13/site-packages/google/cloud/operation/__init__.py_compute_type_urlr      s      %%Dd##    Nc                     Uc  [        U 5      nU[        ;   a"  [        U   U La  [        S[        U   < 35      eU [        U'   g)ae  Register a klass as the factory for a given type URL.

:type klass: :class:`type`
:param klass: class to be used as a factory for the given type

:type type_url: str
:param type_url: (Optional) URL naming the type. If not provided,
                 infers the URL from the type descriptor.

:raises ValueError: if a registration already exists for the URL.
Nz
Conflict: )r   r   
ValueError)r   type_urls     r   register_typer   ,   sF     $U+= "%/}X/FHII#M(r   c                 ^    [         U R                     nUR                  U R                  5      $ )ag  Convert an ``Any`` protobuf into the actual class.

Uses the type URL to do the conversion.

.. note::

    This assumes that the type URL is already registered.

:type any_pb: :class:`google.protobuf.any_pb2.Any`
:param any_pb: An any object to be converted.

:rtype: object
:returns: The instance (of the correct type) stored in the any
          instance.
)r   r   
FromStringvalue)any_pbr   s     r   	_from_anyr   A   s'      &//*EFLL))r   c                       \ rS rSrSrSr Sr Sr Sr Sr	S r
\S 5       r\S 5       r\S 5       rS	 rS
 rS rS rS rSrg)	OperationU   a4  Representation of a Google API Long-Running Operation.

.. _protobuf: https://github.com/googleapis/googleapis/blob/                  050400df0fdb16f63b63e9dee53819044bffc857/                  google/longrunning/operations.proto#L80
.. _service: https://github.com/googleapis/googleapis/blob/                 050400df0fdb16f63b63e9dee53819044bffc857/                 google/longrunning/operations.proto#L38
.. _JSON: https://cloud.google.com/speech/reference/rest/              v1beta1/operations#Operation

This wraps an operation `protobuf`_ object and attempts to
interact with the long-running operations `service`_ (specific
to a given API). (Some services also offer a `JSON`_
API that maps the same underlying data type.)

:type name: str
:param name: The fully-qualified path naming the operation.

:type client: :class:`~google.cloud.client.Client`
:param client: The client used to poll for the status of the operation.
               If the operation was created via JSON/HTTP, the client
               must own a :class:`~google.cloud._http.Connection`
               to send polling requests. If created via protobuf, the
               client must have a gRPC stub in the ``_operations_stub``
               attribute.

:type caller_metadata: dict
:param caller_metadata: caller-assigned metadata about the operation
NTc                 T    Xl         X l        UR                  5       U l        SU l        g )NF)r   clientcopycaller_metadata	_complete)selfr   r   r    s       r   __init__Operation.__init__   s$    	.335r   c                 ^    U " UR                   U40 UD6nUR                  U5        SUl        U$ )a  Factory:  construct an instance from a protobuf.

:type operation_pb:
    :class:`~google.longrunning.operations_pb2.Operation`
:param operation_pb: Protobuf to be parsed.

:type client: object: must provide ``_operations_stub`` accessor.
:param client: The client used to poll for the status of the operation.

:type caller_metadata: dict
:param caller_metadata: caller-assigned metadata about the operation

:rtype: :class:`Operation`
:returns: new instance, with attributes based on the protobuf.
T)r   _update_state
_from_grpc)clsoperation_pbr   r    results        r   from_pbOperation.from_pb   s6    " \&&B/B\* r   c                     [         R                  " U[        R                  " 5       5      nU " UR                  U40 UD6nUR                  U5        SUl        U$ )a  Factory: construct an instance from a dictionary.

:type operation: dict
:param operation: Operation as a JSON object.

:type client: :class:`~google.cloud.client.Client`
:param client: The client used to poll for the status of the operation.

:type caller_metadata: dict
:param caller_metadata: caller-assigned metadata about the operation

:rtype: :class:`Operation`
:returns: new instance, with attributes based on the protobuf.
F)r   	ParseDictr   r   r   r&   r'   )r(   	operationr   r    r)   r*   s         r   	from_dictOperation.from_dict   sQ      #,,Y8P8P8RS\&&B/B\*!r   c                     U R                   $ )zdHas the operation already completed?

:rtype: bool
:returns: True if already completed, else false.
)r!   r"   s    r   completeOperation.complete   s     ~~r   c                     [         R                  " U R                  S9nU R                  R                  R                  U5      $ )zPolls the status of the current operation.

Uses gRPC request to check.

:rtype: :class:`~google.longrunning.operations_pb2.Operation`
:returns: The latest status of the current operation.
)r   )r   GetOperationRequestr   r   _operations_stubGetOperation)r"   
request_pbs     r   _get_operation_rpcOperation._get_operation_rpc   s3     $77TYYG
{{++88DDr   c                     SU R                   < 3nU R                  R                  R                  SUS9n[        R
                  " U[        R                  " 5       5      $ )zChecks the status of the current operation.

Uses HTTP request to check.

:rtype: :class:`~google.longrunning.operations_pb2.Operation`
:returns: The latest status of the current operation.
zoperations/GET)methodpath)r   r   _connectionapi_requestr   r.   r   r   )r"   r@   api_responses      r   _get_operation_httpOperation._get_operation_http   sK     #'))-{{..::%d:S$$\>3K3K3MNNr   c                 d    U R                   (       a  U R                  5       $ U R                  5       $ )zChecks the status of the current operation.

:rtype: :class:`~google.longrunning.operations_pb2.Operation`
:returns: The latest status of the current operation.
)r'   r;   rD   r3   s    r   _get_operationOperation._get_operation   s)     ??**,,++--r   c                 (   UR                   (       a  SU l        UR                  S5      (       a  [        UR                  5      U l        UR                  S5      nUS:X  a  UR                  U l        gUS:X  a  [        UR                  5      U l        gg)zUpdate the state of the current object based on operation.

:type operation_pb:
    :class:`~google.longrunning.operations_pb2.Operation`
:param operation_pb: Protobuf to be parsed.
Tmetadatar*   errorresponseN)doner!   HasFieldr   rJ   
WhichOneofrK   rL   )r"   r)   result_types      r   r&   Operation._update_state   s{     !DN  ,,%l&;&;<DM"--h7'!%++DJJ&%l&;&;<DM 'r   c                     U R                   (       a  [        S5      eU R                  5       nU R                  U5        U R                   $ )zCheck if the operation has finished.

:rtype: bool
:returns: A boolean indicating if the current operation has completed.
:raises ValueError: if the operation
         has already completed.
zThe operation has completed.)r4   r   rG   r&   )r"   r)   s     r   pollOperation.poll   s=     ==;<<**,<(}}r   )r!   r    r   rK   rJ   r   rL   )__name__
__module____qualname____firstlineno____doc__targetrL   rK   rJ   r'   r#   classmethodr+   r0   propertyr4   r;   rD   rG   r&   rS   __static_attributes__ r   r   r   r   U   s    > FCH
 E
 H J  *  *  	E
O	.=&r   r   )N)rY   typingr   google.longrunningr   google.protobufr   _GOOGLE_APIS_PREFIXr   strtype__annotations__r   r   r   objectr   r^   r   r   <module>rg      sP    D  - ' , !#tCI # %8 $ $**(w wr   