← Back
Editing: dns_common_lexicon.cpython-38.pyc
U �]� � @ s� d Z ddlZddlmZmZ ddlmZmZmZ ddl m Z ddlmZ zddl mZ W n ek rp dZY nX e�e�ZG dd � d e�Zd d� ZdS )z;Common code for DNS Authenticator Plugins built on Lexicon.� N)� HTTPError�RequestException)�Union�Dict�Any)�errors)� dns_common)�ConfigResolverc @ 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 | _ d S )N)�provider)�self� r �D/usr/lib/python3/dist-packages/certbot/plugins/dns_common_lexicon.py�__init__ s zLexiconClient.__init__c C sh | � |� z| jjd||d� W nB tk rb } z$tjd|dd� t�d�|���W 5 d}~X Y nX dS )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��type�nameZcontentz'Encountered error adding TXT record: %sT��exc_infozError adding TXT record: {0}N) �_find_domain_idr Z create_recordr �logger�debugr �PluginError�format�r �domainZrecord_nameZrecord_content�er r r �add_txt_record s zLexiconClient.add_txt_recordc C s� z| � |� W n: tjk rH } ztjd|dd� W Y �dS d}~X Y nX z| jjd||d� W n2 tk r� } ztjd|dd� W 5 d}~X Y nX dS )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 Z delete_recordr r r r r �del_txt_record0 s �zLexiconClient.del_txt_recordc C s� t �|�}|D ]�}z4t| jd�r.|| jjd<