Ë
    v»•j|X  ã                   ó°  — d Z ddlZddlmZ ddlmZmZmZmZm	Z	m
Z
mZmZmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZmZ dd
lmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z'm(Z( e
e)eee)e*e+e,ee)   f      f   Z-eee
e)ee   f   e
e)ee)ee   f   f   e
e)ee)ee   e)f   f   e
e)ee)ee   e)e
e)e)f   f   f   f      Z. G d„ d«      Z/ G d„ de/«      Z0ee/   Z1y)z{
gspread.http_client
~~~~~~~~~~~~~~

This module contains HTTPClient class responsible for communicating with
Google API.

é    N)Ú
HTTPStatus)
ÚIOÚAnyÚDictÚListÚMappingÚMutableMappingÚOptionalÚTupleÚTypeÚUnion)ÚCredentials)ÚAuthorizedSession)ÚResponseÚSessioné   )ÚAPIErrorÚUnSupportedExportFormat)ÚDRIVE_FILES_API_V3_URLÚDRIVE_FILES_UPLOAD_API_V2_URLÚSPREADSHEET_BATCH_UPDATE_URLÚSPREADSHEET_SHEETS_COPY_TO_URLÚSPREADSHEET_URLÚSPREADSHEET_VALUES_APPEND_URLÚ"SPREADSHEET_VALUES_BATCH_CLEAR_URLÚ#SPREADSHEET_VALUES_BATCH_UPDATE_URLÚSPREADSHEET_VALUES_BATCH_URLÚSPREADSHEET_VALUES_CLEAR_URLÚSPREADSHEET_VALUES_URL)ÚExportFormatÚconvert_credentialsÚquotec                   ó<  — e Zd ZdZd2dedee   ddfd„Zd3d„Zdee	e
ee
e
f   f      ddfd	„Z	 	 	 	 	 d4d
ededee   dee   deeeef      dedeeeef      defd„Zdedeeeef      defd„Z	 	 d5dededee   deeeef      def
d„Zdedededeeeef      def
d„Zdededefd„Z	 	 d5dedee   deeeef      defd„Z	 d2dededee   defd„Z	 d2dedee   dee   defd„Z	 d2dedeeeef      defd„Zd2dedee   defd„Zdede d edefd!„Z!	 d2dedee   deeef   fd"„Z"dedefd#„Z#e$jJ                  fd$ed%edefd&„Z&	 	 	 d6d$ed'ee   d(ee   d)ee   d*e'd+ee   d,e'defd-„Z(d$edee)ee	ee'f   f      fd.„Z*d$ed/eddfd0„Z+d$ede	eef   defd1„Z,y)7Ú
HTTPClientaì  An instance of this class communicates with Google API.

    :param Credentials auth: An instance of google.auth.Credentials used to authenticate requests
        created by either:

        * gspread.auth.oauth()
        * gspread.auth.oauth_from_dict()
        * gspread.auth.service_account()
        * gspread.auth.service_account_from_dict()

    :param Session session: (Optional) An OAuth2 credential object. Credential objects
        created by `google-auth <https://github.com/googleapis/google-auth-library-python>`_.

        You can pass you own Session object, simply pass ``auth=None`` and ``session=my_custom_session``.

    This class is not intended to be created manually.
    It will be created by the gspread.Client class.
    NÚauthÚsessionÚreturnc                 óˆ   — |�|| _         d | _        y t        |«      | _        t        | j                  «      | _         d | _        y ©N)r&   r!   r%   r   Útimeout)Úselfr%   r&   s      úF/var/www/html/venv/lib/python3.12/site-packages/gspread/http_client.pyÚ__init__zHTTPClient.__init__M   s?   € ØÐØ"ˆDŒLð
 EIˆ�ô &9¸Ó%>ˆDŒIÜ,¨T¯Y©YÓ7ˆDŒLàDHˆ�ó    c                 óâ   — ddl m} | j                  j                   || j                  «      «       | j                  j
                  j                  dd| j                  j                  z  i«       y )Nr   )ÚRequestÚAuthorizationz	Bearer %s)Úgoogle.auth.transport.requestsr0   r%   Úrefreshr&   ÚheadersÚupdateÚtoken)r+   r0   s     r,   ÚloginzHTTPClient.loginV   sJ   € Ý:à�	‰	×Ñ™' $§,¡,Ó/Ô0à�‰×Ñ×#Ñ# _°kÀDÇIÁIÇOÁOÑ6SÐ$TÕUr.   r*   c                 ó   — || _         y)züHow long to wait for the server to send
        data before giving up, as a float, or a ``(connect timeout,
        read timeout)`` tuple.

        Use value ``None`` to restore default timeout

        Value for ``timeout`` is in seconds (s).
        N)r*   )r+   r*   s     r,   Úset_timeoutzHTTPClient.set_timeout]   s   € ð ˆ�r.   ÚmethodÚendpointÚparamsÚdataÚjsonÚfilesr4   c           
      óŽ   — | j                   j                  |||||||| j                  ¬«      }|j                  r|S t	        |«      ‚)N)r:   Úurlr>   r<   r=   r?   r4   r*   )r&   Úrequestr*   Úokr   )	r+   r:   r;   r<   r=   r>   r?   r4   Úresponses	            r,   rB   zHTTPClient.requesth   sR   € ð —<‘<×'Ñ'ØØØØØØØØ—L‘Lð (ó 	
ˆð �;Š;ØˆOä˜8Ó$Ð$r.   ÚidÚbodyc                 óX   — | j                  dt        |z  |¬«      }|j                  «       S )a  Lower-level method that directly calls `spreadsheets/<ID>:batchUpdate <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate>`_.

        :param dict body: `Batch Update Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#request-body>`_.
        :returns: `Batch Update Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#response-body>`_.
        :rtype: dict

        .. versionadded:: 3.0
        Úpost©r>   )rB   r   r>   )r+   rE   rF   Úrs       r,   Úbatch_updatezHTTPClient.batch_update‚   s)   € ð �L‰L˜Ô!=ÀÑ!BÈˆLÓNˆà�v‰v‹xˆr.   Úrangec                 ót   — t         |t        |«      fz  }| j                  d|||¬«      }|j                  «       S )ay  Lower-level method that directly calls `PUT spreadsheets/<ID>/values/<range> <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update>`_.

        :param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to update.
        :param dict params: (optional) `Values Update Query parameters <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update#query-parameters>`_.
        :param dict body: (optional) `Values Update Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update#request-body>`_.
        :returns: `Values Update Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update#response-body>`_.
        :rtype: dict

        Example::

            sh.values_update(
                'Sheet1!A2',
                params={
                    'valueInputOption': 'USER_ENTERED'
                },
                body={
                    'values': [[1, 2, 3]]
                }
            )

        .. versionadded:: 3.0
        Úput©r<   r>   ©r   r"   rB   r>   ©r+   rE   rL   r<   rF   rA   rJ   s          r,   Úvalues_updatezHTTPClient.values_update�   s8   € ô: %¨¬E°%«LÐ'9Ñ9ˆØ�L‰L˜ ¨F¸ˆLÓ>ˆØ�v‰v‹xˆr.   c                 ót   — t         |t        |«      fz  }| j                  d|||¬«      }|j                  «       S )a·  Lower-level method that directly calls `spreadsheets/<ID>/values:append <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append>`_.

        :param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_
                          of a range to search for a logical table of data. Values will be appended after the last row of the table.
        :param dict params: `Values Append Query parameters <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append#query-parameters>`_.
        :param dict body: `Values Append Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append#request-body>`_.
        :returns: `Values Append Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append#response-body>`_.
        :rtype: dict

        .. versionadded:: 3.0
        rH   rO   )r   r"   rB   r>   rQ   s          r,   Úvalues_appendzHTTPClient.values_append°   s8   € ô ,¨r´5¸³<Ð.@Ñ@ˆØ�L‰L˜ ¨V¸$ˆLÓ?ˆØ�v‰v‹xˆr.   c                 ón   — t         |t        |«      fz  }| j                  d|«      }|j                  «       S )a   Lower-level method that directly calls `spreadsheets/<ID>/values:clear <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear>`_.

        :param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to clear.
        :returns: `Values Clear Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/clear#response-body>`_.
        :rtype: dict

        .. versionadded:: 3.0
        rH   )r   r"   rB   r>   )r+   rE   rL   rA   rJ   s        r,   Úvalues_clearzHTTPClient.values_clearÂ   s2   € ô +¨b´%¸³,Ð-?Ñ?ˆØ�L‰L˜ Ó%ˆØ�v‰v‹xˆr.   c                 ó^   — t         |z  }| j                  d|||¬«      }|j                  «       S )aØ  Lower-level method that directly calls `spreadsheets/<ID>/values:batchClear`

        :param dict params: (optional) `Values Batch Clear Query parameters <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchClear#path-parameters>`_.
        :param dict body: (optional) `Values Batch Clear request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchClear#request-body>`_.
        :rtype: dict
        rH   rO   )r   rB   r>   )r+   rE   r<   rF   rA   rJ   s         r,   Úvalues_batch_clearzHTTPClient.values_batch_clearÏ   s/   € ô 1°2Ñ5ˆØ�L‰L˜ ¨V¸$ˆLÓ?ˆØ�v‰v‹xˆr.   c                 ór   — t         |t        |«      fz  }| j                  d||¬«      }|j                  «       S )a°  Lower-level method that directly calls `GET spreadsheets/<ID>/values/<range> <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get>`_.

        :param str range: The `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to retrieve.
        :param dict params: (optional) `Values Get Query parameters <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get#query-parameters>`_.
        :returns: `Values Get Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get#response-body>`_.
        :rtype: dict

        .. versionadded:: 3.0
        Úget©r<   rP   )r+   rE   rL   r<   rA   rJ   s         r,   Ú
