JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/plugins/__pycache__/dns_common_lexicon.cpython-39.pyc

a

}|�g�2�@s�dZddlZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlZddlmZdd
lmZddlmZddlmZddlmZz(ddlmZddlmZddlmZWn e�ydZdZdZYn0e�e �Z!Gdd�d�Z"e#ee#efee#efeee	e#effd�dd�Z$Gdd�dej%�Z&Gdd�d�Z'eee'ej(e ��ej(e <dS)z;Common code for DNS Authenticator Plugins built on Lexicon.�N)�
ModuleType)�Any)�cast)�Dict)�List)�Mapping)�Optional)�Tuple)�Union)�	HTTPError)�RequestException)�
configuration)�errors)�
dns_common)�Client)�ConfigResolver)�Providerc@s�eZdZdZdd�dd�Zeeedd�dd�Zeeedd�d	d
�Zedd�dd
�Ze	ee
ejd�dd�Z
eee
ejd�dd�ZdS)�
LexiconClientz�
    Encapsulates all communication with a DNS provider via Lexicon.

    .. deprecated:: 2.7.0
       Please use certbot.plugins.dns_common_lexicon.LexiconDNSAuthenticator instead.
    N��returncCs|dS�N���selfrr�F/usr/lib/python3.9/site-packages/certbot/plugins/dns_common_lexicon.py�__init__0szLexiconClient.__init__)�domain�record_name�record_contentrc
Csj|�|�z|jjd||d�WnDtyd}z,tjd|dd�t�d�|���WYd}~n
d}~00dS)a�
        Add a TXT record using the supplied information.

        :param str domain: The domain to use to look up the managed zone.
        :param str record_name: The record name (typically beginning with '_acme-challenge.').
        :param str record_content: The record content (typically the challenge validation).
        :raises errors.PluginError: if an error occurs communicating with the DNS Provider API
        �TXT�Zrtype�nameZcontent�'Encountered error adding TXT record: %sT��exc_info�Error adding TXT record: {0}N)	�_find_domain_id�provider�
create_recordr�logger�debugr�PluginError�format�rrrr�errr�add_txt_record3s	
zLexiconClient.add_txt_recordc
Cs�z|�|�Wn8tjyF}ztjd|dd�WYd}~dSd}~00z|jjd||d�Wn4ty�}ztjd|dd�WYd}~n
d}~00dS)a�
        Delete a TXT record using the supplied information.

        :param str domain: The domain to use to look up the managed zone.
        :param str record_name: The record name (typically beginning with '_acme-challenge.').
        :param str record_content: The record content (typically the challenge validation).
        :raises errors.PluginError: if an error occurs communicating with the DNS Provider  API
        �7Encountered error finding domain_id during deletion: %sTr#Nrr �)Encountered error deleting TXT record: %s)r&rr+r)r*r'�
delete_recordrr-rrr�del_txt_recordDs	�zLexiconClient.del_txt_record�rrcCs�t�|�}|D]�}z4t|jd�r.||jjd<n||j_|j��WdSty~}z |�||�}|rj|�WYd}~qd}~0t	y�}z |�
||�}|r�|�WYd}~qd}~00qt�d�
||���dS)z�
        Find the domain_id for a given domain.

        :param str domain: The domain for which to find the domain_id.
        :raises errors.PluginError: if the domain_id cannot be found.
        �optionsrN�AUnable to determine zone identifier for {0} using zone names: {1})r�base_domain_name_guesses�hasattrr'r5rZauthenticater�_handle_http_error�	Exception�_handle_general_errorrr+r,�rrZdomain_name_guesses�domain_namer.Zresult1Zresult2rrrr&Ys&

