o
    6a                  
   @   sp   d Z ddlmZ ddlmZ G dd dZG dd deZG dd	 d	eZd
edededeeef fddZdS )z0Useful mixins for Challenge and Resource objects    )Any)Dictc                       sX   e Zd ZdZedefddZejdeddfddZded	e	ddf fd
dZ
  ZS )VersionedLEACMEMixinzEThis mixin stores the version of Let's Encrypt's endpoint being used.returnc                 C   s   t | ddS )z*Define the version of ACME protocol to use_le_acme_version   )getattrself r   -/usr/lib/python3/dist-packages/acme/mixins.pyle_acme_version   s   z$VersionedLEACMEMixin.le_acme_versionversionNc                 C   s   t | d| d S )Nr   )object__setattr__)r
   r   r   r   r   r      s   keyvaluec                    s,   |dkrt | || d S t || d S )Nr   )r   r   super)r
   r   r   	__class__r   r   r      s   z VersionedLEACMEMixin.__setattr__)__name__
__module____qualname____doc__propertyintr   setterstrr   r   __classcell__r   r   r   r   r      s    "r   c                       H   e Zd ZdZdeeef f fddZdeeef f fddZ  Z	S )ResourceMixinz
    This mixin generates a RFC8555 compliant JWS payload
    by removing the `resource` field if needed (eg. ACME v2 protocol).
    r   c                       t t ddS )/See josepy.JSONDeserializable.to_partial_json()to_partial_jsonresource_safe_jobj_compliancer   r	   r   r   r   r#   !      zResourceMixin.to_partial_jsonc                    r!   )8See josepy.JSONObjectWithFields.fields_to_partial_json()fields_to_partial_jsonr$   r%   r	   r   r   r   r)   &   r'   z$ResourceMixin.fields_to_partial_json
r   r   r   r   r   r   r   r#   r)   r   r   r   r   r   r           "r    c                       r   )	TypeMixinz
    This mixin allows generation of a RFC8555 compliant JWS payload
    by removing the `type` field if needed (eg. ACME v2 protocol).
    r   c                    r!   )r"   r#   typer%   r	   r   r   r   r#   1   r'   zTypeMixin.to_partial_jsonc                    r!   )r(   r)   r-   r%   r	   r   r   r   r)   6   r'   z TypeMixin.fields_to_partial_jsonr*   r   r   r   r   r,   ,   r+   r,   instancejobj_methoduncompliant_fieldr   c                 C   s>   t | |rt| | }| jdkr||d  |S td|)N   z Method {0}() is not implemented.)hasattrr   r   popAttributeErrorformat)r.   r/   r0   jobjr   r   r   r&   <   s   

r&   N)	r   typingr   r   r   r    r,   r   r&   r   r   r   r   <module>   s    