values_getzHTTPClient.values_getß   s6   € ô %¨¬E°%«LÐ'9Ñ9ˆØ�L‰L˜ ¨FˆLÓ3ˆØ�v‰v‹xˆr.   Úrangesc                 ón   — |€i }||d<   t         |z  }| j                  d||¬«      }|j                  «       S )a½  Lower-level method that directly calls `spreadsheets/<ID>/values:batchGet <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGet>`_.

        :param list ranges: List of ranges in the `A1 notation <https://developers.google.com/sheets/api/guides/concepts#a1_notation>`_ of the values to retrieve.
        :param dict params: (optional) `Values Batch Get Query parameters <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGet#query-parameters>`_.
        :returns: `Values Batch Get Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGet#response-body>`_.
        :rtype: dict
        r]   rZ   r[   )r   rB   r>   )r+   rE   r]   r<   rA   rJ   s         r,   Úvalues_batch_getzHTTPClient.values_batch_getï   sA   € ð ˆ>ØˆFà!ˆˆxÑä*¨RÑ/ˆØ�L‰L˜ ¨FˆLÓ3ˆØ�v‰v‹xˆr.   c                 ó\   — t         |z  }| j                  d||¬«      }|j                  «       S )a"  Lower-level method that directly calls `spreadsheets/<ID>/values:batchUpdate <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate>`_.

        :param dict body: (optional) `Values Batch Update Request body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate#request-body>`_.
        :returns: `Values Batch Update Response body <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate#response-body>`_.
        :rtype: dict
        rH   rI   )r   rB   r>   )r+   rE   rF   rA   rJ   s        r,   Úvalues_batch_updatezHTTPClient.values_batch_update  s-   € ô 2°BÑ6ˆØ�L‰L˜ ¨4ˆLÓ0ˆØ�v‰v‹xˆr.   c                 ó\   — t         |z  }| j                  d||¬«      }|j                  «       S )z„A method stub that directly calls `spreadsheets.get <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get>`_.rZ   r[   ©r   rB   r>   ©r+   rE   r<   rA   rJ   s        r,   Úspreadsheets_getzHTTPClient.spreadsheets_get  s+   € ä Ñ"ˆØ�L‰L˜ ¨FˆLÓ3ˆØ�v‰v‹xˆr.   Úsheet_idÚdestination_spreadsheet_idc                 óh   — t         ||fz  }d|i}| j                  d||¬«      }|j                  «       S )z�Lower-level method that directly calls `spreadsheets.sheets.copyTo <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.sheets/copyTo>`_.ÚdestinationSpreadsheetIdrH   rI   )r   rB   r>   )r+   rE   rf   rg   rA   rF   rJ   s          r,   Úspreadsheets_sheets_copy_toz&HTTPClient.spreadsheets_sheets_copy_to  s<   € ô -°°H¨~Ñ=ˆà*Ð,FÐGˆØ�L‰L˜ ¨4ˆLÓ0ˆØ�v‰v‹xˆr.   c                 óh   — |€ddi}t         |z  }| j                  d||¬«      }|j                  «       S )aï  Similar to :method spreadsheets_get:`gspread.http_client.spreadsheets_get`,
        get the spreadsheet form the API but by default **does not get the cells data**.
        It only retrieve the the metadata from the spreadsheet.

        :param str id: the spreadsheet ID key
        :param dict params: (optional) the HTTP params for the GET request.
            By default sets the parameter ``includeGridData`` to ``false``.
        :returns: The raw spreadsheet
        :rtype: dict
        ÚincludeGridDataÚfalserZ   r[   rc   rd   s        r,   Úfetch_sheet_metadatazHTTPClient.fetch_sheet_metadata  s<   € ð ˆ>Ø'¨Ð1ˆFä Ñ"ˆà�L‰L˜ ¨FˆLÓ3ˆà�v‰v‹xˆr.   c                 ó†   — t         dj                  |«      z   }ddddœ}| j                  d||¬«      }|j                  «       S )zÑGet the metadata from the Drive API for a specific file
        This method is mainly here to retrieve the create/update time
        of a file (these metadata are only accessible from the Drive API).
        z/{}Tz id,name,createdTime,modifiedTime)ÚsupportsAllDrivesÚincludeItemsFromAllDrivesÚfieldsrZ   r[   )r   ÚformatrB   r>   )r+   rE   rA   r<   Úress        r,   Úget_file_drive_metadataz"HTTPClient.get_file_drive_metadata5  sK   € ô % u§|¡|°BÓ'7Ñ7ˆð "&Ø)-Ø8ñ
