403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/galaxy/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/galaxy/__pycache__/api.cpython-311.pyc
�

���c���(�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZmZmZmZmZddlmZddlmZddlmZddl m!Z!dd	l m"Z"dd
l#m$Z$ddl%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+dd
l,m-Z-ddl.m/Z/ddl0m1Z1e-��Z2ej3��Z4dZ5ddgZ6d�Z7d�Z8d�Z9d�Z:e7d���Z;d�Z<Gd�de��Z=ej>dgd���Z?Gd�d��Z@ejAGd�d ����ZBdS)!�)�absolute_import�division�print_functionN)�	HTTPError)�quote�	urlencode�urlparse�parse_qs�urljoin)�	constants)�AnsibleError)�
user_agent)�retry_with_delays_and_condition)�generate_jittered_backoff)�string_types)�to_bytes�	to_native�to_text)�open_url�prepare_multipart)�Display)�
secure_hash_s)�
makedirs_safe�di�ic����fd�}|S)Nc�V��t5�|i|��cddd��S#1swxYwYdS�N)�_CACHE_LOCK)�args�kwargs�funcs  ��7/usr/lib/python3.11/site-packages/ansible/galaxy/api.py�wrappedzcache_lock.<locals>.wrapped,s���
�	)�	)��4��(��(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s��"�"�)r!r#s` r"�
cache_lockr%+s#���)�)�)�)�)��N�c�H�t|t��o
|jtvSr)�
isinstance�GalaxyError�	http_code�RETRY_HTTP_ERROR_CODES)�	exceptions r"�is_rate_limit_exceptionr-3s"���i��-�-�_�)�2E�I_�2_�_r&c����fd�}|S)z�
    Wrapper to lazily initialize connection info to Galaxy and verify the API versions required are available on the
    endpoint.

    :param versions: A list of API versions that the function supports.
    c������fd�}|S)Nc���|j�s�t�d|jz��|j}d|j�d|�d�}|jdks|jdkrd}	|�|d|d	�
