o
    ˷e3                     @   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/ideatree/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 )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   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 )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   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    