ˆð �l‰l˜5 #¨fˆlÓ5ˆà�x‰x‹zÐr.   Úfile_idrs   c                 ó’   — |t         vrt        ‚dj                  t        |«      }d|i}| j	                  d||¬«      }|j
                  S )aß  Export the spreadsheet in the given format.

        :param str file_id: The key of the spreadsheet to export

        :param str format: The format of the resulting file.
            Possible values are:

                * ``ExportFormat.PDF``
                * ``ExportFormat.EXCEL``
                * ``ExportFormat.CSV``
                * ``ExportFormat.OPEN_OFFICE_SHEET``
                * ``ExportFormat.TSV``
                * ``ExportFormat.ZIPPED_HTML``

            See `ExportFormat`_ in the Drive API.

        :type format: :class:`~gspread.utils.ExportFormat`

        :returns bytes: The content of the exported file.

        .. _ExportFormat: https://developers.google.com/drive/api/guides/ref-export-formats
        z{}/{}/exportÚmimeTyperZ   r[   )r    r   rs   r   rB   Úcontent)r+   rv   rs   rA   r<   rJ   s         r,   ÚexportzHTTPClient.exportG  sM   € ð0 œÑ%Ü)Ð)à×#Ñ#Ô$:¸GÓDˆà(¨&Ð1ˆà�L‰L˜ ¨FˆLÓ3ˆØ�y‰yÐr.   Úemail_addressÚ	perm_typeÚroleÚnotifyÚemail_messageÚ	with_linkc                 óê   — dj                  t        |«      }|||dœ}	ddi}
