�
E��cE � �J � d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm
Z
dd
lmZ ddl
mZ ddlmZ dd
lmZ n# e$ r dZdZY nw xY w ej e� � Z G d� d� � Zdedeeef deeef deeeeef f fd�ZdS )z;Common code for DNS Authenticator Plugins built on Lexicon.� N)�Any)�Dict)�Mapping)�Optional)�Union)� HTTPError)�RequestException)�errors)�
dns_common)�ConfigResolver)�Providerc � � e Zd ZdZdd�Zdedededdfd�Zdedededdfd �Zdeddfd
�Zde dede
ej fd
�Z
dedede
ej fd�ZdS )�
LexiconClientzI
Encapsulates all communication with a DNS provider via Lexicon.
�returnNc �
� | d S )N� )�selfs �D/usr/lib/python3/dist-packages/certbot/plugins/dns_common_lexicon.py�__init__zLexiconClient.__init__# s � ����� �domain�record_name�record_contentc � � | � |� � | j � d||�� � dS # t $ rI}t � d|d�� � t
j d� |� � � � �d}~ww xY w)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 r r r �es r �add_txt_recordzLexiconClient.add_txt_record& |