o
    ÚtBh«3  ã                   @   s|   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mZ dd„ ZG d	d
„ d
ƒZG dd„ dƒZdS )é    )ÚOrderedDict)ÚResponseExampleDocumenter)Údocument_custom_methodÚdocument_model_driven_methodÚget_instance_public_methods)ÚResponseParamsDocumenter)Údocument_shared_examples)ÚDocumentedShapeÚget_official_service_namec                 K   s   | dkrd S |dv S )NÚgenerate_presigned_url)Ús3© )Úmethod_nameÚservice_nameÚkwargsr   r   úk/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/botocore/docs/client.pyÚ!_allowlist_generate_presigned_url   s   r   c                   @   sŒ   e Zd ZegZd 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S )!ÚClientDocumenterNc                 C   s.   || _ || _| jd u ri | _| j jjj| _d S ©N)Ú_clientÚ_shared_examplesÚmetaÚservice_modelr   Ú_service_name)ÚselfÚclientÚshared_examplesr   r   r   Ú__init__$   s
   
zClientDocumenter.__init__c                 C   s8   |   |¡ |  |¡ |  ¡ }|  ||¡ |  ||¡ dS )z]Documents a client and its methods

        :param section: The section to write to.
        N)Ú
_add_titleÚ_add_class_signatureÚ_get_client_methodsÚ_add_client_introÚ_add_client_methods)r   ÚsectionÚclient_methodsr   r   r   Údocument_client+   s
   

z ClientDocumenter.document_clientc                 C   s   t | jƒ}|  |¡S r   )r   r   Ú_filter_client_methods)r   r$   r   r   r   r    6   s   

z$ClientDocumenter._get_client_methodsc                 C   s8   i }|  ¡ D ]\}}| j||| jd}|r|||< q|S )N)Úmethodr   r   )ÚitemsÚ_filter_client_methodr   )r   r$   Úfiltered_methodsr   r'   Úincluder   r   r   r&   :   s   ý€z'ClientDocumenter._filter_client_methodsc                 K   s.   | j D ]}|di |¤Ž}|d ur|  S qdS )NTr   )Ú_CLIENT_METHODS_FILTERS)r   r   ÚfilterÚfilter_includer   r   r   r)   F   s   
ÿz&ClientDocumenter._filter_client_methodc                 C   ó   |j  d¡ d S )NÚClient©ÚstyleÚh2©r   r#   r   r   r   r   P   ó   zClientDocumenter._add_titlec                 C   s¢   |  d¡}t| jjjƒ}| d|› ¡ |j ¡  | | jjjj	¡ |  
|¡ |j ¡  | d¡ |j ¡  | jjj}t|ƒD ]}|j d|› d|› d¡ q?d S )NÚintroz A low-level client representing z These are the available methods:z:py:meth:`~z.Client.ú`)Úadd_new_sectionr
   r   r   r   Úwriter2   Únew_lineÚinclude_doc_stringÚdocumentationÚ_add_client_creation_exampleÚ	__class__Ú__name__ÚsortedÚli)r   r#   r$   Úofficial_service_nameÚ
class_namer   r   r   r   r!   S   s&   
ÿÿ

ÿ




ÿz"ClientDocumenter._add_client_introc                 C   s   |j j| jjj› dd d S )Nz.Client©rC   )r2   Ústart_sphinx_py_classr   r>   r?   r4   r   r   r   r   l   s   
ÿz%ClientDocumenter._add_class_signaturec                 C   s6   |j  ¡  |j  ¡  | dj| jd¡ |j  ¡  d S )Nz+client = session.create_client('{service}'))Úservice)r2   Ústart_codeblockr:   r9   Úformatr   Úend_codeblockr4   r   r   r   r=   q   s   

ÿÿz-ClientDocumenter._add_client_creation_examplec                 C   s.   |  d¡}t|ƒD ]}|  |||| ¡ q	d S )NÚmethods)r8   r@   Ú_add_client_method)r   r#   r$   r   r   r   r   r"   {   s   