|dk(  r||	d<   n4|dv r||	d<   ||
d<   ||
d	<   n |d
k(  rnt        dj                  |«      «      ‚| j                  d||	|
¬«      S )a�  Creates a new permission for a file.

        :param str file_id: a spreadsheet ID (aka file ID).
        :param email_address: user or group e-mail address, domain name
            or None for 'anyone' type.
        :type email_address: str, None
        :param str perm_type: (optional) The account type.
            Allowed values are: ``user``, ``group``, ``domain``, ``anyone``
        :param str role: (optional) The primary role for this user.
            Allowed values are: ``owner``, ``writer``, ``reader``
        :param bool notify: Whether to send an email to the target
            user/domain. Default ``True``.
        :param str email_message: (optional) An email message to be sent
            if ``notify=True``.
        :param bool with_link: Whether the link is required for this
            permission to be active. Default ``False``.

        :returns dict: the newly created permission

        Examples::

            # Give write permissions to otto@example.com

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                'otto@example.org',
                perm_type='user',
                role='writer'
            )

            # Make the spreadsheet publicly readable

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                None,
                perm_type='anyone',
                role='reader'
            )

        ú{}/{}/permissions)Útyper}   ÚwithLinkrp   ÚtrueÚdomain>   ÚuserÚgroupÚemailAddressÚsendNotificationEmailÚemailMessageÚanyonezInvalid permission type: {}rH   )r>   r<   )rs   r   Ú
