o
    }l~i<  ã                   @   s¸   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZmZ d dlmZ G dd„ deƒZG dd„ deƒZdS )é    N)Ú
xform_name)ÚDocumentStructure)Úget_official_service_name)ÚActionDocumenter)Údocument_attributeÚdocument_identifierÚdocument_reference)ÚBaseDocumenter)ÚCollectionDocumenter)ÚSubResourceDocumenter)Úadd_resource_type_overviewÚ!get_identifier_args_for_signatureÚget_identifier_descriptionÚ!get_identifier_values_for_example)ÚWaiterResourceDocumenterc                       s”   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Z‡  ZS )!ÚResourceDocumenterc                    s>   t ƒ  |¡ || _|| _| j ¡ | _| j| jkrd| _d S d S )Nzservice-resource)ÚsuperÚ__init__Ú_botocore_sessionÚ_root_docs_pathÚ_resource_nameÚlowerÚ_resource_sub_pathÚ_service_name)ÚselfÚresourceÚbotocore_sessionÚroot_docs_path©Ú	__class__© úZ/var/www/newdalilibackend/backend/venv/lib/python3.10/site-packages/boto3/docs/resource.pyr   &   s   
ÿzResourceDocumenter.__init__c                 C   sh   |   |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  |¡ |  	|¡ d S )N)
Ú
_add_titleÚ_add_resource_noteÚ
_add_introÚ_add_identifiersÚ_add_attributesÚ_add_referencesÚ_add_actionsÚ_add_sub_resourcesÚ_add_collectionsÚ_add_waiters©r   Úsectionr    r    r!   Údocument_resource.   s   








z$ResourceDocumenter.document_resourcec                 C   s   |  d¡}|j | j¡ d S )NÚtitle)Úadd_new_sectionÚstyleÚh2r   ©r   r-   Útitle_sectionr    r    r!   r"   :   s   
zResourceDocumenter._add_titlec           
      C   s¬   g }| j jr| j jD ]}| |j¡ q
t|ƒ}| d¡}|jj| j› d|› dd | d¡}|  	|¡ | d¡}|  
||¡ | d¡}|  ||¡ | d¡}	|	j ¡  d S )	NÚstart_classú(ú))Ú
class_nameÚdescriptionÚexampleÚparamsÚ	end_class)Ú_resource_modelÚidentifiersÚappendÚnamer   r0   r1   Ústart_sphinx_py_classr8   Ú_add_descriptionÚ_add_exampleÚ_add_params_descriptionÚend_sphinx_py_class)
r   r-   Úidentifier_namesÚ
identifierÚ
class_argsr5   Údescription_sectionÚexample_sectionÚparam_sectionr<   r    r    r!   r$   >   s"   
ÿ




zResourceDocumenter._add_introc                 C   s"   t | jƒ}| d || j¡¡ d S )Nz A resource representing an {} {})r   Ú_service_modelÚwriteÚformatr   ©r   r-   Úofficial_service_namer    r    r!   rB   [   s   
ÿÿz#ResourceDocumenter._add_descriptionc                 C   sˆ   |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  | d | j| j¡¡ |j  ¡  t|ƒ}| d t| jƒ| j| j|¡¡ |j  	¡  d S )Núimport boto3z{} = boto3.resource('{}')z{} = {}.{}({}))
r1   Ústart_codeblockÚnew_linerM   rN   r   r   r   r   Úend_codeblock)r   r-   rF   Úexample_valuesr    r    r!   rC   c   s*   




ÿÿ
üÿzResourceDocumenter._add_examplec                 C   sV   |D ]&}t | j|ƒ}| d|› d¡ |j ¡  | d|› d|› ¡ |j ¡  qd S )Nz:type z: stringz:param z: )r   r   rM   r1   rS   )r   r-   rF   Úidentifier_namer9   r    r    r!   rD   z   s   ÿ
ùz*ResourceDocumenter._add_params_descriptionc                 C   sR   |j  ¡  | d|› d¡ |j  ¡  |j  ¡  | j| D ]	}|j  |› ¡ qd S )Nz#These are the resource's available ú:)r1   rS   rM   ÚtoctreeÚ
member_mapÚtocitem)r   r-   Úresource_member_typeÚmemberr    r    r!   Ú_add_overview_of_member_type„   s   

ÿ

ÿz/ResourceDocumenter._add_overview_of_member_typec           	      C   s   | j jjj}| d¡}g }|r|| jd< t|dddd |D ]U}| |j¡ t	|jdd}| d¡}|j
 | jd	¡ | d
|j› ¡ | |j¡ |j|jd| j› did}t|| j|d tj | j| j› | j› ¡}| ||j¡ q|r~|  |d¡ d S d S )Nr>   ÚIdentifierszYIdentifiers are properties of a resource that are set upon instantiation of the resource.Úidentifiers_attributes_intro©r-   Úresource_typer9   Ú
intro_linkÚhtml©ÚtargetÚ
breadcrumbÚindexz / Identifier / Ú	qualifierÚ.©Úcontext)r-   Úresource_nameÚidentifier_model)Ú	_resourceÚmetaÚresource_modelr>   r0   rY   r   r?   r@   r   r1   ÚrefÚ_resource_class_namerM   Úadd_title_sectionr8   r   r   ÚosÚpathÚjoinr   r   r   Úwrite_to_filer]   )	r   r-   r>   Úmember_listrG   Úidentifier_docÚbreadcrumb_sectionÚidentifier_sectionÚidentifiers_dir_pathr    r    r!   r%   Ž   sH   

ù	
þýýÿz#ResourceDocumenter._add_identifiersc              	   C   sJ  | j jjjj}i }| j jjjr | | j jjj¡}| j jj |¡}| d¡}g }|r6t	|dddd || j
d< t|ƒD ]^}|| \}}| |¡ t|dd}	|	 d¡}
|
j | jd	¡ |
 d
