B v޲_*@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||||_dS)N)superr__init___botocore_session)selfresourceZbotocore_session) __class__:/tmp/pip-target-kmdnttut/lib/python/boto3/docs/resource.pyrszResourceDocumenter.__init__cCsr|||||d}||||||||||||| || |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|j|jdS)N)styleh2_resource_name)rr$rrrr0szResourceDocumenter._add_titlecCsg}|jjr*x|jjD]}||jqWt|}|jjd|j|fd|d}| ||d}| |||d}| ||dS)Nz%s(%s)) class_name descriptionZexampleparams) 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}|d||jfdS)Nz A resource representing an %s %s)r_service_modelwriter()rr$official_service_namerrrr/Ks z#ResourceDocumenter._add_descriptioncCs|j|j|d|j|j|d|j|jf|jt|}|dt|j|j|j|f|jdS)Nz import boto3z%s = boto3.resource('%s')z%s = %s.%s(%s)) r&start_codeblocknew_liner5 _service_namer rr( end_codeblock)rr$r2Zexample_valuesrrrr0Rs       zResourceDocumenter._add_examplecCsRxL|D]D}t|j|}|d||j|d||f|jqWdS)Nz:type %s: stringz :param %s: %s)rr(r5r&r8)rr$r2Zidentifier_namer*rrrr1ds    z*ResourceDocumenter._add_params_descriptioncCstxn|jD]d}|j|d||jx<|j|D].}|dkrX|jd|q:|jd|q:WqWdS)Nz&These are the resource's available %s:)r, attributes references collectionsz :py:attr:`%s`z:py:meth:`%s()`) member_mapr&r8r5li)rr$Zresource_member_typememberrrrr#ns   z+ResourceDocumenter._add_overview_of_memberscCsr|jjjj}|d}g}|r8||jd<t|ddddx4|D],}||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_listr3Zidentifier_sectionrrrr{s"      z#ResourceDocumenter._add_identifiersc Cs|jjjjj}i}|jjjjr@||jjjj}|jjj|}|d}g}|rlt |dddd||j d<xRt |D]F}||\}}||} | |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.rA)r$rBr*rC)r$Z service_namerD attr_nameZ event_emitterZ attr_model)rErFclient service_modelrGshapeZ shape_forZget_attributesrrr>sortedr-r r9r(events) rr$rJr;rKZattribute_listrH_Z attr_shapeZattribute_sectionrrrrs6        z"ResourceDocumenter._add_attributescCsn|d}|jjjj}g}|r8t|dddd||jd<x0|D](}||j}||jt ||dq>WdS)Nr<Z ReferenceszNReferences are related resource instances that have a belongs-to relationship.Zreferences_intro)r$rBr*rC)r$Zreference_model) rrErFrGr<rr>r.r-r )rr$r<Zreference_list referenceZreference_sectionrrrrs       z"ResourceDocumenter._add_referencescCs:|d}|jjjj}|r6t|j}|j|_||dS)Nactions)rrErFrGrPrr>Zdocument_actions)rr$rP documenterrrrrs    zResourceDocumenter._add_actionscCs:|d}|jjjj}|r6t|j}|j|_||dS)Nz sub-resources)rrErFrGZ subresourcesrr>Zdocument_sub_resources)rr$Z sub_resourcesrQrrrr s    z%ResourceDocumenter._add_sub_resourcescCs:|d}|jjjj}|r6t|j}|j|_||dS)Nr=)rrErFrGr=rr>Zdocument_collections)rr$r=rQrrrr!s    z#ResourceDocumenter._add_collectionscCsJ|d}|jjjj}|rF|j|j}t|j|}|j |_ | |dS)Nwaiters) rrErFrGrRrZget_waiter_modelr9rr>Zdocument_resource_waiters)rr$rRZservice_waiter_modelrQrrrr"s   zResourceDocumenter._add_waiters)__name__ __module__ __qualname__rr%rrr/r0r1r#rrrrr r!r" __classcell__rr)rrrs    "rc@s0eZdZeddZddZddZddZd S) ServiceResourceDocumentercCs d|jS)Nz%s.ServiceResource)Z_service_docs_name)rrrrr)sz$ServiceResourceDocumenter.class_namecCs|jddS)NzService Resource)r&r')rr$rrrrsz$ServiceResourceDocumenter._add_titlecCst|j}|d|dS)NzA resource representing %s)rr4r5)rr$r6rrrr/sz*ServiceResourceDocumenter._add_descriptioncCsV|j|j|d|j|j|d|j|jf|jdS)Nz import boto3z%s = boto3.resource('%s'))r&r7r8r5r9r:)rr$r2rrrr0s     z&ServiceResourceDocumenter._add_exampleN)rSrTrUpropertyr)rr/r0rrrrrWs rWN)ZbotocorerZbotocore.docs.utilsrZboto3.docs.baserZboto3.docs.actionrZboto3.docs.waiterrZboto3.docs.collectionrZboto3.docs.subresourcerZboto3.docs.attrr r r Zboto3.docs.utilsr r rrrrWrrrr s              O