
    PeC                         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mZ d
 Z G d d      Z G d d      Z G d d      Zy)    N)
xform_name)OrderedDict)DocumentStructure)ResponseExampleDocumenter)document_custom_methoddocument_model_driven_methodget_instance_public_methods)ResponseParamsDocumenter)document_shared_examples)DocumentedShapeget_official_service_namec                     | dk7  ry |dv S )Ngenerate_presigned_url)s3 )method_nameservice_namekwargss      6/usr/lib/python3/dist-packages/botocore/docs/client.py!_allowlist_generate_presigned_urlr      s    ..6!!    c                   n    e Zd ZegZddZd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zy)ClientDocumenterNc                     || _         | j                   j                  j                  | _        || _        || _        | j
                  i | _        | j                   j                  j                  j                  | _	        y N)
_client	__class____name___client_class_name_root_docs_path_shared_examplesmetaservice_modelr   _service_name)selfclientroot_docs_pathshared_exampless       r   __init__zClientDocumenter.__init__(   sc    "&,,"8"8"A"A- /  ($&D!!\\..<<IIr   c                     | j                  |       | j                  |       | j                         }| j                  ||       | j	                  |       y)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_methodss      r   document_clientz ClientDocumenter.document_client1   sJ    
 	 !!'*113w7  0r   c                 N    t        | j                        }| j                  |      S r   )r	   r   _filter_client_methods)r%   r1   s     r   r-   z$ClientDocumenter._get_client_methods<   s!    4T\\B**>::r   c                     i }|j                         D ]+  \  }}| j                  ||| j                        }|s'|||<   - |S )N)methodr   r   )items_filter_client_methodr$   )r%   r1   filtered_methodsr   r6   includes         r   r4   z'ClientDocumenter._filter_client_methods@   sa    #1#7#7#9 	7K00'!// 1 G
 06 -	7  r   c                 B    | j                   D ]  } |di |}||c S  y)NTr   )_CLIENT_METHODS_FILTERS)r%   r   filterfilter_includes       r   r8   z&ClientDocumenter._filter_client_methodL   s5    22 	&F#-f-N)%%		& r   c                 :    |j                   j                  d       y )NClientstyleh2r%   r0   s     r   r+   zClientDocumenter._add_titleV   s    "r   c                    |j                  d      }t        | j                  j                  j                        }|j                  d|        |j                  j                          |j                  | j                  j                  j                  j                         | j                  |       |j                  j                          |j                  j                          |j                  d       |j                  j                          t        |      D ],  }|j                  j!                  | j"                   d|        . y )Nintroz A low-level client representing z These are the available methods:z/client/)add_new_sectionr   r   r"   r#   writerB   new_lineinclude_doc_stringdocumentation_add_client_creation_examplededentnew_paragraphwritelntoctreesortedtocitemr$   )r%   r0   r1   official_service_namer   s        r   r.   z"ClientDocumenter._add_client_introY   s   ))'2 9LL++!
 	./D.EF	
 	 ""LL++99	

 	))'2 	##%:;!.1 	PKMM!!T%7%7$8"NO	Pr   c                 V    |j                   j                  | j                   d       y )Nz.Client
class_name)rB   start_sphinx_py_classr   rD   s     r   r,   z%ClientDocumenter._add_class_signaturer   s*    ++112': 	, 	
r   c                     |j                   j                          |j                   j                          |j                  dj	                  | j
                               |j                   j                          y )Nz+client = session.create_client('{service}'))service)rB   start_codeblockrI   rH   formatr$   end_codeblockrD   s     r   rL   z-ClientDocumenter._add_client_creation_examplew   s]    %%' ;BB** C 	

 	##%r   c                     t        |      D ]l  }t        |d      }| j                  ||||          t        j                  j                  | j                  | j                  d      }|j                  ||       n y )Nhtmltargetr&   )	rQ   r   _add_client_methodospathjoinr    r$   write_to_file)r%   r1   r   method_doc_structureclient_dir_paths        r   r/   z$ClientDocumenter._add_client_methods   s}    !.1 	MK#4F$  ##$k>+3N
 !ggll$$d&8&8(O !..L	Mr   c                    |j                  d      }|j                  j                  | j                  d| j                          |j                  d|        |j                  |       |j                  |d| j                   di      }| j                  |      r| j                  |||       y | j                  ||       y )N
breadcrumbz../../z / Client / 	qualifierz.Client.)context)
rG   rB   refr   r$   rH   add_title_section_is_custom_method_add_custom_method_add_model_driven_method)r%   r0   r   r6   breadcrumb_sectionmethod_sections         r   ra   z#ClientDocumenter._add_client_method   s    $44\B  $$##vd.@.@-A%B	
 	  <}!=>!!+. 00 T%<%<$=X"FG 1 
 !!+.## )).+Fr   c                 F    || j                   j                  j                  vS r   )r   r"   method_to_api_mapping)r%   r   s     r   rn   z"ClientDocumenter._is_custom_method   s    $,,"3"3"I"IIIr   c                     t        |||       y r   )r   )r%   r0   r   r6   s       r   ro   z#ClientDocumenter._add_custom_method   s    wV<r   c                 X   |j                  d      }|j                  j                          |j                  j                  d       |j                  j                          |j                  D ];  }| j
                   d|j                   }|j                  j                  d|z         = y )N
