
    (ph                        S r SSKrSSKrSSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  \R                  \R                  \R                   \R"                  \R$                  \\R&                  \R(                  \R*                  \R,                  R.                  \R,                  R0                  \R,                  R2                  \R                  R4                  \R                  R6                  \R                  R8                  \R                  R:                  4r\R,                  R>                  \R,                  R@                  \R,                  RB                  \R,                  RD                  \R,                  RF                  \R,                  RH                  4r%S r&\	RN                  " \&S9r(  " S S	\)5      r*S
 r+S r,S r-S r.\*" \(\+S/5      r/ \*" \(\,S/5      r0 \*" \(\.S/5      r1g)zHelpers for configuring retries with exponential back-off.

See [Retry Strategy for Google Cloud Storage](https://cloud.google.com/storage/docs/retry-strategy#client-libraries)
    N)
exceptions)retry)InvalidResponsec                 f   [        U [        5      (       a  g[        U [        R                  5      (       a  U R                  [
        ;   $ [        U [        5      (       a  U R                  R                  [
        ;   $ [        U [        R                  5      (       a  [        U R                  S   5      $ g)z(Predicate for determining when to retry.Tr   F)
isinstance_RETRYABLE_TYPESapi_exceptionsGoogleAPICallErrorcode_RETRYABLE_STATUS_CODESr   responsestatus_codeauth_exceptionsTransportError_should_retryargs)excs    M/var/www/html/venv/lib/python3.13/site-packages/google/cloud/storage/retry.pyr   r   >   s    #'((	C::	;	;xx222	C	)	)||''+BBB	C77	8	8SXXa[))    )	predicatec                   $    \ rS rSrSrS rS rSrg)ConditionalRetryPolicyZ   a  A class for use when an API call is only conditionally safe to retry.

This class is intended for use in inspecting the API call parameters of an
API call to verify that any flags necessary to make the API call idempotent
(such as specifying an ``if_generation_match`` or related flag) are present.

It can be used in place of a ``retry.Retry`` object, in which case
``_http.Connection.api_request`` will pass the requested api call keyword
arguments into the ``conditional_predicate`` and return the ``retry_policy``
if the conditions are met.

:type retry_policy: class:`google.api_core.retry.Retry`
:param retry_policy: A retry object defining timeouts, persistence and which
    exceptions to retry.

:type conditional_predicate: callable
:param conditional_predicate: A callable that accepts exactly the number of
    arguments in ``required_kwargs``, in order, and returns True if the
    arguments have sufficient data to determine that the call is safe to
    retry (idempotent).

:type required_kwargs: list(str)
:param required_kwargs:
    A list of keyword argument keys that will be extracted from the API call
    and passed into the ``conditional predicate`` in order. For example,
    ``["query_params"]`` is commmonly used for preconditions in query_params.
c                 (    Xl         X l        X0l        g N)retry_policyconditional_predicaterequired_kwargs)selfr   r   r   s       r   __init__ConditionalRetryPolicy.__init__w   s    (%:".r   c                     U R                   " U R                   Vs/ s H  o!U   PM	     sn6 (       a  U R                  $ g s  snf r   r   r   r   )r   kwargskeys      r   "get_retry_policy_if_conditions_met9ConditionalRetryPolicy.get_retry_policy_if_conditions_met|   s>    %%t?S?S'T?Ss?S'TU$$$ (Us   ?r#   N)__name__
__module____qualname____firstlineno____doc__r    r&   __static_attributes__ r   r   r   r   Z   s    8/
r   r   c                 d    U R                  S5      SLnU R                  S5      SLnU=(       d    U$ )z>Return True if generation or if_generation_match is specified.
generationNifGenerationMatchget)query_paramsr0   if_generation_matchs      r   is_generation_specifiedr6      s:    !!,/t;J&**+>?tK,,,r   c                 ,    U R                  S5      SLnU$ )z4Return True if if_metageneration_match is specified.ifMetagenerationMatchNr2   )r4   if_metageneration_matchs     r   is_metageneration_specifiedr:      s    *../FGtS""r   c                 "    U SL=(       a    SU ;   $ )zReturn True if an etag is contained in the request body.

:type data: dict or None
:param data: A dict representing the request JSON body. If not passed, returns False.
Netagr.   datas    r   is_etag_in_datar?      s     t.$.r   c                     [        U 5      $ )zt
``is_etag_in_json`` is supported for backwards-compatibility reasons only;
please use ``is_etag_in_data`` instead.
)r?   r=   s    r   is_etag_in_jsonrA      s    
 4  r   r4   r>   )2r,   httprequestsrequests.exceptionsr   requests_exceptionsurllib3google.api_corer	   r   google.authr   google.cloud.storage.exceptionsr   TooManyRequestsInternalServerError
BadGatewayServiceUnavailableGatewayTimeoutConnectionErrorChunkedEncodingErrorTimeoutclientBadStatusLineIncompleteReadResponseNotReady	PoolErrorProtocolErrorSSLErrorTimeoutErrorr   TOO_MANY_REQUESTSREQUEST_TIMEOUTINTERNAL_SERVER_ERRORBAD_GATEWAYSERVICE_UNAVAILABLEGATEWAY_TIMEOUTr   r   RetryDEFAULT_RETRYobjectr   r6   r:   r?   rA   %DEFAULT_RETRY_IF_GENERATION_SPECIFIED)DEFAULT_RETRY_IF_METAGENERATION_SPECIFIEDDEFAULT_RETRY_IF_ETAG_IN_JSONr.   r   r   <module>rf      s  
   1  8 ! 5 ; ""&&%%!!,,KKKKKK    $$##! * 	KK!!KKKK%%KKKK##KK  m4
%V %P-#/! )?*^,<) % -C.0@- ) !7?VH! r   