%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/http/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/http/__pycache__/serviceclient.cpython-312.pyc

�

!V1f����ddlZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZmZm
Z
mZmZGd�dej ��Zy)�N)�Any�Dict�Optional)�	urlencode)�config�http�system�util�versionc���eZdZdZdZeejdefd���Z	dde
ejddfd�Z
d�Z						dded	e
edej$fd
�Zdefd�Zdede
ej$fd
�Zy)�UAServiceClient�N�returnc��y)z@String in subclasses, the UAConfig attribute containing base urlN���selfs �=/usr/lib/python3/dist-packages/uaclient/http/serviceclient.py�cfg_url_base_attrz!UAServiceClient.cfg_url_base_attrs��	
��cfgc�J�|stj�|_y||_y�N)r�UAConfigr)rrs  r�__init__zUAServiceClient.__init__s������(�D�H��D�Hrc�P�djtj��ddd�S)NzUA-Client/{}�application/json)z
user-agent�accept�content-type)�formatr�get_versionrs r�headerszUAServiceClient.headerss)��(�/�/��0C�0C�0E�F�(�.�
�	
r�log_response_body�timeoutc�T�|jd�}|s|j�}|jd�dk(r6|r4tj|t
j��jd�}tjt|j|j�|�}|j|�}	|	r|	S|r@t|j��D�
�cic]\}
}|��	|
|��
}}
}|dt!|�zz
}|�|n|j"}
t%j&|||||
|��Scc}}
w)N�/rr)�clszutf-8�?)�url�datar"�methodr$r#)�lstripr"�get�json�dumpsr
�DatetimeAwareJSONEncoder�encode�	posixpath�join�getattrrr�_get_fake_responses�sorted�itemsr�url_timeoutr�readurl)r�pathr*r"r+�query_paramsr#r$r)�
fake_response�k�v�filtered_params�timeout_to_uses              r�request_urlzUAServiceClient.request_url%s���{�{�3�����l�l�n�G��;�;�~�&�*<�<���:�:�d��(E�(E�F�M�M���D��n�n�W�T�X�X�t�/E�/E�F��M���0�0��5�
�� � ��"(��(:�(:�(<�!=����A����1���O��
�3��?�3�3�3�C�$+�$7��T�=M�=M���|�|�����"�/�

�	
��
s�
D$� D$r)c��|j�|jj|g�S|jjjd�}|si|_nTtj
j
|�si|_n-tjtj|��|_|jj|g�S)a.Return a list of fake response dicts for a given URL.

        serviceclient_url_responses in uaclient.conf should be a path
        to a json file which contains a dictionary keyed by full URL path.
        Each value will be a list of dicts representing each faked response
        for the given URL.

            The response dict item will have a code: <HTTP_STATUS_CODE> and
               response: "some string of content".
            The JSON string below fakes the available_resources URL on the
            contract server:
            '{"https://contracts.canonical.com/v1/resources":                [{"code": 200, "response": {"key": "val1", "key2": "val2"}}]}'

        :return: List of dicts for each faked response matching the url, or
           and empty list when no matching url found.
        �serviceclient_url_responses)�_response_overlayr-r�features�osr:�existsr.�loadsr	�	load_file)rr)�response_overlay_paths   r�_get_response_overlayz%UAServiceClient._get_response_overlayMs���$�!�!�-��)�)�-�-�c�2�6�6� $��� 1� 1� 5� 5�)�!
��%�%'�D�"������ 5�6�%'�D�"�%)�Z�Z�� � �!6�7�&�D�"��%�%�)�)�#�r�2�2rc�Z�|j|�}|syt|�dk(r|d}n|jd�}i}g}|d}t|t�r|}nt|t
�r|}t
j|d|jdi�tj|dd��||�	�S)
z7Return response if faked for this URL in uaclient.conf.N�r�response�coder"T)�	sort_keys)rOr"�body�	json_dict�	json_list)rK�len�pop�
isinstance�dict�listr�HTTPResponser-r.r/)rr)�	responsesrNrRrS�resps       rr5z#UAServiceClient._get_fake_responsesos����.�.�s�3�	����y�>�Q�� ��|�H�!�}�}�Q�'�H��	��	��
�#���d�D�!��I�
��d�
#��I�� � ��&�!��L�L��B�/����H�Z�0�D�A���
�	
rr)NNNNTN)�__name__�
__module__�__qualname__r8rD�property�abc�abstractmethod�strrrrrrr"�bool�intrrYrArKr5rrrr
r
s����K���
����
�3�
���
��H�V�_�_�5����
�����"&�!%�&
� �&
��#��&
�
�	�	�&
�P 3�� 3�D
�s�
�x��8I�8I�/J�
rr
)�	metaclass)r`r.rFr2�typingrrr�urllib.parser�uaclientrrr	r
r�ABCMetar
rrr�<module>rjs2��
��	��&�&�"�8�8�
����
r

Zerion Mini Shell 1.0