ÿÿz$ClientDocumenter._add_client_methodsc                 C   s6   |  |¡}|  |¡r|  |||¡ d S |  ||¡ d S r   )r8   Ú_is_custom_methodÚ_add_custom_methodÚ_add_model_driven_method©r   r#   r   r'   r   r   r   rK   ‚   s   

z#ClientDocumenter._add_client_methodc                 C   s   || j jjvS r   )r   r   Úmethod_to_api_mapping)r   r   r   r   r   rL   ‰   s   z"ClientDocumenter._is_custom_methodc                 C   s   t |||ƒ d S r   )r   rO   r   r   r   rM   Œ   r5   z#ClientDocumenter._add_custom_methodc                 C   sd   |  d¡}|j ¡  |j d¡ |j ¡  | jjj}|jD ]}|› d|j› }|j 	d| ¡ qd S )NÚ
exceptionsÚ
Exceptionsú.Client.exceptions.ú:py:class:`%s`)
r8   r2   r:   Úboldr   r>   r?   Úerror_shapesÚnamerA   )r   r#   Úoperation_modelÚerror_sectionÚclient_nameÚerrorrC   r   r   r   Ú_add_method_exceptions_list   s   




þz,ClientDocumenter._add_method_exceptions_listc                 C   s~   | j jj}| j jj| }| |¡}d| }t|||| j jj|j|d |jr,|  	||¡ | j
 |¡}|r=t||||ƒ d S d S )Nzresponse = client.%s)Úevent_emitterÚmethod_descriptionÚexample_prefix)r   r   r   rP   rX   r   Úeventsr<   rV   r\   r   Úgetr   )r   r#   r   r   Úoperation_namerX   r_   r   r   r   r   rN   ™   s(   

ú
ÿÿz)ClientDocumenter._add_model_driven_methodr   )r?   Ú
__module__Ú__qualname__r   r,   r   r%   r    r&   r)   r   r!   r   r=   r"   rK   rL   rM   r\   rN   r   r   r   r   r      s$    ÿ



r   c                   @   s´   e Zd ZdZedddededdddfd	ed	dd
dfgƒ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(S ))ÚClientExceptionsDocumenterzQhttps://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.htmlÚErrorÚ	structurez1Normalized access to common exception attributes.ÚCodeÚstringz,An identifier specifying the exception type.)rW   Ú	type_namer<   ÚMessagez;A descriptive message explaining why the exception occured.)rW   rj   r<   Úmembersc                 C   s   || _ | j jjj| _d S r   )r   r   r   r   r   )r   r   r   r   r   r   Ø   s   z#ClientExceptionsDocumenter.__init__c                 C   s,   |   |¡ |  |¡ |  |¡ |  |¡ d S r   )r   Ú_add_overviewÚ_add_exceptions_listÚ_add_exception_classesr4   r   r   r   Údocument_exceptionsÜ   s   


z.ClientExceptionsDocumenter.document_exceptionsc                 C   r/   )NzClient Exceptionsr1   r4   r   r   r   r   â   r5   z%ClientExceptionsDocumenter._add_titlec                 C   s>   |j  ¡  | d¡ |j jd| jd | d¡ |j  ¡  d S )NzÂClient exceptions are available on a client instance via the ``exceptions`` property. For more detailed instructions and examples on the exact usage of client exceptions, see the error handling z
user guide)ÚtitleÚlinkÚ.)r2   r:   r9   Úexternal_linkÚ_USER_GUIDE_LINKr4   r   r   r   rm   å   s   
ÿþ
z(ClientExceptionsDocumenter._add_overviewc                 C   s   | j jj}|› d|j› S )NrS   )r   r>   r?   rW   )r   ÚshapeÚcls_namer   r   r   Ú_exception_class_nameô   s   
z0ClientExceptionsDocumenter._exception_class_namec                 C   sx   | j jjj}|s|j ¡  | d¡ |j ¡  d S |j ¡  | d¡ |j ¡  |D ]}|  |¡}|j d| ¡ q*d S )Nz-This client has no modeled exception classes.z$The available client exceptions are:rT   )	r   r   r   rV   r2   r:   r9   rx   rA   )r   r#   rV   rv   rC   r   r   r   rn   ø   s   