ValueErrorrB   )r+   rv   r{   r|   r}   r~   r   r€   rA   Úpayloadr<   s              r,   Úinsert_permissionzHTTPClient.insert_permissioni  s«   € ðd "×(Ñ(Ô)?ÀÓIˆàØØ!ñ
ˆð   ð
ˆð ˜Ò Ø -ˆG�HÒØÐ+Ñ+Ø&3ˆG�NÑ#Ø.4ˆFÐ*Ñ+Ø%2ˆF�>Ò"Ø˜(Ò"ØäÐ:×AÑAÀ)ÓLÓMÐMà�|‰|˜F C¨g¸fˆ|ÓEÐEr.   c                 óì   — dj                  t        |«      }dddœ}d}g }|�R|r||d<   | j                  d||¬	«      j                  «       }|j	                  |d
   «       |j                  dd«      }|�ŒR|S )zpRetrieve a list of permissions for a file.

        :param str file_id: a spreadsheet ID (aka file ID).
        r‚   TznextPageToken,permissions)rp   rr   Ú NÚ	pageTokenrZ   r[   ÚpermissionsÚnextPageToken)rs   r   rB   r>   ÚextendrZ   )r+   rv   rA   r<   r6   r“   rJ   s          r,   Úlist_permissionszHTTPClient.list_permissions²  s•   € ð
 "×(Ñ(Ô)?ÀÓIˆð "&Ø1ñ
ˆð
 ˆàˆàÐÙØ&+��{Ñ#à—‘˜U C°�Ó7×<Ñ<Ó>ˆAØ×Ñ˜q Ñ/Ô0à—E‘E˜/¨4Ó0ˆEð Ñð Ðr.   Úpermission_idc                 ób   — dj                  t        ||«      }ddi}| j                  d||¬«       y)z£Deletes a permission from a file.

        :param str file_id: a spreadsheet ID (aka file ID.)
        :param str permission_id: an ID for the permission.
        z{}/{}/permissions/{}rp   TÚdeleter[   N)rs   r   rB   )r+   rv   r—   rA   r<   s        r,   Úremove_permissionzHTTPClient.remove_permissionÍ  s9   € ð %×+Ñ+Ü" G¨]ó
ˆð 2°4Ð8ˆØ�‰�X˜s¨6ˆÕ2r.   c           	      óÌ   — t        |t        «      r|j                  d«      }ddi}dj                  t        |«      }| j                  d||ddddœ|¬	«      }|j                  «       S )
a½  Imports data into the first page of the spreadsheet.

        :param str data: A CSV string of data.

        Example:

        .. code::

            # Read CSV file contents
            content = open('file_to_import.csv', 'r').read()

            gc.import_csv(spreadsheet.id, content)

        .. note::

           This method removes all other worksheets and then entirely
           replaces the contents of the first worksheet.

        zutf-8zContent-Typeztext/csvz{}/{}rN   ÚmediaT)Ú
