%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/module_utils/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/module_utils/__pycache__/api.cpython-39.pyc

a

�)g��@s�dZddlmZmZmZeZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mmmZddd�Zddd�Zddd	�Zdd
d�Zdd
d�Zddd�Zdd�Zddd�ZdS)a�
This module adds shared support for generic api modules

In order to use this module, include it as part of a custom
module as shown below.

The 'api' module provides the following common argument specs:

    * rate limit spec
        - rate: number of requests per time unit (int)
        - rate_limit: time window in which the limit is applied in seconds

    * retry spec
        - retries: number of attempts
        - retry_pause: delay between attempts in seconds
�)�absolute_import�division�print_functionNcCs*ttdd�tdd�d�}|r&|�|�|S)z7Creates an argument spec for working with rate limiting�int��type)�rate�
rate_limit��dict�update��specZarg_spec�r�</usr/lib/python3.9/site-packages/ansible/module_utils/api.py�rate_limit_argument_spec's�
rcCs,ttdd�tddd�d�}|r(|�|�|S)z2Creates an argument spec for working with retryingrr�float��r�default��retries�retry_pauser
r
rrr�retry_argument_spec2s
�
rcCs>ttdd�tddd�tdd�tddd�d�}|r:|�|�|S)N�strrT)rZno_log�boolr)Zapi_usernameZapi_passwordZapi_urlZvalidate_certsr
r
rrr�basic_auth_argument_spec=s

�
rcs4d�|dur$|dur$t|�t|���fdd�}|S)zrate limiting decoratorNcsdg����fdd�}|S)Ngcsdtjdkrtj}ntj}�durR|��d}�|}|dkrHt�|�|��d<�|i|��}|S)N)��r)�sys�version_info�time�process_timeZclock�sleep)�args�kwargsZ	real_time�elapsed�left�ret)�f�last�minraterr�ratelimitedRs


z0rate_limit.<locals>.wrapper.<locals>.ratelimitedr)r)r,�r+)r)r*r�wrapperOszrate_limit.<locals>.wrapper)r)rr	r.rr-rr	Is
r	rcs��fdd�}|S)zRetry decoratorcs���fdd�}|S)Ncsld}�durhd}|d7}|�kr,td���z�|i|��}WntyPYn0|rXqdt���q|SdS)NrrzRetry limit exceeded: %d)�	Exceptionr!r#)r$r%Zretry_countr()r)rrrr�retriedhsz'retry.<locals>.wrapper.<locals>.retriedr)r)r0r)r)rr.fszretry.<locals>.wrapperr)rrr.rrr�retrydsr1�
r�<c	cs0td|�D] }t�dt||d|��Vq
dS)aDThe "Full Jitter" backoff strategy.

    Ref: https://www.awsarchitectureblog.com/2015/03/backoff.html

    :param retries: The number of delays to generate.
    :param delay_base: The base time in seconds used to calculate the exponential backoff.
    :param delay_threshold: The maximum time in seconds for any delay.
    r�N)�range�randomZrandint�min)rZ
delay_baseZdelay_thresholdr1rrr�generate_jittered_backoff}s	r8cCsdS)NFr)Zexception_or_resultrrr�retry_never�sr9cs0dd�}||��~�durt���fdd�}|S)z�Generic retry decorator.

    :param backoff_iterator: An iterable of delays in seconds.
    :param should_retry_error: A callable that takes an exception of the decorated function and decides whether to retry or not (returns a bool).
    css&t�|�\}}|Vt�|�VqdS)N)�	itertools�tee�copy)Zoriginal_iteratorZ_copiable_iteratorZ_first_iterator_copyrrr�_emit_isolated_iterator_copies�szGretry_with_delays_and_condition.<locals>._emit_isolated_iterator_copiesNcst������fdd��}|S)Ncsrtj�g|�Ri|��}t��D]J}z|�WSty^}z�|�sJ�WYd}~n
d}~00t�|�q |�S)z�This assumes the function has not already been called.
            If backoff_iterator is empty, we should still run the function a single time with no delay.
            N)�	functools�partial�nextr/r!r#)r$r%Zcall_retryable_functionZdelay�e)�backoff_iterator_generator�function�should_retry_errorrr�run_function�szOretry_with_delays_and_condition.<locals>.function_wrapper.<locals>.run_function)r>�wraps)rCrE�rBrD)rCr�function_wrapper�sz9retry_with_delays_and_condition.<locals>.function_wrapper)r9)Zbackoff_iteratorrDr=rHrrGr�retry_with_delays_and_condition�srI)N)N)N)NN)Nr)r2rr3)N)�__doc__Z
__future__rrrrZ
__metaclass__r<r>r:r6rr!Z"ansible.module_utils.compat.typingZmodule_utils�compat�typing�trrrr	r1r8r9rIrrrr�<module>
s"








Zerion Mini Shell 1.0