AlkantarClanX12

Your IP : 3.145.47.193


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/geoip2/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/geoip2/__pycache__/webservice.cpython-311.pyc

�

l��f�C��z�dZddlZddlZddlmZmZmZmZmZm	Z	m
Z
ddlZddlZddl
Z
ddlZ
ddlZddlZddlmZmZmZmZmZmZmZddlmZmZmZddlmZdej�dejj ��Z!dej�de
j"�#����Z$Gd	�d
��Z%Gd�de%��Z&Gd
�de%��Z'dS)a{
============================
WebServices Client API
============================

This class provides a client API for all the GeoIP2 Precision web service end
points. The end points are Country, City, and Insights. Each end point returns
a different set of data about an IP address, with Country returning the least
data and Insights the most.

Each web service end point is represented by a different model class, and
these model classes in turn contain multiple record classes. The record
classes have attributes which contain data about the IP address.

If the web service does not return a particular piece of data for an IP
address, the associated attribute is not populated.

The web service may not return any information for an entire record, in which
case all of the attributes for that record class will be empty.

SSL
---

Requests to the web service are always made with SSL.

�N)�Any�Dict�cast�List�Optional�Type�Union)�AddressNotFoundError�AuthenticationError�GeoIP2Error�	HTTPError�InvalidRequestError�OutOfQueriesError�PermissionRequiredError)�City�Country�Insights)�	IPAddresszGeoIP2-Python-Client/� c��eZdZUeed<eed<eed<eeed<eed<dededed	eeed
eddfd
�Z	dede
defd�Zededede
fd���Zdededededef
d�Zdededededef
d�Zedededededeeeeeeff
d���Zedededeedefd���Zedededeedefd���ZdS)�
BaseClient�_account_id�_host�_license_key�_locales�_timeout�
account_id�license_key�host�locales�timeout�returnNc��|�dg}||_t|t��r|nt|��|_||_d|�d�|_||_dS)zConstruct a Client.N�enzhttps://z/geoip/v2.1)r�
isinstance�bytes�strrr�	_base_urir)�selfrrrr r!s      �q/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/geoip2/webservice.py�__init__zBaseClient.__init__Csd���?��f�G���
�%�Z��7�7�L�J�J�S��_�_�	
��(���5�D�5�5�5�����
�
�
��path�
ip_addressc��|dkrtj|��}d�|j|t	|��g��S)N�me�/)�	ipaddressr.�joinr(r')r)r-r.s   r*�_urizBaseClient._uriZs>������"�-�j�9�9�J��x�x����s�:���?�@�@�@r,�body�uric��	tj|��S#t$r6}td|�d�d�|j��zd|��|�d}~wwxYw)NzReceived a 200 response for z, but could not decode the response as JSON: �, ��)�json�loads�
ValueErrorrr3�args)r5r6�exs   r*�_handle_successzBaseClient._handle_success_s���		��:�d�#�#�#���	�	�	���s�����9�9�R�W�-�-�.������

�����	���s��
A�1A�A�status�content_typec���d|cxkrdkrnn|�||||��Sd|cxkrdkrnn|�|||��S|�|||��S)Ni�i�iX)�_exception_for_4xx_status�_exception_for_5xx_status�_exception_for_non_200_status)r)r@rAr5r6s     r*�_exception_for_errorzBaseClient._exception_for_errorls����&�����3�������1�1�&�,��c�R�R�R��&�����3�������1�1�&�#�t�D�D�D��1�1�&�#�t�D�D�Dr,c��|std|�d|�d�|||��S|�d��dkrtd|�d|�d|��|||��S	tj|��}d|vrBd	|vr>|�|�d	��|�d��||��Std
|||��S#t$rA}td|�d|�d�dzd
�|j��z|||��cYd}~Sd}~wwxYw)NzReceived a z error for z with no body.r:���z for z with the following body: �code�errorzAResponse contains JSON but it does not specify code or error keysz but it did not include zthe expected JSON body: r8)	r
�findr:r;� _exception_for_web_service_error�getr<r3r=)r)r@rAr5r6�decoded_bodyr>s       r*rCz$BaseClient._exception_for_4xx_statusus����	��D�f�D�D��D�D�D����	��
����V�$�$��*�*��P�f�P�P�3�P�P�$�P�P����	��
�	��:�d�+�+�L���%�%�'�\�*A�*A��<�<� �$�$�W�-�-�|�/?�/?��/G�/G��QT�����S����	��
���	�	�	��N�f�N�N��N�N�N�,�-��)�)�B�G�$�$�%����
��
�
�
�
�
�
�����	���s�B=�=
D�6D�=D�D�messagerIc���|dvrt|��S|dvrt|��S|dvrt|��S|dkrt|��St	||||��S)N)�IP_ADDRESS_NOT_FOUND�IP_ADDRESS_RESERVED)�ACCOUNT_ID_REQUIRED�ACCOUNT_ID_UNKNOWN�AUTHORIZATION_INVALID�LICENSE_KEY_REQUIRED�USER_ID_REQUIRED�USER_ID_UNKNOWN)�INSUFFICIENT_FUNDS�OUT_OF_QUERIES�PERMISSION_REQUIRED)r
rrrr)rOrIr@r6s    r*rLz+BaseClient._exception_for_web_service_error�s����B�B�B�'��0�0�0��
�
�
�'�w�/�/�/��;�;�;�$�W�-�-�-��(�(�(�*�7�3�3�3�"�7�D�&�#�>�>�>r,c�2�td|�d|��|||��S)NzReceived a server error (�) for �r
�r@r6r5s   r*rDz$BaseClient._exception_for_5xx_status�s2���;��;�;�c�;�;����	
�
�	
r,c�2�td|�d|��|||��S)Nz(Received a very surprising HTTP status (r]r^r_s   r*rEz(BaseClient._exception_for_non_200_status�s2���J�v�J�J�S�J�J����	
�
�	
r,)�__name__�
__module__�__qualname__r'�__annotations__r�float�intrr+rr4�staticmethodrr?rrFrCr	rr
rrrrLr
rDrE�r,r*rr<sw������������J�J�J������3�i�����O�O�O� �� �� ��	 �
�$�s�)�$� ��
 �
� � � � �.A��A�)�A��A�A�A�A�
�
�c�
��
��
�
�
��\�
�E��E�),�E�47�E�>A�E�	�E�E�E�E�&��&�),�&�47�&�>A�&�	�&�&�&�&�P�?��?��?�),�?�36�?�	������		�
�?�?�?��\�?�6�
��
��
�%-�c�]�
�	�
�
�
��\�
��
��
��
�%-�c�]�
�	�
�
�
��\�
�
�
r,rc�\��eZdZUdZejed<eeed<				dde	ded	ed
ee
ededeed
df�fd�
Zdde
d
efd�Zdde
d
efd�Zdde
d
efd�Zd
ejfd�Zdedeeeeeeefde
d
eeeeffd�Zd�Zd d�Zd!d�Z�xZS)"�AsyncClientaUAn async GeoIP2 client.

    It accepts the following required arguments:

    :param account_id: Your MaxMind account ID.
    :param license_key: Your MaxMind license key.

    Go to https://www.maxmind.com/en/my_license_key to see your MaxMind
    account ID and license key.

    The following keyword arguments are also accepted:

    :param host: The hostname to make a request against. This defaults to
      "geoip.maxmind.com". To use the GeoLite2 web service instead of GeoIP2
      Precision, set this to "geolite.info".
    :param locales: This is list of locale codes. This argument will be
      passed on to record classes to use when their name properties are
      called. The default value is ['en'].

      The order of the locales is significant. When a record class has
      multiple names (country, city, etc.), its name property will return
      the name in the first locale that has one.

      Note that the only locale which is always present in the GeoIP2
      data is "en". If you do not include this locale, the name property
      may end up returning None even when the record has an English name.

      Currently, the valid locale codes are:

      * de -- German
      * en -- English names may still include accented characters if that is
        the accepted spelling in English. In other words, English does not
        mean ASCII.
      * es -- Spanish
      * fr -- French
      * ja -- Japanese
      * pt-BR -- Brazilian Portuguese
      * ru -- Russian
      * zh-CN -- Simplified Chinese.
    :param timeout: The timeout in seconds to use when waiting on the request.
      This sets both the connect timeout and the read timeout. The default is
      60.
    :param proxy: The URL of an HTTP proxy to use. It may optionally include
      a basic auth username and password, e.g.,
      ``http://username:password@host:port``.

    �_existing_session�_proxy�geoip.maxmind.comN�<rrrr r!�proxyr"c�`��t���|||||��||_dS�N)�superr+rl�r)rrrr r!ro�	__class__s       �r*r+zAsyncClient.__init__s=���	����������	
�	
�	
�����r,r0r.c��K�tt|�dtjj|���d{V����S)�Call City endpoint with the specified IP.

        :param ip_address: IPv4 or IPv6 address as a string. If no
           address is provided, the address that the web service is
           called from will be used.

        :returns: :py:class:`geoip2.models.City` object

        �cityN�rr�
_response_for�geoip2�models�r)r.s  r*rwzAsyncClient.citysH�������*�*�6�6�=�3E�z�R�R�R�R�R�R�R�R�
�
�	
r,c��K�tt|�dtjj|���d{V����S)�(Call the GeoIP2 Country endpoint with the specified IP.

        :param ip_address: IPv4 or IPv6 address as a string. If no address
          is provided, the address that the web service is called from will
          be used.

        :returns: :py:class:`geoip2.models.Country` object

        �countryN�rrryrzr{r|s  r*rzAsyncClient.country$sI�������$�$�Y��
�0E�z�R�R�R�R�R�R�R�R�
�
�	
r,c��K�tt|�dtjj|���d{V����S)�Call the Insights endpoint with the specified IP.

        Insights is only supported by GeoIP2 Precision. The GeoLite2 web
        service does not support it.

        :param ip_address: IPv4 or IPv6 address as a string. If no address
          is provided, the address that the web service is called from will
          be used.

        :returns: :py:class:`geoip2.models.Insights` object

        �insightsN�rrryrzr{r|s  r*r�zAsyncClient.insights3sI�������$�$�Z���1G��T�T�T�T�T�T�T�T�
�
�	
r,c���K�t|d��sYtjtj|j|j��dtd�tj|j������|_	|j	S)Nrk�application/json)�Accept�
User-Agent)�total)�auth�headersr!)
�hasattr�aiohttp�
ClientSession�	BasicAuthrr�_AIOHTTP_UA�
ClientTimeoutrrk�r)s r*�_sessionzAsyncClient._sessionEsr�����t�0�1�1�	�%,�%:��&�t�'7��9J�K�K�#5�[�Q�Q��-�D�M�B�B�B�&�&�&�D�"��%�%r,r-�model_classc���K�|�||��}|����d{V��}|�||j����d{V��4�d{V��}|j}|j}|����d{V��}	|dkr|�|||	|���|�|	|��}
||
|j	���cddd���d{V��S#1�d{V��swxYwYdS)N)ror9�r )
r4r�rMrlr@rA�textrFr?r)r)r-r�r.r6�session�responser@rAr5rNs           r*ryzAsyncClient._response_forOs������i�i��j�)�)���
�
���'�'�'�'�'�'�� ���S����<�<�<�<�<�<�<�<�	D�	D�	D�	D�	D�	D�	D���_�F�#�0�L�!�����(�(�(�(�(�(�D���}�}��/�/���d�C�P�P�P��/�/��c�:�:�L��;�|�T�]�C�C�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�A.C�
C&�)C&c��lK�t|d��r!|j����d{V��dSdS)�fClose underlying session

        This will close the session and any associated connections.
        rkN)r�rk�closer�s r*r�zAsyncClient.close`sR����
�4�,�-�-�	1��(�.�.�0�0�0�0�0�0�0�0�0�0�0�	1�	1r,c��
K�|Srqrhr�s r*�
__aenter__zAsyncClient.__aenter__hs�����r,�exc_type�	exc_value�	tracebackc��>K�|����d{V��dSrq�r��r)r�r�r�s    r*�	__aexit__zAsyncClient.__aexit__ks,�����j�j�l�l���������r,�rmNrnN�r0)r"rj�r�Nr�Nr�Nr"N)rarbrc�__doc__r�r�rdrr'rfrrer+rrrwrrrr�r�r	rryr�r�r��
__classcell__�rts@r*rjrj�s���������.�.�`�,�,�,�,��S�M����(�'+��#��������	�
�$�s�)�$���
���}��
�������$
�
�Y�
�$�
�
�
�
�

�

�	�

�W�

�

�

�

�
�
��
�h�
�
�
�
�$&�� 5�&�&�&�&�D��D��4��>�4��:�t�G�}�D�E�D��	D�

�w��h�&�	'�D�D�D�D�"1�1�1������������r,rjc�V��eZdZUdZejed<eee	e	fed<				dde
de	d	e	d
eee	dedee	d
df�fd�
Z
dded
efd�Zdded
efd�Zdded
efd�Zde	deeeeeeefded
eeeeffd�Zd�Zdd�Zd d�Z�xZS)!�Clienta[A synchronous GeoIP2 client.

    It accepts the following required arguments:

    :param account_id: Your MaxMind account ID.
    :param license_key: Your MaxMind license key.

    Go to https://www.maxmind.com/en/my_license_key to see your MaxMind
    account ID and license key.

    The following keyword arguments are also accepted:

    :param host: The hostname to make a request against. This defaults to
      "geoip.maxmind.com". To use the GeoLite2 web service instead of GeoIP2
      Precision, set this to "geolite.info".
    :param locales: This is list of locale codes. This argument will be
      passed on to record classes to use when their name properties are
      called. The default value is ['en'].

      The order of the locales is significant. When a record class has
      multiple names (country, city, etc.), its name property will return
      the name in the first locale that has one.

      Note that the only locale which is always present in the GeoIP2
      data is "en". If you do not include this locale, the name property
      may end up returning None even when the record has an English name.

      Currently, the valid locale codes are:

      * de -- German
      * en -- English names may still include accented characters if that is
        the accepted spelling in English. In other words, English does not
        mean ASCII.
      * es -- Spanish
      * fr -- French
      * ja -- Japanese
      * pt-BR -- Brazilian Portuguese
      * ru -- Russian
      * zh-CN -- Simplified Chinese.
    :param timeout: The timeout in seconds to use when waiting on the request.
      This sets both the connect timeout and the read timeout. The default is
      60.
    :param proxy: The URL of an HTTP proxy to use. It may optionally include
      a basic auth username and password, e.g.,
      ``http://username:password@host:port``.


    r��_proxiesrmNrnrrrr r!ror"c� ��t���|||||��tj��|_|j|jf|j_d|jjd<t|jjd<|�	d|_
dSd|i|_
dS)Nr�r�r��https)rrr+�requests�Sessionr�rrr�r��_REQUEST_UAr�rss       �r*r+zClient.__init__�s����	������[�$���I�I�I� �(�*�*��
�"�.��0A�B��
��*<��
��h�'�.9��
��l�+��=� �D�M�M�M�$�e�,�D�M�M�Mr,r0r.c�t�tt|�dtjj|����S)rvrwrxr|s  r*rwzClient.city�s+���D�$�,�,�V�V�]�5G��T�T�U�U�Ur,c�t�tt|�dtjj|����S)r~rr�r|s  r*rzClient.country�s2����T�'�'�	�6�=�3H�*�U�U�
�
�	
r,c�t�tt|�dtjj|����S)r�r�r�r|s  r*r�zClient.insights�s2����d�(�(��V�]�5K�Z�X�X�
�
�	
r,r-r�c�>�|�||��}|j�||j|j���}|j}|jd}|j}|dkr|�||||���|�	||��}	||	|j
���S)N)�proxiesr!zContent-Typer9r�)r4r�rMr�r�status_coder�r�rFr?r)
r)r-r�r.r6r�r@rAr5rNs
          r*ryzClient._response_for�s����i�i��j�)�)���=�$�$�S�$�-���$�W�W���%���'��7���}���S�=�=��+�+�F�L�$��L�L�L��+�+�D�#�6�6���{�<���?�?�?�?r,c�8�|j���dS)r�N)r�r�r�s r*r�zClient.close�s��
	
�
�������r,c��|Srqrhr�s r*�	__enter__zClient.__enter__�s���r,r�r�r�c�.�|���dSrqr�r�s    r*�__exit__zClient.__exit__�s���
�
�����r,r�r�)r"r�r�)rarbrcr�r�r�rdrrr'rfrrer+rrrwrrrr�r	rryr�r�r�r�r�s@r*r�r�os���������/�/�b������t�C��H�~�&�&�&�&�(�'+��#�-�-��-��-��	-�
�$�s�)�$�-��
-���}�-�
�-�-�-�-�-�-�&
V�
V�y�
V�D�
V�
V�
V�
V�
�
�)�
�w�
�
�
�
�
�
�9�
��
�
�
�
�"@��@��4��>�4��:�t�G�}�D�E�@��	@�

�w��h�&�	'�@�@�@�@� ��������������r,r�)(r�r2r:�typingrrrrrrr	r��aiohttp.httpr��requests.utilsrz�
geoip2.models�
geoip2.errorsr
rrr
rrrrrr�geoip2.typesr�__version__�http�SERVER_SOFTWAREr��utils�default_user_agentr�rrjr�rhr,r*�<module>r�s����6��������?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�����������������
�
�
�
�����������������������2�1�1�1�1�1�1�1�1�1�"�"�"�"�"�"�P�F�.�O�O���1M�O�O��
W�F�.�V�V���1R�1R�1T�1T�V�V��
Q
�Q
�Q
�Q
�Q
�Q
�Q
�Q
�h\�\�\�\�\�*�\�\�\�~N�N�N�N�N�Z�N�N�N�N�Nr,