HEX
Server: LiteSpeed
System: Linux cluster02.load-balancer.x2.network 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: kbdhpghp (1098)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/certbot/plugins/__pycache__/dns_common_lexicon.cpython-36.pyc
3

گa;�@sdZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddl
mZyddlmZdd
lmZWnek
r�dZdZYnXeje�ZGdd�d�Zeeeefeeefeeeeeffd�dd�ZdS)z;Common code for DNS Authenticator Plugins built on Lexicon.�N)�Any)�Dict)�Mapping)�Optional)�Union)�	HTTPError)�RequestException)�errors)�
dns_common)�ConfigResolver)�Providerc@s�eZdZdZdd�dd�Zeeedd�dd�Zeeedd�d	d
�Zedd�dd
�Ze	ee
jd�dd�Ze
eee
jd�dd�ZdS)�
LexiconClientzI
    Encapsulates all communication with a DNS provider via Lexicon.
    N)�returncCs|dS)N�)�selfrr�(/usr/lib/python3.6/dns_common_lexicon.py�__init__#szLexiconClient.__init__)�domain�record_name�record_contentrcCsh|j|�y|jjd||d�WnBtk
rb}z&tjd|dd�tjdj|���WYdd}~XnXdS)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)�rtype�name�contentz'Encountered error adding TXT record: %sT)�exc_infozError adding TXT record: {0}N)	�_find_domain_id�providerZ
create_recordr�logger�debugr	�PluginError�format)rrrr�errr�add_txt_record&s	
zLexiconClient.add_txt_recordcCs�y|j|�Wn2tjk
r@}ztjd|dd�dSd}~XnXy|jjd||d�Wn2tk
r�}ztjd|dd�WYdd}~XnXdS)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
        z7Encountered error finding domain_id during deletion: %sT)rNr)rrrz)Encountered error deleting TXT record: %s)rr	rrrrZ
delete_recordr)rrrrr!rrr�del_txt_record7s	zLexiconClient.del_txt_record)rrcCs�tj|�}x�|D]�}y0t|jd�r0||jjd<n||j_|jj�dStk
rz}z|j||�}|rj|�WYdd}~Xqt	k
r�}z|j
||�}|r�|�WYdd}~XqXqWtjdj
||���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.
        �optionsrNzAUnable to determine zone identifier for {0} using zone names: {1})r
Zbase_domain_name_guesses�hasattrrr$rZauthenticater�_handle_http_error�	Exception�_handle_general_errorr	rr )rrZdomain_name_guesses�domain_namer!Zresult1Zresult2rrrrLs$


zLexiconClient._find_domain_id)r!r)rcCstjdj||��S)Nz/Error determining zone identifier for {0}: {1}.)r	rr )rr!r)rrrr&psz LexiconClient._handle_http_errorcCs$t|�jd�s tjdj||��SdS)NzNo domain foundz9Unexpected error determining zone identifier for {0}: {1})�str�
startswithr	rr )rr!r)rrrr(ts
z#LexiconClient._handle_general_error)�__name__�
__module__�__qualname__�__doc__rr*r"r#rrr	rr&r'rr(rrrrr
s$r
)�lexicon_provider_name�lexicon_options�provider_optionsrcCsLd|i}|j|�ts"|j|�n&i}|j|�|||<t�j|�j�}|S)ao
    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
    Z
provider_name)�updaterZ	with_dictZwith_env)r0r1r2�configZprovider_configrrr�build_lexicon_config{s

r5)r/ZloggingZtypingrrrrrZrequests.exceptionsrrZcertbotr	Zcertbot.pluginsr
Zlexicon.configrZlexicon.providers.baser�ImportErrorZ	getLoggerr,rr
r*r5rrrr�<module>s*

]