a
    ݌xd<                     @   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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 )    N)OrderedDict)DocumentStructure)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 )NZgenerate_presigned_url)Zs3 )method_nameservice_namekwargsr   r   L/var/www/html/Ranjet/env/lib/python3.9/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 jj| _|| _|| _| jd u r.i | _| j jjj| _	d S N)
_client	__class____name___client_class_name_root_docs_path_shared_examplesmetaservice_modelr   _service_name)selfclientroot_docs_pathshared_examplesr   r   r   __init__'   s    
zClientDocumenter.__init__c                 C   s6   |  | | | |  }| || | | 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_client0   s
    

z ClientDocumenter.document_clientc                 C   s   t | j}| |S r   )r   r   _filter_client_methods)r   r(   r   r   r   r$   ;   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(   Zfiltered_methodsr   r+   includer   r   r   r*   ?   s    
z'ClientDocumenter._filter_client_methodsc                 K   s.   | j D ]"}|f i |}|d ur|  S qdS )NT)_CLIENT_METHODS_FILTERS)r   r   filterZfilter_includer   r   r   r-   K   s
    

z&ClientDocumenter._filter_client_methodc                 C   s   |j d d S )NZClientstyleZh2r   r'   r   r   r   r"   U   s    zClientDocumenter._add_titlec                 C   s   | d}t| jjj}|d|  |j  || jjjj	 | 
| |j  |j  |d |j  t|D ]}|j| j d|  q~d S )NZintroz A low-level client representing z These are the available methods:z/client/)add_new_sectionr   r   r   r   writer2   new_lineinclude_doc_stringdocumentation_add_client_creation_examplededentnew_paragraphwritelntoctreesortedtocitemr   )r   r'   r(   Zofficial_service_namer   r   r   r   r%   X   s$    







z"ClientDocumenter._add_client_introc                 C   s   |j j| j dd d S )Nz.Client
class_name)r2   start_sphinx_py_classr   r3   r   r   r   r#   q   s    
z%ClientDocumenter._add_class_signaturec                 C   s6   |j   |j   |dj| jd |j   d S )Nz+client = session.create_client('{service}'))Zservice)r2   start_codeblockr6   r5   formatr   end_codeblockr3   r   r   r   r9   v   s    

z-ClientDocumenter._add_client_creation_examplec                 C   sP   t |D ]B}t|dd}| ||||  tj| j| jd}||| qd S )Nhtmltargetr   )	r>   r   _add_client_methodospathjoinr   r   write_to_file)r   r(   r   Zmethod_doc_structureZclient_dir_pathr   r   r   r&      s    

z$ClientDocumenter._add_client_methodsc                 C   s   | d}|j| jd| j  |d|  || |j |d| j did}| |rp| ||| n| 	|| d S )N
breadcrumbz../../z / Client / 	qualifierz.Client.)context)
r4   r2   refr   r   r5   add_title_section_is_custom_method_add_custom_method_add_model_driven_method)r   r'   r   r+   breadcrumb_sectionZmethod_sectionr   r   r   rI      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   rS      s    z"ClientDocumenter._is_custom_methodc                 C   s   t ||| d S r   )r   )r   r'   r   r+   r   r   r   rT      s    z#ClientDocumenter._add_custom_methodc                 C   s\   | d}|j  |jd |j  |jD ]&}| j d|j }|jd|  q0d S )N
exceptionsZ
Exceptions.Client.exceptions.z:py:class:`%s`)r4   r2   r6   bolderror_shapesr   nameZli)r   r'   operation_modelZerror_sectionerrorrA   r   r   r   _add_method_exceptions_list   s    



z,ClientDocumenter._add_method_exceptions_listc           	      C   s   | j jj}| j jj| }||}d| }|jdd | }t|||| j jj|j	|d |j
rn| || | j|}|rt|||| d S )Nzresponse = client.%srO    )event_emitterZmethod_descriptionexample_prefix)r   r   r   rW   r]   rP   getr   eventsr8   r[   r_   r   r	   )	r   r'   r   r   operation_namer]   rb   Zfull_method_namer    r   r   r   rU      s*    


z)ClientDocumenter._add_model_driven_method)N)r   
__module____qualname__r   r/   r!   r)   r$   r*   r-   r"   r%   r#   r9   r&   rI   rS   rT   r_   rU   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ErrorZ	structurez1Normalized access to common exception attributes.ZCodestringz,An identifier specifying the exception type.)r\   	type_namer8   Messagez;A descriptive message explaining why the exception occured.)r\   rk   r8   membersc                 C   s*   || _ | j jj| _| j jjj| _|| _d S r   )	r   r   r   r   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_classesr3   r   r   r   document_exceptions   s    