��}n�#ttttf$r�}|�
d��s|�
d��r�t|d��}	|�|d|d	�
��}n #t$r}|jd
kr|��d}~wwxYwYd}~nd}~wwxYwd|vrt
d|�d|j�����||_|�
dddi��}t|�����dgkrd|d<||_t�dd�|������d|j�d|j�d���t#|j�����}t#����|��}	|	sSt
d�
j�dd�����dd�|���d|j�d|j��
����
|g|�Ri|��S)Nz'Initial connection to galaxy_server: %sz/Error when finding available api versions from � (�)zhttps://galaxy.ansible.comzhttps://galaxy.ansible.com/zhttps://galaxy.ansible.com/api/�GETT)�method�error_context_msg�cachez/apiz/api/��available_versionsz!Tried to find galaxy API root at z. but no 'available_versions' are available on �v1zv1/zv2/�v2zFound API version '�, z' with Galaxy server zGalaxy action z requires API versions 'z' but only 'z' are available on � )�_available_api_versions�display�vvvv�
api_server�name�_call_galaxyr
r)�
ValueError�KeyError�endswith�_urljoinr*�get�list�keys�join�set�intersection�__name__)�selfrr �n_urlr5�data�err�new_errr8�common_versionsr4�versionss          ��r"r#z-g_connect.<locals>.decorator.<locals>.wrappedBs	����/�,
c����F���X�Y�Y�Y�����`d�`i�`i�`i�kp�kp�kp�$q�!��?�&B�B�B�d�o�Yv�Fv�Fv�=�E���,�,�U�5�Te�mq�,�r�r�D�D��$�k�:�x�H�
�
�
��~�~�f�-�-������1H�1H���%�U�G�4�4�E��#�0�0��u�Xi�qu�0�v�v����&����"�,��3�3�"%�I�������������������
����(�t�3�3�&�,�27�%�%����(J�K�K�K�
#(���&*�X�X�.B�U�F�O�%T�%T�"��*�/�/�1�1�2�2�u�g�=�=�06�&�u�-�/A��,����� $�	�	�*<�*A�*A�*C�*C� D� D� D� D�d�i�i�i�QU�Q`�Q`�Q`�b�c�c�c�"%�T�%A�%F�%F�%H�%H�!I�!I��!�(�m�m�8�8�9K�L�L�O�"�
C�"�l�&,�o�o�o�t�y�y��7J�7J�7J�7J�D�I�I�Vh�Li�Li�Li�Li�&*�i�i�i����$B�C�C�C��6�$�0��0�0�0��0�0�0s<�A4�4D�;D�
C'�&D�'
D�1C?�?D�D�Dr$)r4r#rTs` �r"�	decoratorzg_connect.<locals>.decoratorAs*����7	1�7	1�7	1�7	1�7	1�7	1�p�r&r$)rTrUs` r"�	g_connectrV:s%���9�9�9�9�9�t�r&c�r�t|��}d}	|j}n#t$rYnwxYw|j�d|pd��S)z* Gets the cache ID for the URL specified. N�:�)r	�portrC�hostname)�url�url_inforZs   r"�get_cache_idr^~s\����}�}�H��D�
��}�����
�
�
���
�����'�'�'�����4�4s��
(�(c��d}tj�|��sgt�dt|��z��t
|d��5tj|d��ddd��n#1swxYwYtj|��j	}|tj
zr,t�dt|��z��dSt
|d���5}t|���d	�
��}ddd��n#1swxYwY	tj|��}n#t$rd}YnwxYwt!|t"��r|�dd��|kr�t�dt|��z��d|i}t
|d
���5}|�t)tj|��d	�
����ddd��n#1swxYwY|S)zR Loads the cache file requested if possible. The file must not be world writable. �z/Creating Galaxy API response cache file at '%s'�wi�NzKGalaxy cache has world writable access (%s), ignoring it as a cache source.�rb��mode�surrogate_or_strict��errors�versionz:Galaxy cache file at '%s' has an invalid version, clearing�wb)�os�path�isfiler>r?r�open�chmod�stat�st_mode�S_IWOTH�warning�read�json�loadsrCr(�dictrG�writer�dumps)�b_cache_path�
cache_version�
cache_mode�fd�json_valr6s      r"�_load_cacher~�s����M�
�7�>�>�,�'�'�*����F��Q]�I^�I^�^�_�_�_�
�,��
$�
$�	*�	*��H�\�5�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*����&�&�.�J��D�L� �����e�!�,�/�/�0�	1�	1�	1���	
�l��	&�	&�	&�D�"��2�7�7�9�9�-B�C�C�C��D�D�D�D�D�D�D�D�D�D�D����D�D�D�D���
�8�$�$�����������������e�T�"�"�P�e�i�i�	�4�&@�&@�M�&Q�&Q����Q�T[�\h�Ti�Ti�i�j�j�j��M�*���,�T�
*�
*�
*�	P�b��H�H�X�d�j��/�/�8M�N�N�N�O�O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P��LsH�A>�>B�B�.$D�D"�%D"�*D?�?E�
E�?7H�H�	Hc�F�d�d�|dzD����S)N�/c3�bK�|]*}|�t|d����d��V��+dS)rerfr�N)r�strip)�.0�as  r"�	<genexpr>z_urljoin.<locals>.<genexpr>�sD����e�e�a�cd�e�I�a�(=�>�>�>�D�D�S�I�I�e�e�e�e�e�er&)rY)rJ)rs r"rFrF�s*���8�8�e�e�SW�Z_�S_�e�e�e�e�e�er&c�"��eZdZdZ�fd�Z�xZS)r)z( Error for bad Galaxy server responses. c����tt|���|��|j|_|���|_	t|�����}tj
|��}n#ttf$ri}YnwxYw|j�
d��}d|vr@|�d|j��}|�dd��}d||j||fz}n�d|vr�|�dg��}	|	sig}	g}
|	D]l}|�d	��p|�d
��p|j}|�d��pd}
d|j||
fz}|
�|���m|�dd
�|
����}n(|�d|j��}d||j|fz}t%|��|_dS)Nr�r:�message�code�Unknownz(%s (HTTP Code: %d, Message: %s Code: %s)�v3rg�detail�titlez%(HTTP Code: %d, Message: %s Code: %s)r<r;�defaultz%s (HTTP Code: %d, Message: %s))�superr)�__init__r�r*�geturlr\rrsrtru�AttributeErrorrC�splitrG�reason�appendrJrr�)rN�
http_errorr��http_msg�err_info�	url_split�
galaxy_msgr��full_error_msgrg�
message_lines�error�	error_msg�
error_code�message_line�	__class__s               �r"r�zGalaxyError.__init__�s���
�k�4� � �)�)�'�2�2�2�#�����$�$�&�&���	��z���0�0�1�1�H��z�(�+�+�H�H���
�+�	�	�	��H�H�H�	�����H�N�N�3�'�'�	��9���!���i��1B�C�C�J��<�<��	�2�2�D�H�G�UY�Uc�eo�qu�Kv�v�N�N�
�Y�
�
��\�\�(�B�/�/�F��
�����M��
3�
3��!�I�I�h�/�/�Z�5�9�9�W�3E�3E�Z��IZ�	�"�Y�Y�v�.�.�;�)�
�G�4�>�[d�fp�Jq�q���$�$�\�2�2�2�2�(/������=�1I�1I�1I�J�N�N�"���i��1B�C�C�J�?�7�D�N�\f�Bg�g�N� ��0�0����s�5B�B�B)rM�
__module__�__qualname__�__doc__r��
__classcell__)r�s@r"r)r)�s>�������2�2�"1�"1�"1�"1�"1�"1�"1�"1�"1r&r)�CollectionMetadata)�	namespacerA�created_str�modified_strc��eZdZd�ZdS)�CollectionVersionMetadatac	�v�||_||_||_||_||_||_||_||_dS)a�
        Contains common information about a collection on a Galaxy server to smooth through API differences for
        Collection and define a standard meta info for a collection.

        :param namespace: The namespace name.
        :param name: The collection name.
        :param version: The version that the metadata refers to.
        :param download_url: The URL to download the collection.
        :param artifact_sha256: The SHA256 of the collection artifact for later verification.
        :param dependencies: A dict of dependencies of the collection.
        :param signatures_url: The URL to the specific version of the collection.
        :param signatures: The list of signatures found at the signatures_url.
        N)r�rArh�download_url�artifact_sha256�dependencies�signatures_url�
signatures)	rNr�rArhr�r�r�r�r�s	         r"r�z"CollectionVersionMetadata.__init__�sD��#�����	����(���.���(���,���$����r&N)rMr�r�r�r$r&r"r�r��s#������%�%�%�%�%r&r�c
���eZdZdZddddddded��df	d�Zd�Zd	�Zd
�Zd�Z	e
egd���d
�����Ze
eddd���e���		d+d���Zd,d�Zed���Zedg��d���Zedg��d-d���Zedg��d.d���Zedg��d/d���Zedg��d���Zedg��d���Zedg��d���Zedg��d���Zedg��d���Zedg��d ���Zedg��d!���Zed"d#g��d$���Zed"d#g��d0d&���Z ed"d#g��d'���Z!ed"d#g��d(���Z"ed"d#g��d)���Z#ed"d#g��d*���Z$dS)1�	GalaxyAPIzM This class is meant to be used as a API client for an Ansible Galaxy server NTF�inf�<c
��||_||_||_||_||_||_||_||_|pi|_||_	||_
ttj
d���}
t|
d���tj�|
d��|_|	r�t&5tj�|j��rHt*�dt/|j��z��tj|j��ddd��n#1swxYwYd|_|
st5|j��|_t*�d|j�d|j����dS)	Nrerfi�rcsapi.jsonzClearing cache file (%s)zValidate TLS certificates for z: )�galaxyrA�username�password�tokenr@�validate_certs�timeoutr=�	_priority�_server_timeoutr�C�GALAXY_CACHE_DIRrrjrkrJ�
_b_cache_pathr�existsr>r?r�remove�_cacher~�debug)rNr�rAr\r�r�r�r��available_api_versions�clear_response_cache�no_cache�priorityr��b_cache_dirs              r"r�zGalaxyAPI.__init__�s��������	� ��
� ��
���
����,������'=�'C���$�!���&����q�1�:O�P�P�P���k��.�.�.�.��W�\�\�+�{�C�C����	2��
2�
2��7�>�>�$�"4�5�5�2��L�L�!;�g�d�FX�>Y�>Y�!Y�Z�Z�Z��I�d�0�1�1�1�
2�
2�
2�
2�
2�
2�
2�
2�
2�
2�
2����
2�
2�
2�
2�
����	:�%�d�&8�9�9�D�K��
�
�
�����QU�Qd�Qd�e�f�f�f�f�fs�*A-D#�#D'�*D'c�*�t|j��S)z3Render GalaxyAPI as a native string representation.)rrA�rNs r"�__str__zGalaxyAPI.__str__"s�����#�#�#r&c�*�t|j��S)z9Render GalaxyAPI as a unicode/text string representation.)rrAr�s r"�__unicode__zGalaxyAPI.__unicode__'s���t�y�!�!�!r&c�R�d�||j|j|j���S)z9Render GalaxyAPI as an inspectable string representation.z><{instance!s} "{name!s}" @ {url!s} with priority {priority!s}>)�instancerAr�r\)�formatrAr�r@r�s r"�__repr__zGalaxyAPI.__repr__,s1��
M��F��D�I���T�_�
�
�
�	
r&c�z�t||j��stS|j|jkp|j|jkS)z:Return whether the instance priority is higher than other.)r(r��NotImplementedr�rA)rN�other_galaxy_apis  r"�__lt__zGalaxyAPI.__lt__7sE���*�D�N�;�;�	"�!�!�
�N�-�7�7�
"��I��	�!�	
r&)r9r:r�c��|jSr)r=r�s r"r�z GalaxyAPI.available_api_versionsBs
���+�+r&���()�retries�
delay_base�delay_threshold)�backoff_iterator�should_retry_errorc	
�:�t|��}	t|��}
|s|	j}t|	j��}|�r:|j�r2|j�|
i��}d}
d}||vrNtj�||d|
��}tj�	��|k}d|vpd|v}|rd|sb||}|�
d��r;d|vrdd	dii}nd	di}g|d
<|d
D]}|d
�|���n|d
}|S|sQtj�	��}|tjd���z
}|�
|
��dd
�||<|pi}|�|||���	t�d|z��t#t%|��||j|||jt+��d���}nQ#t,$r}t/||���d}~wt0$r'}t3d|�dt%|�������d}~wwxYwt5|���d���}	t9j|��}n5#t<$r(t3d|j�dt%|�������wxYw|rl|jre|j|
|}d}dD]
}||vr|}n�|r<d|d<|�d
g��}||D]}|�|���n||d
<|S)Nz%Y-%m-%dT%H:%M:%SZF�expires�page�offset�	paginatedz/v3/�links�next�resultsr`)�days)r�r�)�requiredzCalling Galaxy at %s�safe)rPr��headersr4r��
http_agent�follow_redirectsz1Unknown error when attempting to call Galaxy at 'z': rerfz&Failed to parse Galaxy response from 'z' as JSON:
)rPr�T) r	r^rkr
�queryr��
setdefault�datetime�strptime�utcnowrGr��	timedelta�strftime�_add_auth_tokenr>r?rrr�r�rrr)�	Exceptionr
rrsrtrurCr\)rNr\rr�r4�
auth_requiredr5r6�	cache_keyr]�cache_idr��server_cache�iso_datetime_format�validr��is_paginated_url�
path_cache�res�result�resp�e�	resp_datarP�
paginated_key�keyr�s                           r"rBzGalaxyAPI._call_galaxyHs����C�=�=����$�$���	&� �
�I����(�(���%	�T�[�%	��;�1�1�(�B�?�?�L�"6���E��L�(�(�"�+�4�4�\�)�5L�Y�5W�Yl�m�m�� �)�0�0�2�2�W�<��%���C�(�e�2C���
�-�
�)�)�4�
��>�>�+�.�.�
0���*�*�&����7���%�t�n��&(�C�	�N�",�Y�"7�6�6���I��-�-�f�5�5�5�5�6�%�Y�/�C��
�%�
�"�+�2�2�4�4���8�-�1�5�5�5�5��&�/�/�0C�D�D�!&�+�+��Y�'�
�-�R�����W�c�M��B�B�B�	q��L�L�/�#�5�6�6�6��I�c�N�N��d�FY�cj�#)�4�3G�T^�T`�T`�sy�{�{�{�D�D���	4�	4�	4��a�!2�3�3�3������	q�	q�	q��,�]`�]`�]`�bk�lm�bn�bn�bn�o�p�p�p�����	q�����D�I�I�K�K�0E�F�F�F�	�	C��:�i�(�(�D�D���	C�	C�	C��,�"&�(�(�(�I�i�,@�,@�,@� B�C�C�
C�	C�����	-�T�[�	-���X�.�y�9�J�!�M�*�
�
���$�;�;�$'�M��E���
-�*.�
�;�'�$�/�/�	�2�>�>��"�=�1�+�+�F��N�N�6�*�*�*�*�+�)-�
�9�%��s1�AG.�.
H<�8H�
H<�"H7�7H<�#I8�82J*c��d|vrdS|js;|r9td�ttj�������|jr.|�|j�����dSdS)N�
AuthorizationzMNo access token or username set. A token can be set with --api-key or at {0}.)r�r
r�rr��GALAXY_TOKEN_PATH�updater�)rNr�r\�
token_typer�s     r"r�zGalaxyAPI._add_auth_token�s����g�%�%��F��z�	T�h�	T�� ,�,2�F�9�Q�=P�3Q�3Q�,R�,R�T�T�
T��:�	1��N�N�4�:�-�-�/�/�0�0�0�0�0�	1�	1r&c���t|jd���5}|�tt	j|j��d�����ddd��dS#1swxYwYdS)Nrircrerf)rmr�rwrrtrxr�)rNr|s  r"�
_set_cachezGalaxyAPI._set_cache�s���
�$�$�4�
0�
0�
0�	V�B��H�H�X�d�j���5�5�>S�T�T�T�U�U�U�	V�	V�	V�	V�	V�	V�	V�	V�	V�	V�	V�	V����	V�	V�	V�	V�	V�	Vs�<A � A$�'A$r9c���t|j|jdd��dz}td|i��}	t	|||jdt
��|j���}nP#t$r}t|d���d}~wt$r&}td	t|��z|�
���d}~wwxYwtjt|���d�����}|S)
z2
        Retrieve an authentication token
        r9�tokensr��github_token�POST)rPr�r4r�r�z$Attempting to authenticate to galaxyNz$Unable to authenticate to galaxy: %s)�orig_excrerf)rFr@r�rrr�rr�rr)r�r