|› ¡ |	 |¡ |	j|d| j› did}t|| j| j|| j jjjj|d tj | j| j› | j› ¡}|	 ||¡ q:|r£|  |d¡ d S d S )NÚ
attributesÚ
Attributesz”Attributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the :py:meth:`load` method.r_   r`   rc   rd   rf   rg   z / Attribute / rh   ri   rj   )r-   Úservice_namerl   Ú	attr_nameÚevent_emitterÚ
attr_model)rn   ro   ÚclientÚservice_modelrp   ÚshapeÚ	shape_forÚget_attributesr0   r   rY   Úsortedr?   r   r1   rq   rr   rM   rs   r8   r   r   r   Úeventsrt   ru   rv   r   r   rw   r]   )r   r-   r„   r}   r…   Úattribute_listr€   Ú_Ú
attr_shapeÚattribute_docrz   Úattribute_sectionÚattributes_dir_pathr    r    r!   r&   º   s`   
ÿ
ÿ
÷



þú
ýÿz"ResourceDocumenter._add_attributesc           	      C   s  |  d¡}| jjjj}g }|r"t|dddd || jd< |  |d¡ |D ]S}| |j	¡ t
|j	dd}|  d¡}|j | jd	¡ | d
|j	› ¡ | |j	¡ |j |j	d| j› did}t||d tj | j| j› | j› ¡}| ||j	¡ q$|r‚|  |d¡ d S d S )NÚ
referencesÚ
ReferenceszNReferences are related resource instances that have a belongs-to relationship.Úreferences_intror`   rc   rd   rf   rg   z / Reference / rh   ri   rj   )r-   Úreference_model)r0   rn   ro   rp   r   r   rY   r]   r?   r@   r   r1   rq   rr   rM   rs   r8   r   rt   ru   rv   r   r   r   rw   )	r   r-   r   Úreference_listÚ	referenceÚreference_docrz   Úreference_sectionÚreferences_dir_pathr    r    r!   r'   ó   sH   
ù
	
þþýÿz"ResourceDocumenter._add_referencesc                 C   óN   |  d¡}| jjjj}|r%t| j| jƒ}| j|_| |¡ |  	|d¡ d S d S )NÚactions)
r0   rn   ro   rp   rš   r   r   rY   Údocument_actionsr]   )r   r-   rš   Ú
documenterr    r    r!   r(     s   

üzResourceDocumenter._add_actionsc                 C   r™   )Nzsub-resources)
r0   rn   ro   rp   Úsubresourcesr   r   rY   Údocument_sub_resourcesr]   )r   r-   Úsub_resourcesrœ   r    r    r!   r)   '  ó   
ÿ
úz%ResourceDocumenter._add_sub_resourcesc                 C   r™   )NÚcollections)
r0   rn   ro   rp   r¡   r
   r   rY   Údocument_collectionsr]   )r   r-   r¡   rœ   r    r    r!   r*   2  r    z#ResourceDocumenter._add_collectionsc                 C   s^   |  d¡}| jjjj}|r-| j | j¡}t| j|| j	ƒ}| j
|_
| |¡ |  |d¡ d S d S )NÚwaiters)r0   rn   ro   rp   r£   r   Úget_waiter_modelr   r   r   rY   Údocument_resource_waitersr]   )r   r-   r£   Úservice_waiter_modelrœ   r    r    r!   r+   =  s   
ÿ
ÿ
÷zResourceDocumenter._add_waitersc                 C   s,   |  d¡}|j ¡  | d¡ |j ¡  d S )Nzfeature-freezez¢Before using anything on this page, please refer to the resources :doc:`user guide <../../../../guide/resources>` for the most recent guidance on using resources.)r0   r1   Ú
start_noterM   Úend_noter,   r    r    r!   r#   K  s   

ÿz%ResourceDocumenter._add_resource_note)Ú__name__Ú
__module__Ú__qualname__r   r.   r"   r$   rB   rC   rD   r]   r%   r&   r'   r(   r)   r*   r+   r#   Ú__classcell__r    r    r   r!   r   %   s"    

,9+	r   c                   @   s0   e Zd Zedd„ ƒZdd„ Zdd„ Zdd„ Zd	S )
ÚServiceResourceDocumenterc                 C   s   | j › dS )Nz.ServiceResource)Ú_service_docs_name)r   r    r    r!   r8   W  s   z$ServiceResourceDocumenter.class_namec                 C   s   |  d¡}|j d¡ d S )Nr/   zService Resource)r0   r1   r2   r3   r    r    r!   r"   [  s   
z$ServiceResourceDocumenter._add_titlec                 C   s   t | jƒ}| d|› ¡ d S )NzA resource representing )r   rL   rM   rO   r    r    r!   rB   _  s   
z*ServiceResourceDocumenter._add_descriptionc                 C   sZ   |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  | | j› d| j› d¡ |j  ¡  d S )NrQ   z = boto3.resource('z'))r1   rR   rS   rM   r   rT   )r   r-   rF   r    r    r!   rC   c  s   




ÿz&ServiceResourceDocumenter._add_exampleN)r©   rª   r«   Úpropertyr8   r"   rB   rC   r    r    r    r!   r­   V  s    
r­   )rt   Úbotocorer   Úbotocore.docs.bcdoc.restdocr   Úbotocore.docs.utilsr   Úboto3.docs.actionr   Úboto3.docs.attrr   r   r   Úboto3.docs.baser	   Úboto3.docs.collectionr
   Úboto3.docs.subresourcer   Úboto3.docs.utilsr   r   r   r   Úboto3.docs.waiterr   r   r­   r    r    r    r!   Ú<module>   s     3