þz/ClientExceptionsDocumenter._add_exceptions_listc                 C   s"   | j jjjD ]}|  ||¡ qd S r   )r   r   r   rV   Ú_add_exception_class©r   r#   rv   r   r   r   ro     s   ÿz1ClientExceptionsDocumenter._add_exception_classesc                 C   sV   |  |j¡}|  |¡}|jj|d |  ||¡ |  ||¡ |  ||¡ |j ¡  d S )NrD   )	r8   rW   rx   r2   rE   Ú_add_top_level_documentationÚ_add_exception_catch_exampleÚ_add_response_attrÚend_sphinx_py_class)r   r#   rv   Úclass_sectionrC   r   r   r   ry   
  s   
z/ClientExceptionsDocumenter._add_exception_classc                 C   s.   |j r|j ¡  | |j ¡ |j ¡  d S d S r   )r<   r2   r:   r;   rz   r   r   r   r{     s
   
ýz7ClientExceptionsDocumenter._add_top_level_documentationc                 C   s¢   |j  ¡  |j  d¡ |j  ¡  | d¡ |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  | d|j ¡ |j  ¡  |j  ¡  | d¡ |j  ¡  |j  ¡  d S )NÚExampleztry:z...z!except client.exceptions.%s as e:zprint(e.response))	r2   r:   rU   rG   r9   ÚindentÚdedentrW   rI   rz   r   r   r   r|     s   











z7ClientExceptionsDocumenter._add_exception_catch_examplec                 C   sF   |  d¡}|j d¡ |  |¡ |  ||¡ |  ||¡ |j ¡  d S )NÚresponse)r8   r2   Ústart_sphinx_py_attrÚ_add_response_attr_descriptionÚ_add_response_exampleÚ_add_response_paramsÚend_sphinx_py_attr)r   r#   rv   Úresponse_sectionr   r   r   r}   *  s   

z-ClientExceptionsDocumenter._add_response_attrc                 C   s"   |j  ¡  | d¡ |j  ¡  d S )NzÈThe parsed error response. All exceptions have a top level ``Error`` key that provides normalized access to common exception atrributes. All other keys are specific to this service or exception class.)r2   r:   r;   r4   r   r   r   r…   2  s
   
ÿz9ClientExceptionsDocumenter._add_response_attr_descriptionc                 C   sX   |  d¡}|j ¡  |j d¡ |j ¡  t| jd | jjj	d}|j
||| jgd d S )NÚsyntaxÚSyntax©r   rb   r]   ©r+   )r8   r2   r:   rU   Únew_paragraphr   r   r   r   r`   Údocument_exampleÚ_GENERIC_ERROR_SHAPE)r   r#   rv   Úexample_sectionÚ
documenterr   r   r   r†   <  ó   


ý
ýz0ClientExceptionsDocumenter._add_response_examplec                 C   sX   |  d¡}|j ¡  |j d¡ |j ¡  t| jd | jjj	d}|j
||| jgd d S )NÚ	StructurerŒ   r   )r8   r2   r:   rU   rŽ   r   r   r   r   r`   Údocument_paramsr   )r   r#   rv   Úparams_sectionr’   r   r   r   r‡   L  r“   z/ClientExceptionsDocumenter._add_response_paramsN)r?   rc   rd   ru   r	   r   r   r   rp   r   rm   rx   rn   ro   ry   r{   r|   r}   r…   r†   r‡   r   r   r   r   re   ´   sN    ÿüþüþõÿü	
re   N)Úbotocore.compatr   Úbotocore.docs.exampler   Úbotocore.docs.methodr   r   r   Úbotocore.docs.paramsr   Úbotocore.docs.sharedexampler   Úbotocore.docs.utilsr	   r
   r   r   re   r   r   r   r   Ú<module>   s    