rrtrurrs)rNrr\rrrrPs       r"�authenticatezGalaxyAPI.authenticate�s��
�t���(C�D�(I�8�T�T�WZ�Z���.�,�7�8�8��	b��C�d�4�;N�W]�jt�jv�jv�AE�AU�V�V�V�D�D���	I�	I�	I��a�!G�H�H�H������	b�	b�	b��E�	�RS���T�_`�a�a�a�a�����	b�����z�'�$�)�)�+�+�6K�L�L�L�M�M���s#�+A#�#
B0�-A=�=
B0�
!B+�+B0c�\�t|j|jdd��dz}|||r|ndd�}|r||d<n2|�d��r|t	d��dzd	�|d<|�|t
|��d
���}|�dd	��r|dS|S)
z(
        Post an import request
        r9�importsr�rY)�github_user�github_repo�github_reference�alternate_role_namezansible-roler`Nr�rr4r�)rFr@r��
startswith�lenrBrrG)rNrr�	reference�	role_namer\rrPs        r"�create_import_taskzGalaxyAPI.create_import_task�s���
�t���(C�D�(I�9�U�U�X[�[��&�&�-6� >�	�	�B�
�
��
�	P�*3�D�&�'�'�
�
#�
#�N�
3�
3�	P�*5�c�.�6I�6I�A�6M�6N�6N�*O�D�&�'�� � ��9�T�?�?�6� �J�J���8�8�I�t�$�$�	#��	�?�"��r&c���t|j|jdd��}|�d||fz}n|�
|�|�d|�d|��}ntd���|�|��}|dS)	z5
        Check the status of an import task.
        r9rNz%s?id=%d�
?github_user=�
&github_repo=z/Expected task_id or github_user and github_repor�)rFr@r�r
rB)rN�task_idrrr\rPs      r"�get_import_taskzGalaxyAPI.get_import_task�s���
�t���(C�D�(I�9�U�U������W�~�-�C�C�
�
$��)@�8;���[�[�[�+�+�V�C�C��P�Q�Q�Q�� � ��%�%���I��r&c	��ttt|������}	|�d��}d�|dd���}|d}|r t
�d|�d|����n #t$rtd|z���wxYwt|j	|j
ddd	|�d
|����}|�|��}t|d��dkr|ddSdS)
z&
        Find a role by name.
        �.r���z- downloading role 'z', owned by zAInvalid role name (%s). Specify role as format: username.rolenamer9�rolesz?owner__username=z&name=r�N)