uploadTypeÚconvertrp   )r=   r<   r4   )Ú
isinstanceÚstrÚencoders   r   rB   r>   )r+   rv   r=   r4   rA   rt   s         r,   Ú
import_csvzHTTPClient.import_csvÚ  st   € ô* �dœCÔ Ø—;‘;˜wÓ'ˆDà! :Ð.ˆØ�n‰nÔ:¸GÓDˆà�l‰lØØØà%ØØ%)ñð
 ð ó 

ˆð �x‰x‹zÐr.   r)   )r'   N)NNNNN)NN)TNF)-Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r-   r7   r   Úfloatr   r9   r    Ú
ParamsTypeÚbytesr   r   ÚFileTyper	   r   rB   rK   rR   rT   rV   rX   r\   r   r_   ra   re   Úintrj   rn   ru   r    ÚPDFrz   Úboolr�   r   r–   rš   r¢   © r.   r,   r$   r$   9   s)  „ ññ&I˜[ð I°8¸GÑ3Dð IÐPTó IóVð	 8¨E°%¸¸uÀe¸|Ñ9LÐ2LÑ,MÑ#Nð 	ÐSWó 	ð (,Ø $Ø,0ØØ6:ñ%àð%ð ð%ð ˜Ñ$ð	%ð
 �u‰oð%ð �w˜s C˜xÑ(Ñ)ð%ð ð%ð ˜.¨¨c¨Ñ2Ñ3ð%ð 
ó%ð4˜sð ¨(°7¸3À¸8Ñ3DÑ*Eð È#ó ð" (,Ø,0ñàðð ðð ˜Ñ$ð	ð
 �w˜s C˜xÑ(Ñ)ðð 
óðBØðØ!ðØ+5ðØ=EÀgÈcÐSVÈhÑFWÑ=Xðà	óð$˜sð ¨3ð °3ó ð  (,Ø,0ñ	àðð ˜Ñ$ðð �w˜s C˜xÑ(Ñ)ð	ð
 
óð" CGñØðØ!ðØ+3°JÑ+?ðà	óð" JNñØðØ# C™yðØ2:¸:Ñ2Fðà	óð( <@ñØðØ% g¨c°3¨hÑ&7Ñ8ðà	óñ 3ð °¸Ñ0Dð ÐPSó ðØðØ!$ðØBEðà	óð 7;ñØðØ'¨
Ñ3ðà	��c�Ñ	óð,¨#ð °#ó ð$ 2>×1AÑ1Añ  ˜cð  ¨3ð  Àeó  ðP Ø'+ØñGFàðGFð   ‘}ðGFð ˜C‘=ð	GFð
 �s‰mðGFð ðGFð   ‘}ðGFð ðGFð 
óGFðR¨ð °°T¸#¸uÀSÈ$ÀYÑ?OÐ:OÑ5PÑ0Qó ð63¨ð 3¸Sð 3ÀTó 3ð' #ð '¨U°3¸°:Ñ->ð 'À3ô 'r.   r$   c                   óŽ   ‡ — e Zd ZU dZej
                  ej                  gZee   e	d<   dZ
ee	d<   dZee	d<   deded	efˆ fd
„Zˆ xZS )ÚBackOffHTTPClientae  BackOffHTTPClient is a http client with exponential
    backoff retries.

    In case a request fails due to some API rate limits,
    it will wait for some time, then retry the request.

    This can help by trying the request after some time and
    prevent the application from failing (by raising an APIError exception).

    .. Warning::
        This HTTPClient is not production ready yet.
        Use it at your own risk !

    .. note::
        To use with the `auth` module, make sure to pass this backoff
        http client using the ``http_client`` parameter of the
        method used.

    .. note::
        Currently known issues are:

        * will retry exponentially even when the error should
          raise instantly. Due to the Drive API that raises
          403 (Forbidden) errors for forbidden access and
          for api rate limit exceeded.Ú_HTTP_ERROR_CODESr   Ú_NR_BACKOFFé€   Ú_MAX_BACKOFFÚargsÚkwargsr'   c                 óÄ  •‡ — dt         dt        t        t        f   dt         dt        fˆ fd„}	 t        ‰	‰ �  |i |¤ŽS # t        $ r˜}|j                  }|j                  }‰ xj                  dz  c_
        t        d‰ j                  z  ‰ j                  «      } ||||«      du r5t        j                  |«        ‰ j                  |i |¤Ž}d	‰ _
        |cY d }~S |‚d }~ww xY w)
