3 ?\*@sddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZGdddeZGdddeZdS)) xform_name)get_official_service_name)BaseDocumenter)ActionDocumenter)WaiterResourceDocumenter)CollectionDocumenter)SubResourceDocumenter)document_attribute)document_identifier)document_reference)!get_identifier_args_for_signature)!get_identifier_values_for_example)get_identifier_description)add_resource_type_overviewcseZdZfddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZZS)ResourceDocumentercstt|j|||_dS)N)superr__init___botocore_session)selfresourceZbotocore_session) __class__j/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/boto3/boto3/docs/resource.pyrszResourceDocumenter.__init__cCsr|j||j||jd}|j||j||j||j||j||j||j ||j |dS)Nzmember-overview) _add_title _add_introadd_new_section_add_identifiers_add_attributes_add_references _add_actions_add_sub_resources_add_collections _add_waiters_add_overview_of_members)rsectionZoverview_sectionrrrdocument_resource#s          z$ResourceDocumenter.document_resourcecCs|jj|jdS)N)styleh2_resource_name)rr$rrrr0szResourceDocumenter._add_titlecCsg}|jjr*x|jjD]}|j|jqWt|}|jjd|j|fd|jd}|j ||jd}|j |||jd}|j ||dS)Nz%s(%s)) class_name descriptionexampleparams) Z_resource_model identifiersappendnamer r&Zstart_sphinx_py_classr)r_add_description _add_example_add_params_description)rr$identifier_names identifierZ class_argsZdescription_sectionZexample_sectionZ param_sectionrrrr3s     zResourceDocumenter._add_introcCs"t|j}|jd||jfdS)Nz A resource representing an %s %s)r_service_modelwriter()rr$official_service_namerrrr0Ks z#ResourceDocumenter._add_descriptioncCs|jj|jj|jd|jj|jj|jd|j|jf|jjt|}|jdt|j|j|j|f|jjdS)Nz import boto3z%s = boto3.resource('%s')z%s = %s.%s(%s)) r&start_codeblocknew_liner6 _service_namer rr( end_codeblock)rr$r3Zexample_valuesrrrr1Rs       zResourceDocumenter._add_examplecCsRxL|D]D}t|j|}|jd||jj|jd||f|jjqWdS)Nz:type %s: stringz :param %s: %s)rr(r6r&r9)rr$r3Zidentifier_namer*rrrr2ds    z*ResourceDocumenter._add_params_descriptioncCstxn|jD]d}|jj|jd||jjx<|j|D].}|dkrX|jjd|q:|jjd|q:WqWdS) Nz&These are the resource's available %s:r- attributes references collectionsz :py:attr:`%s`z:py:meth:`%s()`)r-r<r=r>) member_mapr&r9r6li)rr$Zresource_member_typememberrrrr#ns   z+ResourceDocumenter._add_overview_of_memberscCsr|jjjj}|jd}g}|r8||jd<t|ddddx4|D],}|j|j}|j|jt ||j |dq>WdS)Nr-Z IdentifierszXIdentifiers are properties of a resource that are set upon instantation of the resource.identifiers_attributes_intro)r$ resource_typer* intro_link)r$ resource_nameZidentifier_model) _resourcemetaresource_modelr-rr?rr/r.r r()rr$r-Z member_listr4Zidentifier_sectionrrrr{s"      z#ResourceDocumenter._add_identifiersc Cs|jjjjj}i}|jjjjr@|j|jjjj}|jjjj|}|jd}g}|rlt |dddd||j d<xRt |D]F}||\}}|j|} |j |t | |j|j||jjjjj|dqvWdS)Nr<Z AttributeszAttributes provide access to the properties of a resource. Attributes are lazy-loaded the first time one is accessed via the :py:meth:`load` method.rB)r$rCr*rD)r$Z service_namerE attr_nameZ event_emitterZ attr_model)rFrGclient service_modelrHshapeZ shape_forZget_attributesrrr?sortedr.r r:r(events) rr$rKr<rLZattribute_listrI_Z attr_shapeZattribute_sectionrrrrs6        z"ResourceDocumenter._add_attributescCsn|jd}|jjjj}g}|r8t|dddd||jd<x0|D](}|j|j}|j|jt ||dq>WdS)Nr=Z ReferenceszNReferences are related resource instances that have a belongs-to relationship.Zreferences_intro)r$rCr*rD)r$Zreference_model) rrFrGrHr=rr?r/r.r )rr$r=Zreference_list referenceZreference_sectionrrrrs       z"ResourceDocumenter._add_referencescCs:|jd}|jjjj}|r6t|j}|j|_|j|dS)Nactions)rrFrGrHrQrr?Zdocument_actions)rr$rQ documenterrrrrs    zResourceDocumenter._add_actionscCs:|jd}|jjjj}|r6t|j}|j|_|j|dS)Nz sub-resources)rrFrGrHZ subresourcesrr?Zdocument_sub_resources)rr$Z sub_resourcesrRrrrr s    z%ResourceDocumenter._add_sub_resourcescCs:|jd}|jjjj}|r6t|j}|j|_|j|dS)Nr>)rrFrGrHr>rr?Zdocument_collections)rr$r>rRrrrr!s    z#ResourceDocumenter._add_collectionscCsJ|jd}|jjjj}|rF|jj|j}t|j|}|j |_ |j |dS)Nwaiters) rrFrGrHrSrZget_waiter_modelr:rr?Zdocument_resource_waiters)rr$rSZservice_waiter_modelrRrrrr"s   zResourceDocumenter._add_waiters)__name__ __module__ __qualname__rr%rrr0r1r2r#rrrrr r!r" __classcell__rr)rrrs    "rc@s0eZdZeddZddZddZddZd S) ServiceResourceDocumentercCs d|jS)Nz%s.ServiceResource)Z_service_docs_name)rrrrr)sz$ServiceResourceDocumenter.class_namecCs|jjddS)NzService Resource)r&r')rr$rrrrsz$ServiceResourceDocumenter._add_titlecCst|j}|jd|dS)NzA resource representing %s)rr5r6)rr$r7rrrr0sz*ServiceResourceDocumenter._add_descriptioncCsV|jj|jj|jd|jj|jj|jd|j|jf|jjdS)Nz import boto3z%s = boto3.resource('%s'))r&r8r9r6r:r;)rr$r3rrrr1s     z&ServiceResourceDocumenter._add_exampleN)rTrUrVpropertyr)rr0r1rrrrrXs rXN)ZbotocorerZbotocore.docs.utilsrZboto3.docs.baserZboto3.docs.actionrZboto3.docs.waiterrZboto3.docs.collectionrZboto3.docs.subresourcerZboto3.docs.attrr r r Zboto3.docs.utilsr r rrrrXrrrr s              O