r�urlquoterr�rJr>r�r
rFr@r�rBr)rNr�notify�parts�	user_namer\rPs       r"�lookup_role_by_namezGalaxyAPI.lookup_role_by_name�s*��
�H�X�i�%8�%8�9�9�:�:�	�	p��O�O�C�(�(�E�����q��t��-�-�I��b�	�I��
a�����)�)�)�U^�U^� _�`�`�`����	p�	p�	p��b�en�n�o�o�o�	p�����t���(C�D�(I�7�7�8A�	�	�9�9�M�O�O��� � ��%�%���t�I����1�$�$��	�?�1�%�%��ts�AB�B%c�>�g}	t|j|jdd||d��}|�|��}|d}|�dd��du}t|j��}|j�d|j�d�}|sPt||d��}|�|��}||dz
}|�dd��du}|�PnG#t$r:}	t�
d	|�d
|�dt|	������Yd}	~	nd}	~	wwxYw|S)z�
        Fetch the list of related items for the given role.
        The url comes from the 'related' field of the role.
        r9r(z
?page_size=50r��	next_linkNz://r�zUnable to retrieve role (id=z) data (z)), but this is not fatal so we continue: )rFr@r�rBrGr	�scheme�netlocr�r>rrr)
rN�related�role_idr�r\rP�doner]�base_urlrs
          r"�fetch_role_relatedzGalaxyAPI.fetch_role_relatedsf����	>��4�?�D�,G��,M�w�X_�ah�*�,�,�C��$�$�S�)�)�D��9�o�G��H�H�[�$�/�/�4�7�D� ���0�0�H�%-�_�_�_�h�o�o�o�F�H��
=��x��k�):�;�;���(�(��-�-���4�	�?�*������d�3�3�t�;��	�
=���
�	>�	>�	>��O�O�O�&�w�w���������=�
>�
>�
>�
>�
>�
>�
>�
>�����	>�����s�CC�
D� 0D�Dc	���	t|j|jd|d��}|�|��}d|vr	|d}n|}d}d|vr|�dd��du}|sUt|j|d��}|�|��}||dz
}|�dd��du}|�U|S#t
$r'}t
d|�d	t|�������d}~wwxYw)
z4
        Fetch the list of items specified.
        r9z
?page_sizer�Tr�r/NzFailed to download the z list: )rFr@r�rBrGr�r
r)rN�whatr\rPr�r4r�s       r"�get_listzGalaxyAPI.get_lists*��
	`��4�?�D�,G��,M�t�Ua�b�b�C��$�$�S�)�)�D��D� � ��y�/������D���~�~�����d�3�3�t�;���
=��t���[�0A�B�B���(�(��-�-���4�	�?�*������d�3�3�t�;��	�
=�
�N���	`�	`�	`��,�t�t�t�Y�W\�M]�M]�M]�^�_�_�_�����	`���s�B<B?�?
C0�	"C+�+C0c	���t|j|jdddd��}|r/|dtt	t|������zz
}|�dd��}|�dd��}|�dd��}|�d	d��}|rEt|t��r0|�	d
��}|dd�
|��zz
}|rEt|t��r0|�	d
��}|d
d�
|��zz
}|r|d|zz
}|r|d|zz
}|�|��}|S)Nr9�searchr(�?z&autocomplete=�tags�	platforms�	page_size�author�,z&tags_autocomplete=�+z&platforms_autocomplete=z
&page_size=%sz&username_autocomplete=%s)rFr@r�rr)rrGr(rr�rJrB)	rNr;r �
search_urlr=r>r?r@rPs	         r"�search_roleszGalaxyAPI.search_roles6sv���d�o�t�/J�4�/P�RZ�\c�eh�i�i�
��	Q��*�W�X�h�v�>N�>N�5O�5O�-P�-P�P�P�J��z�z�&�$�'�'���J�J�{�D�1�1�	��J�J�{�D�1�1�	����H�d�+�+���	A�J�t�\�2�2�	A��:�:�c�?�?�D��/�#�(�(�4�.�.�@�@�J��	K��I�|�<�<�	K�!����,�,�I��4�s�x�x�	�7J�7J�J�J�J��	6��/�I�5�5�J��	?��5��>�>�J�� � ��,�,���r&c��t|j|jdd��dz}t||||d���}|�||d���}|S)Nr9�notification_secretsr�)�sourcerr�secretrr)rFr@r�rrB)rNrGrrrHr\rrPs        r"�
add_secretzGalaxyAPI.add_secretTsj���t���(C�D�(I�Ka�b�b�eh�h����&�&��	
�
����� � ��4�� �?�?���r&c�v�t|j|jdd��}|�|d���}|S)Nr9rFT)r��rFr@r�rB)rNr\rPs   r"�list_secretszGalaxyAPI.list_secrets`s;���t���(C�D�(I�Ka�b�b��� � ��D� �9�9���r&c��t|j|jdd|��dz}|�|dd���}|S)Nr9rFr�T�DELETE�r�r4rK)rN�	secret_idr\rPs    r"�
remove_secretzGalaxyAPI.remove_secretfsF���t���(C�D�(I�Ka�cl�m�m�ps�s��� � ��D�� �J�J���r&c	��t|j|jddd|�d|����}|�|dd���}|S)Nr9�
removeroler!r"TrNrOrK)rNrrr\rPs     r"�delete_rolezGalaxyAPI.delete_rolelsR���t���(C�D�(I�<�<�;F�;�;���T�V�V��� � ��D�� �J�J���r&r:r�c�l�t�d|�d|j�d|j����t|d���}tj�|��stdt|��z���tj
|��stdt|��z���t|d��5}t|�
��tj�	��}d
d
d
��n#1swxYwYt!||dd�d
���\}}|t#|��d�}d|jvr&t'|j|jddd��dz}n$t'|j|jdd��dz}|�|||ddd|j�d|j�d����}	|	dS)z�
        Publishes a collection to a Galaxy server and returns the import task URI.

        :param collection_path: The path to the collection tarball to publish.
        :return: The import task URI that contains the import results.
        z Publishing collection artifact 'z' to r<rerfz2The collection path specified '%s' does not exist.zThe collection path specified '%s' is not a tarball, use 'ansible-galaxy collection build' to create a proper release artifact.rb)�	hash_funcNzapplication/octet-stream)�filename�	mime_type)�sha256�file)zContent-typezContent-lengthr��	artifacts�collectionsr�r:rTz$Error when publishing collection to r1r2)rr�r4r�r5�task)r>rAr@rrjrkr�r