z.ClientExceptionsDocumenter.document_exceptionsc                 C   s   |j d d S )NzClient Exceptionsr1   r3   r   r   r   r"     s    z%ClientExceptionsDocumenter._add_titlec                 C   s>   |j   |d |j jd| jd |d |j   d S )NzClient 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   r6   r5   Zexternal_link_USER_GUIDE_LINKr3   r   r   r   rn     s    

z(ClientExceptionsDocumenter._add_overviewc                 C   s   | j  d|j S )NrY   )r   r\   )r   shaper   r   r   _exception_class_name  s    z0ClientExceptionsDocumenter._exception_class_namec                 C   sx   | j jjj}|s2|j  |d |j  d S |j  |d |j  |D ]}|j	| j
 d|j  qTd S )Nz-This client has no modeled exception classes.z$The available client exceptions are:z/client/exceptions/)r   r   r   r[   r2   r6   r5   r<   r=   r?   r   r\   )r   r'   r[   rv   r   r   r   ro     s    





z/ClientExceptionsDocumenter._add_exceptions_listc                 C   sT   | j jjjD ]B}t|jdd}| || tj	| j
| jdd}|||j qd S )NrF   rG   r   rX   )r   r   r   r[   r   r\   _add_exception_classrJ   rK   rL   r   r   rM   )r   rv   Zexception_doc_structureZexception_dir_pathr   r   r   rp   '  s    z1ClientExceptionsDocumenter._add_exception_classesc                 C   s   | d}|j| jd| j  |d|j  ||j | |j}| |}|jj	|d | 
|| | || | || |j  d S )NrN   z	../../../z / Client / exceptions / r@   )r4   r2   rQ   r   r   r5   r\   rR   rw   rB   _add_top_level_documentation_add_exception_catch_example_add_response_attrZend_sphinx_py_class)r   r'   rv   rV   Zclass_sectionrA   r   r   r   rx   :  s    

z/ClientExceptionsDocumenter._add_exception_classc                 C   s*   |j r&|j  ||j  |j  d S r   )r8   r2   r6   r7   r   r'   rv   r   r   r   ry   I  s    
z7ClientExceptionsDocumenter._add_top_level_documentationc                 C   s   |j   |j d |j   |j   |d |j   |j   |d |j   |j   |d|j  |j   |j   |d |j   |j 	  d S )NZExampleztry:z...z!except client.exceptions.%s as e:zprint(e.response))
r2   r6   rZ   r;   rC   r5   indentr:   r\   rE   r|   r   r   r   rz   O  s     












z7ClientExceptionsDocumenter._add_exception_catch_examplec                 C   sF   | d}|jd | | | || | || |j  d S )Nresponse)r4   r2   Zstart_sphinx_py_attr_add_response_attr_description_add_response_example_add_response_paramsZend_sphinx_py_attr)r   r'   rv   Zresponse_sectionr   r   r   r{   a  s    

z-ClientExceptionsDocumenter._add_response_attrc                 C   s"   |j   |d |j   d S )NzThe 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   r6   r7   r3   r   r   r   r   i  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   re   ra   r.   )r4   r2   r6   rZ   r;   r   r   r   r   rd   Zdocument_example_GENERIC_ERROR_SHAPE)r   r'   rv   Zexample_section
documenterr   r   r   r   s  s    


z0ClientExceptionsDocumenter._add_response_examplec                 C   sX   | d}|j  |jd |j  t| jd | jjj	d}|j
||| jgd d S )NZ	Structurer   r   )r4   r2   r6   rZ   r;   r   r   r   r   rd   Zdocument_paramsr   )r   r'   rv   Zparams_sectionr   r   r   r   r     s    


z/ClientExceptionsDocumenter._add_response_paramsN)r   rf   rg   ru   r
   r   r   r!   rq   r"   rn   rw   ro   rp   rx   ry   rz   r{   r   r   r   r   r   r   r   rh      sL   
rh   )rJ   Zbotocore.compatr   Zbotocore.docs.bcdoc.restdocr   Zbotocore.docs.exampler   Zbotocore.docs.methodr   r   r   Zbotocore.docs.paramsr   Zbotocore.docs.sharedexampler	   Zbotocore.docs.utilsr
   r   r   r   rh   r   r   r   r   <module>   s    2