�zLexiconClient._find_domain_id�r.r=rcCst�d�||��S�Nz/Error determining zone identifier for {0}: {1}.�rr+r,�rr.r=rrrr9}s�z LexiconClient._handle_http_errorcCs$t|��d�s t�d�||��SdS�NzNo domain foundz9Unexpected error determining zone identifier for {0}: {1}��str�
startswithrr+r,rArrrr;�s
�z#LexiconClient._handle_general_error)�__name__�
__module__�__qualname__�__doc__rrDr/r3r&rrrr+r9r:r;rrrrr(s$r)�lexicon_provider_name�lexicon_options�provider_optionsrcCsRd|i}|�|�tdur(|�|�|Si}|�|�|||<t��|���SdS)a�
    Convenient function to build a Lexicon 2.x/3.x config object.

    :param str lexicon_provider_name: the name of the lexicon provider to use
    :param dict lexicon_options: options specific to lexicon
    :param dict provider_options: options specific to provider
    :return: configuration to apply to the provider
    :rtype: ConfigurationResolver or dict

    .. deprecated:: 2.7.0
       Please use certbot.plugins.dns_common_lexicon.LexiconDNSAuthenticator instead.
    �
provider_nameN)�updater�	with_dict�with_env)rJrKrLZconfig_dictZprovider_configrrr�build_lexicon_config�s


rQcs�eZdZdZejed��fdd�Zee	j
ed�dd���Zeed�dd	��Z
eeed
d�dd
�Zeed�dd�Zd
d�dd�Zeeed
d�dd�Zeeed
d�dd�Zeed�dd�Zeeeejd�dd�Zeeeejd�dd�Z�ZS)�LexiconDNSAuthenticatorzr
    Base class for a DNS authenticator that uses Lexicon client
    as backend to execute DNS record updates
    )�configr!cst��||�g|_|dSr)�superr�_provider_options)rrSr!��	__class__rrr�sz LexiconDNSAuthenticator.__init__rcCsdS)z9
        The name of the Lexicon provider to use
        Nrrrrr�_provider_name�sz&LexiconDNSAuthenticator._provider_namecCsdS)zX
        Time to live to apply to the DNS records created by this Authenticator
        �<rrrrr�_ttl�szLexiconDNSAuthenticator._ttlN)�creds_var_name�creds_var_label�lexicon_provider_option_namercCs|j�|||f�dSr)rU�append)rr[r\r]rrr�_add_provider_option�s�z,LexiconDNSAuthenticator._add_provider_optionr4csPt�d�s���d|d|d�jd�j�j�fdd��jD�i}t��|���S)N�_credentialsrZ	delegatedrMZttlcs"i|]}|d�j�|d��qS)�r)r`Zconf��.0�itemrrr�
<dictcomp>�s�zALexiconDNSAuthenticator._build_lexicon_config.<locals>.<dictcomp>)r8�_setup_credentialsrXrZrUrrOrP)rrZdict_configrrr�_build_lexicon_config�s
��z-LexiconDNSAuthenticator._build_lexicon_configcCs,|jdd|j�d�dd�|jD�d�|_dS)NZcredentialszCredentials INI file for z DNS authenticatorcSsi|]}|d|d�qS)r�rrbrrrre��z>LexiconDNSAuthenticator._setup_credentials.<locals>.<dictcomp>)�keyZlabelZrequired_variables)Z_configure_credentialsrXrUr`rrrrrf�s
�z*LexiconDNSAuthenticator._setup_credentials)r�validation_name�
validationrc
Cs�|�|�}zBt|�|��� }|jd||d�Wd�n1s@0YWnDty�}z,tjd|dd�t�d�	|���WYd}~n
d}~00dS)Nrr r"Tr#r%)
�_resolve_domainrrgr(rr)r*rr+r,)rrrkrl�resolved_domain�
operationsr.rrr�_perform�s
2z LexiconDNSAuthenticator._performc
Cs�z|�|�}Wn8tjyF}ztjd|dd�WYd}~dSd}~00zBt|�|��� }|jd||d�Wd�n1s~0YWn4ty�}ztjd|dd�WYd}~n
d}~00dS)Nr0Tr#rr r1)	rmrr+r)r*rrgr2r)rrrkrlrnr.rorrr�_cleanup�s�2z LexiconDNSAuthenticator._cleanupcCs�t�|�}|D]�}z<t|�|���|Wd�WS1sB0YWqty�}z |�||�}|rr|�WYd}~qd}~0ty�}z |�||�}|r�|�WYd}~qd}~00qt�	d�
||���dS)Nr6)rr7rrgrr9r:r;rr+r,r<rrrrm�s 
,�z'LexiconDNSAuthenticator._resolve_domainr>cCst�d�||��Sr?r@rArrrr9
s�z*LexiconDNSAuthenticator._handle_http_errorcCs$t|��d�s t�d�||��SdSrBrCrArrrr;s
�z-LexiconDNSAuthenticator._handle_general_error)rFrGrHrIr
ZNamespaceConfigrDr�property�abc�abstractmethodrX�intrZr_rrgrfrprqrmrrrr+r9r:r;�
__classcell__rrrVrrR�s"�
rRc@sbeZdZdZed�dd�Zeed�dd�Zeedd	�d
d�Z	eed�dd
�Z
eed�dd�ZdS)�_DeprecationModulez�
    Internal class delegating to a module, and displaying warnings when attributes
    related to deprecated attributes in the current module.
    )�modulecCs||jd<dS�N�_module)�__dict__)rrxrrrrsz_DeprecationModule.__init__)�attrrcCs0|dvr$tj|�dt�d�tdd�t|j|�S)N)rrQz attribute in z/ module is deprecated and will be removed soon.ra)�
stacklevel)�warnings�warnrF�DeprecationWarning�getattrrz�rr|rrr�__getattr__ s
�z_DeprecationModule.__getattr__N)r|�valuercCst|j||�dSr)�setattrrz)rr|r�rrr�__setattr__'sz_DeprecationModule.__setattr__cCst|j|�dSr)�delattrrzr�rrr�__delattr__*sz_DeprecationModule.__delattr__rcCsdgt|j�Sry)�dirrzrrrr�__dir__-sz_DeprecationModule.__dir__)
rFrGrHrIrrrDrr�r�r�rr�rrrrrwsrw))rIrsZlogging�sys�typesr�typingrrrrrrr	r
r~Zrequests.exceptionsrrZcertbotr
rZcertbot.pluginsrZlexicon.clientrZlexicon.configrZlexicon.interfacesr�ImportErrorZ	getLoggerrFr)rrDrQZDNSAuthenticatorrRrw�modulesrrrr�<module>sF

`�s
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w)R$& N1EtdU3Uȉ1pM"N*(DNyd96.(jQ)X 5cQɎMyW?Q*!R>6=7)Xj5`J]e8%t!+'!1Q5 !1 AQaqё#2"0BRb?Gt^## .llQT $v,,m㵜5ubV =sY+@d{N! dnO<.-B;_wJt6;QJd.Qc%p{ 1,sNDdFHI0ГoXшe黅XۢF:)[FGXƹ/w_cMeD,ʡcc.WDtA$j@:) -# u c1<@ۗ9F)KJ-hpP]_x[qBlbpʖw q"LFGdƶ*s+ډ_Zc"?%t[IP 6J]#=ɺVvvCGsGh1 >)6|ey?Lӣm,4GWUi`]uJVoVDG< SB6ϏQ@ TiUlyOU0kfV~~}SZ@*WUUi##; s/[=!7}"WN]'(L! ~y5g9T̅JkbM' +s:S +B)v@Mj e Cf jE 0Y\QnzG1д~Wo{T9?`Rmyhsy3!HAD]mc1~2LSu7xT;j$`}4->L#vzŏILS ֭T{rjGKC;bpU=-`BsK.SFw4Mq]ZdHS0)tLg