r�tarfile�
is_tarfilermrrs�hashlibrYrrr�rFrB)
rN�collection_path�b_collection_path�collection_tarrY�content_type�b_form_datar�rOrs
          r"�publish_collectionzGalaxyAPI.publish_collectionusK��	����/�/�/�[_�[d�[d�[d�fj�fu�fu�v�w�w�w�$�_�=R�S�S�S���w�~�~�/�0�0�	k��S�V_�`o�Vp�Vp�p�q�q�q��#�$5�6�6�	k�� M�OX�Yh�Oi�Oi� j�k�k�
k��#�T�
*�
*�	T�n�"�>�#6�#6�#8�#8�G�N�S�S�S�F�	T�	T�	T�	T�	T�	T�	T�	T�	T�	T�	T����	T�	T�	T�	T�%6� � 1�!;���
�
�%
�%
�!��k�)�!�+�.�.�
�
��
�4�.�.�.��T�_�d�.I�$�.O�Q\�^k�l�l�or�r�E�E��T�_�d�.I�$�.O�Q^�_�_�be�e�E�� � ��[�'�RX�hl�hl�6:�i�i�i�����4R�!�S�S���F�|�s�.C:�:C>�C>rc�
�d}d}d|jvr$t|j|jdd|d��}n#t|j|jdd|d��}t�d|z��t	j��}d	}|d
kst	j��|z
|k�r	|�|ddd
|z���}nT#t$rG}|jdkr�t�d|z��t	j	|��Yd}~��d}~wwxYw|�
dd��}|�
dd��rngt�d||fz��t	j	|��td|dz��}|d
k��t	j��|z
|k��|dkrtdt|��z���|�
dg��D]�}	|	d}
|
���dkr$t�d|	dz���F|
���dkr$t�d|	dz����t�d|
�d|	d������|d krkt|d�
d!d"����}t|d�
d#d$|z����}td%|�d&|�d'����dS)(aH
        Waits until the import process on the Galaxy server has completed or the timeout is reached.

        :param task_id: The id of the import task to wait for. This can be parsed out of the return
            value for GalaxyAPI.publish_collection.
        :param timeout: The timeout in seconds, 0 is no timeout.
        �waitingNr�zimports/collectionsr�r:zcollection-importsz1Waiting until Galaxy import task %s has completedr�rr3Tz,Error when getting import task results at %s)r4r�r5r7zJGalaxy import process has not started, wait %s seconds before trying again�state�finished_atzMGalaxy import process has a status of %s, wait %d seconds before trying again�g�?zUTimeout while waiting for the Galaxy import process to finish, check progress at '%s'�messages�levelr�zGalaxy import error message: %sr�rrz!Galaxy import warning message: %szGalaxy import message: z - �failedr��UNKNOWN�descriptionz&Unknown error, see %s for more detailszGalaxy import process failed: z (Code: r2)r�rFr@r>�timerBr)r*�vvv�sleeprG�minr
r�lowerr�rr)
rNr#r�rirP�full_url�start�waitrr�rmr�rps
             r"�wait_import_taskzGalaxyAPI.wait_import_task�sT�������4�.�.�.�����1L�T�1R� 5�w��E�E�H�H� ����1L�T�1R� 4�g�s�D�D�H�	���K�h�V�W�W�W��	��������l�l�t�y�{�{�U�2�g�=�=�	
