File: //usr/lib/python3/dist-packages/certbot/plugins/__pycache__/dns_common_lexicon.cpython-310.pyc
o
6��a �
@ s� d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
dd lmZ zdd
l
mZ ddlmZ W n
eyK dZdZY nw e�e�ZG dd
� d
�Zdedededeeef fdd�ZdS )z;Common code for DNS Authenticator Plugins built on Lexicon.� N)�Any)�Dict)�Union)� HTTPError)�RequestException)�errors)�
dns_common)�ConfigResolver)�Providerc @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�
LexiconClientzI
Encapsulates all communication with a DNS provider via Lexicon.
c C s | d S )N� )�selfr r �D/usr/lib/python3/dist-packages/certbot/plugins/dns_common_lexicon.py�__init__! s zLexiconClient.__init__c
C s\ | � |� z| jjd||d� W dS ty- } ztjd|dd� t�d�|���d}~ww )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�provider�
create_recordr �logger�debugr �PluginError�format�r
�domain�record_name�record_content�er r r �add_txt_record$ s
��zLexiconClient.add_txt_recordc
C s� z| � |� W n tjy# } ztjd|dd� W Y d}~dS d}~ww z| jjd||d� W dS tyK } ztjd|dd� W Y d}~dS d}~ww )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: %sTr Nr r z)Encountered error deleting TXT record: %s)r r r r r r �
delete_recordr r r r r �del_txt_record5 s �����zLexiconClient.del_txt_recordc C s� t �|�}|D ]S}zt| jd�r|| jjd<