o <&a2@sddlmZddlmZddlmZddlmZddlmZddlm Z ddl m Z ddlm Z dd l mZd d ZGd d d eZGdddeZdS))get_official_service_namedocument_custom_method)document_model_driven_method)get_instance_public_methods)document_shared_examples)ResponseExampleDocumenter)ResponseParamsDocumenter)DocumentedShape) OrderedDictcKs|dkrdS|dvS)Ngenerate_presigned_url)s3) method_name service_namekwargsrr6/usr/lib/python3/dist-packages/botocore/docs/client.py!_allowlist_generate_presigned_urlsrc@seZdZegZd ddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZddZddZdS)!ClientDocumenterNcCs.||_||_|jduri|_|jjjj|_dSN)_client_shared_examplesmeta service_modelr _service_name)selfclientshared_examplesrrr__init__#s  zClientDocumenter.__init__cCs8|||||}||||||dS)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)rsectionclient_methodsrrrdocument_client*s   z ClientDocumenter.document_clientcCst|j}||Sr)rr_filter_client_methods)rr%rrrr!5s  z$ClientDocumenter._get_client_methodscCs8i}|D]\}}|j|||jd}|r|||<q|S)N)methodrr)items_filter_client_methodr)rr%filtered_methodsrr(includerrrr'9sz'ClientDocumenter._filter_client_methodscKs.|jD]}|di|}|dur|SqdS)NTr)_CLIENT_METHODS_FILTERS)rrfilterfilter_includerrrr*Es z&ClientDocumenter._filter_client_methodcC|jddS)NClientstyleh2rr$rrrrOzClientDocumenter._add_titlecCs|d}t|jjj}|d||j||jjjj | ||j|d|j|jj j }t |D] }|jd||fq>dS)Nintroz"A low-level client representing %sz These are the available methods:z:py:meth:`~%s.Client.%s`)add_new_sectionrrrrwriter3new_lineinclude_doc_string documentation_add_client_creation_example __class____name__sortedli)rr$r%official_service_name class_namerrrrr"Rs&         z"ClientDocumenter._add_client_introcCs|jjd|jjjddS)Nz %s.ClientrC)r3start_sphinx_py_classrr>r?r5rrrr hs  z%ClientDocumenter._add_class_signaturecCs6|j|j|dj|jd|jdS)Nz+client = session.create_client('{service}'))service)r3start_codeblockr:r9formatr end_codeblockr5rrrr=ls  z-ClientDocumenter._add_client_creation_examplecCs.|d}t|D] }|||||q dS)Nmethods)r8r@_add_client_method)rr$r%rrrrr#us   z$ClientDocumenter._add_client_methodscCs6||}||r||||dS|||dSr)r8_is_custom_method_add_custom_method_add_model_driven_methodrr$rr(rrrrK{s  z#ClientDocumenter._add_client_methodcCs||jjjvSr)rrmethod_to_api_mapping)rrrrrrLsz"ClientDocumenter._is_custom_methodcCst|||dSrrrOrrrrMr6z#ClientDocumenter._add_custom_methodcCsb|d}|j|jd|j|jjj}|jD]}d||jf}|j d|qdS)N exceptions Exceptions%s.Client.exceptions.%s:py:class:`%s`) r8r3r:boldrr>r? error_shapesnamerA)rr$operation_model error_section client_nameerrorrCrrr_add_method_exceptions_lists      z,ClientDocumenter._add_method_exceptions_listcCs~|jjj}|jjj|}||}d|}t||||jjj|j|d|jr,| |||j |}|r=t ||||dSdS)Nzresponse = client.%s) event_emittermethod_descriptionexample_prefix) rrrrPrXreventsr<rVr\rgetr)rr$rroperation_namerXr_rrrrrNs$    z)ClientDocumenter._add_model_driven_methodr)r? __module__ __qualname__rr-rr&r!r'r*rr"r r=r#rKrLrMr\rNrrrrrs$      rc @seZdZdZedddededdddfd ed dd dfgd Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S))ClientExceptionsDocumenterzQhttps://boto3.amazonaws.com/v1/documentation/api/latest/guide/error-handling.htmlError structurez1Normalized access to common exception attributes.Codestringz,An identifier specifying the exception type.)rW type_namer<Messagez;A descriptive message explaining why the exception occured.)rWrjr<memberscCs||_|jjjj|_dSr)rrrrr)rrrrrrsz#ClientExceptionsDocumenter.__init__cCs,||||||||dSr)r _add_overview_add_exceptions_list_add_exception_classesr5rrrdocument_exceptionss   z.ClientExceptionsDocumenter.document_exceptionscCr0)NzClient Exceptionsr2r5rrrrr6z%ClientExceptionsDocumenter._add_titlecCs>|j|d|jjd|jd|d|jdS)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)titlelink.)r3r:r9 external_link_USER_GUIDE_LINKr5rrrrms  z(ClientExceptionsDocumenter._add_overviewcCs|jjj}d||jfS)NrS)rr>r?rW)rshapecls_namerrr_exception_class_names z0ClientExceptionsDocumenter._exception_class_namecCsx|jjjj}|s|j|d|jdS|j|d|j|D]}||}|jd|q*dS)Nz-This client has no modeled exception classes.z$The available client exceptions are:rT) rrrrVr3r:r9rxrA)rr$rVrvrCrrrrns        z/ClientExceptionsDocumenter._add_exceptions_listcCs"|jjjjD]}|||qdSr)rrrrV_add_exception_classrr$rvrrrrosz1ClientExceptionsDocumenter._add_exception_classescCsV||j}||}|jj|d||||||||||jdS)NrD) r8rWrxr3rE_add_top_level_documentation_add_exception_catch_example_add_response_attrend_sphinx_py_class)rr$rv class_sectionrCrrrrys     z/ClientExceptionsDocumenter._add_exception_classcCs.|jr|j||j|jdSdSr)r<r3r:r;rzrrrr{s   z7ClientExceptionsDocumenter._add_top_level_documentationcCs|j|jd|j|d|j|j|d|j|j|d|j|j|j|d|j|jdS)NExampleztry:z...z!except client.exceptions.%s as e:zprint(e.response)) r3r:rUrGr9indentdedentrWrIrzrrrr| s             z7ClientExceptionsDocumenter._add_exception_catch_examplecCsF|d}|jd|||||||||jdS)Nresponse)r8r3start_sphinx_py_attr_add_response_attr_description_add_response_example_add_response_paramsend_sphinx_py_attr)rr$rvresponse_sectionrrrr}s     z-ClientExceptionsDocumenter._add_response_attrcCs"|j|d|jdS)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.)r3r:r;r5rrrr"s z9ClientExceptionsDocumenter._add_response_attr_descriptioncCsX|d}|j|jd|jt|jd|jjj d}|j |||j gddS)NsyntaxSyntaxrrbr]r,) r8r3r:rU new_paragraphrrrrr`document_example_GENERIC_ERROR_SHAPE)rr$rvexample_section documenterrrrr,      z0ClientExceptionsDocumenter._add_response_examplecCsX|d}|j|jd|jt|jd|jjj d}|j |||j gddS)N Structurerr) r8r3r:rUrr rrrr`document_paramsr)rr$rvparams_sectionrrrrr:rz/ClientExceptionsDocumenter._add_response_paramsN)r?rcrdrur r rrrprrmrxrnroryr{r|r}rrrrrrrresD  reN)botocore.docs.utilsrbotocore.docs.methodrrrbotocore.docs.sharedexamplerbotocore.docs.examplerbotocore.docs.paramsr r botocore.compatr robjectrrerrrrs