exceptions
Exceptions.Client.exceptions.z:py:class:`%s`)rG   rB   rI   bolderror_shapesr   nameli)r%   r0   operation_modelerror_sectionerrorrV   s         r   _add_method_exceptions_listz,ClientDocumenter._add_method_exceptions_list   s    //=$$&  .$$&$11 	BE**++>uzzlK  ""#3j#@A		Br   c                    | j                   j                  j                  }| j                   j                  j                  |   }|j	                  |      }d|z  }|j
                  j                  dd       | }t        |||| j                   j                  j                  |j                  |       |j                  r| j                  ||       | j                  j                  |      }|rt        ||||       y y )Nzresponse = client.%srj    )event_emittermethod_descriptionexample_prefix)r   r"   r#   rt   r~   rk   getr   eventsrK   r{   r   r!   r   )	r%   r0   r   r#   operation_namer~   r   full_method_namer(   s	            r   rp   z)ClientDocumenter._add_model_driven_method   s    ))77**@@M'77G/+="";34[MB 	 	%,,++22.<<)	
 '',,WoF //33NC$./ r   r   )r   
__module____qualname__r   r<   r)   r2   r-   r4   r8   r+   r.   r,   rL   r/   ra   rn   ro   r   rp   r   r   r   r   r   #   s^    )J	1;
 #P2

&M G(J=	Br   r   c                       e Zd ZdZ eddd ed eddd      fd	 ed	dd
      fg            Zd Zd Zd Z	d Z
d Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)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.)r|   	type_namerK   Messagez;A descriptive message explaining why the exception occured.)r|   r   rK   membersc                     || _         | j                   j                  j                  | _        | j                   j                  j
                  j                  | _        || _        y r   )	r   r   r   r   r"   r#   r   r$   r    )r%   r&   r'   s      r   r)   z#ClientExceptionsDocumenter.__init__   sG    "&,,"8"8"A"A!\\..<<II-r   c                     | j                  |       | j                  |       | j                  |       | j                          y r   )r+   _add_overview_add_exceptions_list_add_exception_classesrD   s     r   document_exceptionsz.ClientExceptionsDocumenter.document_exceptions   s6     7#!!'*##%r   c                 :    |j                   j                  d       y )NzClient ExceptionsrA   rD   s     r   r+   z%ClientExceptionsDocumenter._add_title  s    ,-r   c                     |j                   j                          |j                  d       |j                   j                  d| j                         |j                  d       |j                   j                          y )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.)rB   rI   rH   external_link_USER_GUIDE_LINKrD   s     r   r   z(ClientExceptionsDocumenter._add_overview  sf     	
 	##&& 	$ 	
 	c r   c                 8    | j                    d|j                   S )Nry   )r   r|   )r%   shapes     r   _exception_class_namez0ClientExceptionsDocumenter._exception_class_name  s    ))**=ejj\JJr   c                    | j                   j                  j                  j                  }|sF|j                  j                          |j                  d       |j                  j                          y |j                  j                          |j                  d       |j                  j                          |D ]6  }|j                  j                  | j                   d|j                          8 y )Nz-This client has no modeled exception classes.z$The available client exceptions are:z/client/exceptions/)r   r"   r#   r{   rB   rI   rH   rO   rP   rR   r$   r|   )r%   r0   r{   r   s       r   r   z/ClientExceptionsDocumenter._add_exceptions_list  s    ||((66CCMM""$MMIJMM""$ >?! 	EMM!!%%&&9%**F	r   c                 X   | j                   j                  j                  j                  D ]}  }t	        |j
                  d      }| j                  ||       t        j                  j                  | j                  | j                  dd      }|j                  ||j
                          y )Nr^   r_   r&   rw   )r   r"   r#   r{   r   r|   _add_exception_classrb   rc   rd   r    r$   re   )r%   r   exception_doc_structureexception_dir_paths       r   r   z1ClientExceptionsDocumenter._add_exception_classes(  s    \\&&44AA 	E&7

6'# %%&=uE "$$$""	" $11"EJJ	r   c                 .   |j                  d      }|j                  j                  | j                  d| j                          |j                  d|j                          |j                  |j                         |j                  |j                        }| j                  |      }|j                  j                  |       | j                  ||       | j                  ||       | j                  ||       |j                  j                          y )Nri   z	../../../z / Client / exceptions / rU   )rG   rB   rl   r   r$   rH   r|   rm   r   rW   _add_top_level_documentation_add_exception_catch_example_add_response_attrend_sphinx_py_class)r%   r0   r   rq   class_sectionrV   s         r   r   z/ClientExceptionsDocumenter._add_exception_class;  s    $44\B  $$##y1C1C0D%E	
 	  #<UZZL!IJ!!%**-//