��(�(��%�t�;i�lt�;t�)�v�v�����
�
�
��;�#�%�%�����h�ko�o�p�p�p��
�4� � � ����������

�����H�H�W�i�0�0�E��x�x�
�t�,�,�
���K�K�g� �$�-�(�
)�
)�
)��J�t�����r�4�#�:�&�&�D�-��l�l�t�y�{�{�U�2�g�=�=�.�I����v�!*�8�!4�!4� 5�6�6�
6��x�x�
�B�/�/�	\�	\�G��G�$�E��{�{�}�}��'�'��
�
�?�'�)�BT�T�U�U�U�U������)�+�+���� C�g�i�FX� X�Y�Y�Y�Y��������w�y�GY�GY�Z�[�[�[�[��H����T�'�]�.�.�v�y�A�A�B�B�D�#��W�
�!�!�-�1Y�\d�1d�e�e�g�g�K��,�P[�P[�P[�]a�]a�]a�b�c�c�c�	�s�)C�
D�=D�Dc	�N�d|jvr|jd}ddg}n|jd}ddg}t|j|d||d��}d	|�d
|�d|j�d|j�d
�	}|�||���}i}|D]\}}	|�|	d��||<�t
||fi|��S)z�
        Gets the collection information from the Galaxy server about a specific Collection.

        :param namespace: The collection namespace.
        :param name: The collection name.
        return: CollectionMetadata about the collection.
        r�)r��
created_at)r��
updated_atr:)r��created)r��modifiedr\r�z+Error when getting the collection info for r&� from r1r2)r5N)r�rFr@rArBrGr�)
rNr�rA�api_path�	field_map�info_urlr5rP�metadata�	api_fields
          r"�get_collection_metadataz!GalaxyAPI.get_collection_metadata�s����4�.�.�.��2�4�8�H�-�.��I�I�
�2�4�8�H�*�,��I�
�D�O�X�}�i�QU�WZ�[�[���(�y�y�$�$�$��	�	�	�4�?�?�?�L��� � ��=N� �O�O����(�	7�	7�O�D�)�!�X�X�i��6�6�H�T�N�N�!�)�T�>�>�X�>�>�>r&c��|j�d|j�d����}|j|d||d|dg}t|�}d|�d|�d|�d	|j�d
|j�d�}|�||d�
��}|���|�d��pg}	t|dd|dd|d|d|dd|dd|d|	��S)at
        Gets the collection information from the Galaxy server about a specific Collection version.

        :param namespace: The collection namespace.
        :param name: The collection name.
        :param version: Version of the collection to get the information for.
        :return: CollectionVersionMetadata about the collection at the version requested.
        r�r:r\rTr��3Error when getting collection version metadata for r&rXrr1r2T�r5r6r�r�rA�
collectionrhr��artifactrYr�r��href)r�rGr@rFrArBr
r��
rNr�rArhr��	url_paths�n_collection_urlr5rPr�s
          r"�get_collection_version_metadataz)GalaxyAPI.get_collection_version_metadatas)���.�2�2�4��9T�9X�9X�Y]�9^�9^�_�_���_�h�
�y�$�PZ�\c�eh�i�	�#�Y�/���(�y�y�$�$�$��������D�O�O�O�U��� � �!1�EV�^b� �c�c���������X�X�l�+�+�1�r�
�(��k�):�6�)B�D��DV�W]�D^�`d�en�`o�)-�n�)=�t�J�?O�PX�?Y�)-�j�)9�.�)I�4�PV�<�Yc�e�e�	er&c���d}d|jvr|jd}ddg}d}n|jd}dg}d|jvrdnd}t|j|d	||d
d|tfz��}t	|��}|j}	|jr�|j�t|��i��}
|
�di��}	|�	||��j
}n%#t$r}
|
jd
kr�gcYd}
~
Sd}
~
wwxYw|�
|�d|��d��}||kr*|||�d|��<|j|
vr|
|	=|���d|�d|�d|j�d|j�d�	}	|�||d|	���}n%#t$r}
|
jd
kr�gcYd}
~
Sd}
~
wwxYwd|vrd}nd}g}	|d�||D��z
}|}|D]}|�
|i��}�|snh|r=t#|t	|��j��}|�|j|��}|�t'|d���|d|	���}��|���|S)z�
        Gets a list of available versions for a collection on a Galaxy server.

        :param namespace: The collection namespace.
        :param name: The collection name.
        :return: A list of versions that are available.
        Fr�r�r�Tr:�limitr?r\rTz/?%s=%dr~r7Nr&z5Error when getting available collection versions for rr1r2)r5r6r�rPr�c��g|]
}|d��S)rhr$)r��vs  r"�
<listcomp>z5GalaxyAPI.get_collection_versions.<locals>.<listcomp>as��A�A�A�!��9��A�A�Ar&rerf)r�rFr@�COLLECTION_PAGE_SIZEr	rkr�r�r^r�r�r)r*rGr
rArBr�replacer)rNr�rA�
relative_linkr��pagination_path�page_size_name�versions_url�versions_url_infor�r��modified_cache�
modified_daterQ�cached_modified_dater5rP�results_keyrTr/rks                     r"�get_collection_versionsz!GalaxyAPI.get_collection_versionssP���
��4�.�.�.��2�4�8�H�&��/�O� �M�M��2�4�8�H�%�h�O�$(�D�,G�$G�$G���[������=�)�UY�[e�gp�uC�EY�tZ�hZ�[�[��$�\�2�2��%�*�	��;�	"��;�1�1�,�|�2L�2L�b�Q�Q�L�)�4�4�Z��D�D�N�
� $� <� <�Y�� M� M� Z�
�
���
�
�
��=�C�'�'���	�	�	�	�	�	�����	
����$2�#5�#5����D�D�6Q�SW�#X�#X� �#�}�4�4�>K��)�)�)�T�T�:�;�$�)�\�9�9�$�Y�/����!�!�!�� )�y�y�$�$�$��	�	�	�4�?�?�?�L��	��$�$�\�EV�^b�nw�$�x�x�D�D���	�	�	��}��#�#���I�I�I�I�I�I�����		�����T�>�>�!�K�K�#�K���	k��A�A�t�K�/@�A�A�A�A�H��I�'�
4�
4��%�M�M�$��3�3�	�	��
T���
T�
 '�|�X�l�5K�5K�5P�Q�Q��(�0�0�1B�1G��S�S�	��$�$�Y�y�AV�%W�%W�%W�7H�PT�`i�%�k�k�D�#	k�&	
�������s<�=C�
C;�#
C6�0C;�6C;�#E=�=
F�
F�F�Fc���|j�d|j�d����}|j|d||d|dg}t|�}d|�d|�d|�d	|j�d
|j�d�}|�||d�
��}|���	|d}	d�|	D��S#t$r0t�	d|j�d|�d|�d|����gcYSwxYw)aG
        Gets the collection signatures from the Galaxy server about a specific Collection version.

        :param namespace: The collection namespace.
        :param name: The collection name.
        :param version: Version of the collection to get the information for.
        :return: A list of signature strings.
        r�r:r\rTr�r�r&rXrr1r2Tr�r�c��g|]
}|d��S)�	signaturer$)r��signature_infos  r"r�z7GalaxyAPI.get_collection_signatures.<locals>.<listcomp>�s��Q�Q�Q�N�N�;�/�Q�Q�Qr&zServer z has not signed )
r�rGr@rFrArBr
rDr>�vvvvvvr�s
          r"�get_collection_signaturesz#GalaxyAPI.get_collection_signaturesws4���.�2�2�4��9T�9X�9X�Y]�9^�9^�_�_���_�h�
�y�$�PZ�\c�eh�i�	�#�Y�/���(�y�y�$�$�$��������D�O�O�O�U��� � �!1�EV�^b� �c�c��������	R��l�+�J�R�Q�j�Q�Q�Q�Q���	�	�	��N�N�b�T�_�b�b�i�b�b�RV�b�b�Y`�b�b�c�c�c��I�I�I�	���s�B)�)7C#�"C#)NNNFNFN)NF)NN)NNN)T)r)%rMr�r�r��floatr�r�r�r�r��propertyrVr�rrr-rBr�r%r
rrr$r-r6r9rDrIrLrQrTrfryr�r�r�r�r$r&r"r�r��s4������W�W��D��T�#'�!&���U�5�\�\��
"g�"g�"g�"g�H$�$�$�
"�"�"�
	
�	
�	
�	
�	
�	
���Y�!�!�!�"�"�,�,�#�"��X�,�%�$�2�2�1��\^�_�_�_�2����nr�,0�T�T�T�	��T�l
1�
1�
1�
1��V�V��Z�V��Y��v��������"�Y��v���������&�Y��v���
�
�
���
��Y��v���������,�Y��v��������:�Y��v���`�`���`�.�Y��v��������:�Y��v���	�	���	��Y��v��������
�Y��v��������
�Y��v���������Y��d�|���+�+���+�Z�Y��d�|���?d�?d�?d���?d�B�Y��d�|���?�?���?�@�Y��d�|���e�e���e�0�Y��d�|���U�U���U�n�Y��d�|���R�R���R�R�Rr&r�)C�
__future__rrr�type�
__metaclass__r\r��	functoolsr`rtrjror^rq�	threading�urllib.errorr�urllib.parserr)rr	r
r�ansiblerr��ansible.errorsr
�ansible.galaxy.user_agentr�ansible.module_utils.apirr�ansible.module_utils.sixr�ansible.module_utils._textrrr�ansible.module_utils.urlsrr�ansible.utils.displayr�ansible.utils.hashingr�ansible.utils.pathrr>�Lockrr�r+r%r-rVr^r~rFr)�
namedtupler�r��total_orderingr�r$r&r"�<module>r�s	��
C�B�B�B�B�B�B�B�B�B��
���������������������	�	�	�	�����������������"�"�"�"�"�"�R�R�R�R�R�R�R�R�R�R�R�R�R�R�"�"�"�"�"�"�'�'�'�'�'�'�0�0�0�0�0�0�D�D�D�D�D�D�>�>�>�>�>�>�1�1�1�1�1�1�C�C�C�C�C�C�C�C�C�C�A�A�A�A�A�A�A�A�)�)�)�)�)�)�/�/�/�/�/�/�,�,�,�,�,�,�
�'�)�)���i�n�������������`�`�`�A�A�A�H5�5�5�������Df�f�f�%1�%1�%1�%1�%1�,�%1�%1�%1�T,�[�+�,@�Bv�Bv�Bv�w�w��%�%�%�%�%�%�%�%�4��V
R�V
R�V
R�V
R�V
R�V
R�V
R���V
R�V
R�V
Rr&

Youez - 2016 - github.com/yon3zu
LinuXploit