NÚcodeÚerrorÚwaitr'   c                 ó¸   •— d|v r"| t         j                  k(  r|d   d   d   dk(  ry| ‰j                  v xs | t         j                  k\  xr |‰j                  k  S )NÚerrorsr   r†   ÚusageLimitsT)r   Ú	FORBIDDENr±   ÚINTERNAL_SERVER_ERRORr´   )r¸   r¹   rº   r+   s      €r,   Ú_should_retryz0BackOffHTTPClient.request.<locals>._should_retry(  ss   ø€ ð ˜5Ñ ð œJ×0Ñ0Ò0Ø˜h™¨Ñ*¨8Ñ4¸ÒEàð ˜×.Ñ.Ð.ò <Øœ:×;Ñ;Ñ;ò,ð ˜$×+Ñ+Ñ+ð,r.   r   é   Tr   )r«   r   r    r   r­   ÚsuperrB   r   r¸   r¹   r²   Úminr´   ÚtimeÚsleep)
r+   rµ   r¶   rÀ   Úerrr¸   r¹   rº   rD   Ú	__class__s
   `        €r,   rB   zBackOffHTTPClient.request&  sê   ù€ ð	,Üð	,äœ3¤˜8Ñ$ð	,ô ð	,ô õ		,ð2	Ü‘7‘? DÐ3¨FÑ3Ð3øÜò 	Ø—8‘8ˆDØ—I‘IˆEà×Ò Ñ!ÕÜ�q˜$×*Ñ*Ñ*¨D×,=Ñ,=Ó>ˆDñ ˜T 5¨$Ó/°4Ñ7Ü—
‘
˜4Ô ð (˜4Ÿ<™<¨Ð8°Ñ8�ð $%�Ô à•ð ˆIûð)	ús"   ¯> ¾	CÁBCÃCÃCÃC)r£   r¤   r¥   r¦   r   ÚREQUEST_TIMEOUTÚTOO_MANY_REQUESTSr±   r   Ú__annotations__r²   r«   r´   r   r   rB   Ú__classcell__)rÇ   s   @r,   r°   r°     se   ø… ñ*ð6 	×"Ñ"Ø×$Ñ$ð+Ð�t˜JÑ'ó ð €K�ÓØ€L�#Óð1˜Sð 1¨Cð 1°H÷ 1ñ 1r.   r°   )2r¦   rÄ   Úhttpr   Útypingr   r   r   r   r   r	   r
   r   r   r   Úgoogle.auth.credentialsr   r2   r   Úrequestsr   r   Ú
exceptionsr   r   Úurlsr   r   r   r   r   r   r   r   r   r   r   Úutilsr    r!   r"   r    r«   r­   r§   r¨   rª   r$   r°   ÚHTTPClientTyper®   r.   r,   ú<module>rÔ      s"  ðñó Ý ÷÷ ÷ õ 0Ý <ß &ç 9÷÷ ÷ ñ ÷ <Ñ ;à˜C ¨%°°S¸$ÀÀtÈCÁyÐ0PÑ*QÑ!RÐRÑS€
àØ	Ø�s˜B˜s™G�|Ñ$Ø�s˜E # r¨#¡w ,Ñ/Ð/Ñ0Ø�s˜E # r¨#¡w°Ð"3Ñ4Ð4Ñ5Ø�s˜E # r¨#¡w°°^ÀCÈÀHÑ5MÐ"MÑNÐNÑOð	Qññ€÷Hñ HôVS˜
ô Sðl �jÑ!�r.   