;//6
11Z1H))-?))-?u5//1r   c                     |j                   rP|j                  j                          |j                  |j                          |j                  j                          y y r   )rK   rB   rI   rJ   r%   r0   r   s      r   r   z7ClientExceptionsDocumenter._add_top_level_documentationJ  sD    MM""$&&u':':;MM""$ r   c                    |j                   j                          |j                   j                  d       |j                   j                          |j                   j	                          |j                  d       |j                   j                          |j                   j                          |j                  d       |j                   j                          |j                   j                          |j                  d|j                  z         |j                   j                          |j                   j                          |j                  d       |j                   j                          |j                   j                          y )NExampleztry:z...z!except client.exceptions.%s as e:zprint(e.response))
rB   rI   rz   rN   rZ   rH   indentrM   r|   r\   r   s      r   r   z7ClientExceptionsDocumenter._add_exception_catch_exampleP  s     9%##%%%'f e 9EJJFG )*##%r   c                     |j                  d      }|j                  j                  d       | j                  |       | j	                  ||       | j                  ||       |j                  j                          y )Nresponse)rG   rB   start_sphinx_py_attr_add_response_attr_description_add_response_example_add_response_paramsend_sphinx_py_attr)r%   r0   r   response_sections       r   r   z-ClientExceptionsDocumenter._add_response_attrb  sj    "22:>33J?++,<=""#3U;!!"2E:113r   c                     |j                   j                          |j                  d       |j                   j                          y )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.)rB   rI   rJ   rD   s     r   r   z9ClientExceptionsDocumenter._add_response_attr_descriptionj  s7     ""*	
 	 r   c                 n   |j                  d      }|j                  j                          |j                  j                  d       |j                  j	                          t        | j                  d | j                  j                  j                        }|j                  ||| j                  g       y )NsyntaxSyntaxr   r   r   r:   )rG   rB   rI   rz   rN   r   r$   r   r"   r   document_example_GENERIC_ERROR_SHAPE)r%   r0   r   example_section
documenters        r   r   z0ClientExceptionsDocumenter._add_response_examplet  s    !11(;&&(""8,++-.++,,++22


 	##../ 	$ 	
r   c                 n   |j                  d      }|j                  j                          |j                  j                  d       |j                  j	                          t        | j                  d | j                  j                  j                        }|j                  ||| j                  g       y )N	Structurer   r   )rG   rB   rI   rz   rN   r
   r$   r   r"   r   document_paramsr   )r%   r0   r   params_sectionr   s        r   r   z/ClientExceptionsDocumenter._add_response_params  s     00=%%'!!+.**,-++,,++22


 	""../ 	# 	
r   N)r   r   r   r   r   r   r   r)   r   r+   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    	@  +J ##"*J		 #&"*'	

	>.&.!K&2%&$4!
 
r   r   c                   8    e Zd ZdZdddZd Zd Zd Zd Zd	 Z	y
)ClientContextParamsDocumenterzPhttps://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html)
AccelerateDisableMultiRegionAccessPointsForcePathStyleUseArnRegion)r   )r   	s3controlc                      || _         || _        y r   )r$   _context_params)r%   r   context_paramss      r   r)   z&ClientContextParamsDocumenter.__init__  s    )-r   c                 j    | j                  |       | j                  |       | j                  |       y r   )r+   r   _add_context_params_listrD   s     r   document_context_paramsz5ClientContextParamsDocumenter.document_context_params  s*     7#%%g.r   c                 :    |j                   j                  d       y )NzClient Context ParametersrA   rD   s     r   r+   z(ClientContextParamsDocumenter._add_title  s    45r   c                     |j                   j                          |j                  d       |j                   j                  d| j                         |j                  d       |j                   j                          y )NzClient context parameters are configurable on a client instance via the ``client_context_params`` parameter in the ``Config`` object. For more detailed instructions and examples on the exact usage of context params see the zconfiguration guider   r   )rB   rI   rH   r   _CONFIG_GUIDE_LINKrD   s     r   r   z+ClientContextParamsDocumenter._add_overview  sf     <	
 	##'(( 	$ 	
 	c r   c           	      f   |j                   j                          d| j                   d}|j                  d| d       | j                  D ]c  }|j                   j                          dt        |j                         d}|j                  d| d|j                   d|j                          e y )Nz``zThe available z client context params are:z* z (z) - )
rB   rI   r$   rO   r   r   r|   rH   typerK   )r%   r0   snparamr|   s        r   r   z6ClientContextParamsDocumenter._add_context_params_list  s     $$$%R(.,GHI)) 	NEMM""$
5::./r2DMMBtfBuzzl$u7J7J6KLM	Nr   N)
r   r   r   r   OMITTED_CONTEXT_PARAMSr)   r   r+   r   r   r   r   r   r   r     s8    	? 
 './
6!Nr   r   )rb   botocorer   botocore.compatr   botocore.docs.bcdoc.restdocr   botocore.docs.exampler   botocore.docs.methodr   r   r	   botocore.docs.paramsr
   botocore.docs.sharedexampler   botocore.docs.utilsr   r   r   r   r   r   r   r   r   <module>r      sV    
  ' 9 ; 
 : @ J"n nb~
 ~
B2N 2Nr   