B ’äî\ÃPã@s¶dZddlZddlmZe e¡ZGdd„deƒZGdd„deƒZ Gdd „d eƒZ Gd d „d eƒZ Gd d „d e ƒZ Gdd„de ƒZ Gdd„deƒZGdd„de ƒZGdd„deƒZdS)a  The models defined in this file represent the resource JSON description format and provide a layer of abstraction from the raw JSON. The advantages of this are: * Pythonic interface (e.g. ``action.request.operation``) * Consumers need not change for minor JSON changes (e.g. renamed field) These models are used both by the resource factory to generate resource classes as well as by the documentation generator. éN)Ú xform_namec@seZdZdZddd„ZdS)Ú Identifierzw A resource identifier, given by its name. :type name: string :param name: The name of the identifier NcCs||_||_dS)N)ÚnameÚ member_name)Úselfrr©rú6/tmp/pip-build-uw_ogi45/boto3/boto3/resources/model.pyÚ__init__)szIdentifier.__init__)N)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrr"src@seZdZdZdd„ZdS)ÚActiona A service operation action. :type name: string :param name: The name of the action :type definition: dict :param definition: The JSON definition :type resource_defs: dict :param resource_defs: All resources defined in the service cCs^||_||_d|_d|kr,t| di¡ƒ|_d|_d|krNt| di¡|ƒ|_| d¡|_dS)NÚrequestÚresourceÚpath)Ú _definitionrrÚRequestÚgetrÚResponseResourcer)rrÚ definitionÚ resource_defsrrrr :s zAction.__init__N)r r r r r rrrrr/s rc@s$eZdZdZdd„Zedd„ƒZdS)ÚDefinitionWithParamsa An item which has parameters exposed via the ``params`` property. A request has an operation and parameters, while a waiter has a name, a low-level waiter name and parameters. :type definition: dict :param definition: The JSON definition cCs ||_dS)N)r)rrrrrr UszDefinitionWithParams.__init__cCs0g}x&|j dg¡D]}| tf|Ž¡qW|S)zt Get a list of auto-filled parameters for this request. :type: list(:py:class:`Parameter`) Úparams)rrÚappendÚ Parameter)rrÚitemrrrrXszDefinitionWithParams.paramsN)r r r r r ÚpropertyrrrrrrLsrc@seZdZdZddd„ZdS)raÌ An auto-filled parameter which has a source and target. For example, the ``QueueUrl`` may be auto-filled from a resource's ``url`` identifier when making calls to ``queue.receive_messages``. :type target: string :param target: The destination parameter name, e.g. ``QueueUrl`` :type source_type: string :param source_type: Where the source is defined. :type source: string :param source: The source name, e.g. ``Url`` NcKs2||_||_||_||_||_|r.t d|¡dS)Nz#Unknown parameter options found: %s)ÚtargetÚsourcerrÚvalueÚloggerÚwarning)rrrrrr Úkwargsrrrr tszParameter.__init__)NNN)r r r r r rrrrrgs rcs eZdZdZ‡fdd„Z‡ZS)rzt A service operation action request. :type definition: dict :param definition: The JSON definition cs tt|ƒ |¡| d¡|_dS)NÚ operation)Úsuperrr rr$)rr)Ú __class__rrr szRequest.__init__)r r r r r Ú __classcell__rr)r&rr†srcs$eZdZdZdZ‡fdd„Z‡ZS)ÚWaiterzª An event waiter specification. :type name: string :param name: Name of the waiter :type definition: dict :param definition: The JSON definition Z WaitUntilcs&tt|ƒ |¡||_| d¡|_dS)NZ waiterName)r%r(r rrZ waiter_name)rrr)r&rrr ŸszWaiter.__init__)r r r r ÚPREFIXr r'rr)r&rr(”sr(c@s0eZdZdZdd„Zedd„ƒZedd„ƒZdS) rzç A resource response to create after performing an action. :type definition: dict :param definition: The JSON definition :type resource_defs: dict :param resource_defs: All resources defined in the service cCs(||_||_| d¡|_| d¡|_dS)NÚtyper)rÚ_resource_defsrr*r)rrrrrrr ²s zResponseResource.__init__cCs0g}x&|j dg¡D]}| tf|Ž¡qW|S)z^ A list of resource identifiers. :type: list(:py:class:`Identifier`) Ú identifiers)rrrr)rr,rrrrr,¼s zResponseResource.identifierscCst|j|j|j|jƒS)zm Get the resource model for the response resource. :type: :py:class:`ResourceModel` )Ú ResourceModelr*r+)rrrrÚmodelËszResponseResource.modelN)r r r r r rr,r.rrrrr©s rc@seZdZdZedd„ƒZdS)Ú Collectiona A group of resources. See :py:class:`Action`. :type name: string :param name: The name of the collection :type definition: dict :param definition: The JSON definition :type resource_defs: dict :param resource_defs: All resources defined in the service cCs |jjjS)zò Get a list of batch actions supported by the resource type contained in this action. This is a shortcut for accessing the same information through the resource model. :rtype: list(:py:class:`Action`) )rr.Ú batch_actions)rrrrr0ás zCollection.batch_actionsN)r r r r rr0rrrrr/Ös r/c@s®eZdZdZdd„Zd"dd„Zd#dd „Zd$d d „Zd d „Ze dd„ƒZ e dd„ƒZ e dd„ƒZ e dd„ƒZ dd„Zdd„Ze dd„ƒZe dd„ƒZe dd„ƒZe d d!„ƒZdS)%r-aù A model representing a resource, defined via a JSON description format. A resource has identifiers, attributes, actions, sub-resources, references and collections. For more information on resources, see :ref:`guide_resources`. :type name: string :param name: The name of this resource, e.g. ``sqs`` or ``Queue`` :type definition: dict :param definition: The JSON definition :type resource_defs: dict :param resource_defs: All resources defined in the service cCs(||_||_i|_||_| d¡|_dS)NÚshape)rr+Ú_renamedrrr1)rrrrrrrr ûs zResourceModel.__init__NcCshtdgƒ}i|_|j d¡r&| d¡x(|j dg¡D]}| ||dd¡q6Wx$|j di¡D]}| ||d¡q`Wxj| ¡ ¡D]Z\}}d}x&|d dD]}|d d kržd }PqžW|sÐ|j||d ddq„| ||d¡q„Wx$|j di¡D]}| ||d¡qòWx,|j di¡D]}| |tj |d¡qW|dk rdx"|j   ¡D]}| ||d¡qLWdS)aþ Load a name translation map given a shape. This will set up renamed values for any collisions, e.g. if the shape, an action, and a subresource all are all named ``foo`` then the resource will have an action ``foo``, a subresource named ``Foo`` and a property named ``foo_attribute``. This is the order of precedence, from most important to least important: * Load action (resource.load) * Identifiers * Actions * Subresources * References * Collections * Waiters * Attributes (shape members) Batch actions are only exposed on collections, so do not get modified here. Subresources use upper camel casing, so are unlikely to collide with anything but other subresources. Creates a structure like this:: renames = { ('action', 'id'): 'id_action', ('collection', 'id'): 'id_collection', ('attribute', 'id'): 'id_attribute' } # Get the final name for an action named 'id' name = renames.get(('action', 'id'), 'id') :type shape: botocore.model.Shape :param shape: The underlying shape for this resource. ÚmetaÚloadr,rÚ identifierÚactionsÚactionFrrÚdataTÚ subresource)Ú snake_caseÚ referenceÚhasManyÚ collectionÚwaitersÚwaiterNÚ attribute) Úsetr2rrÚaddÚ_load_name_with_categoryÚ_get_has_definitionÚitemsr(r)ÚmembersÚkeys)rr1ÚnamesrrÚrefÚ data_requiredr5rrrÚload_rename_maps4&        zResourceModel.load_rename_mapTcCsv|r t|ƒ}||krht d|j||f¡|d||j||f<|d|7}||krhtd |j||¡ƒ‚| |¡dS)a‚ Load a name with a given category, possibly renaming it if that name is already in use. The name will be stored in ``names`` and possibly be set up in ``self._renamed``. :type names: set :param names: Existing names (Python attributes, properties, or methods) on the resource. :type name: string :param name: The original name of the value. :type category: string :param category: The value type, such as 'identifier' or 'action' :type snake_case: bool :param snake_case: True (default) if the name should be snake cased. zRenaming %s %s %sÚ_z Problem renaming {0} {1} to {2}!N)rr!Údebugrr2Ú ValueErrorÚformatrB)rrHrÚcategoryr:rrrrCQs z&ResourceModel._load_name_with_categorycCs|r t|ƒ}|j ||f|¡S)a] Get a possibly renamed value given a category and name. This uses the rename map set up in ``load_rename_map``, so that method must be called once first. :type category: string :param category: The value type, such as 'identifier' or 'action' :type name: string :param name: The original name of the value :type snake_case: bool :param snake_case: True (default) if the name should be snake cased. :rtype: string :return: Either the renamed value if it is set, otherwise the original name. )rr2r)rrPrr:rrrÚ _get_namerszResourceModel._get_namecCs^i}dd„|jDƒ}xD|j ¡D]6\}}t|ƒ}||kr:q |jd|dd}||f||<q W|S)a³ Get a dictionary of attribute names to original name and shape models that represent the attributes of this resource. Looks like the following: { 'some_name': ('SomeName', ) } :type shape: botocore.model.Shape :param shape: The underlying shape for this resource. :rtype: dict :return: Mapping of resource attributes. cSsg|] }|j‘qSr)r)Ú.0Úirrrú —sz0ResourceModel.get_attributes..r@F)r:)r,rFrErrQ)rr1Ú attributesZidentifier_namesrÚmemberZ snake_casedrrrÚget_attributes‡szResourceModel.get_attributescCs\g}xR|j dg¡D]@}| d|d¡}| dd¡}|rD| d|¡}| t||ƒ¡qW|S)zb Get a list of resource identifiers. :type: list(:py:class:`Identifier`) r,r5rZ memberNameNr@)rrrQrr)rr,rrrrrrr,¤s  zResourceModel.identifierscCs&|j d¡}|dk r"td||jƒ}|S)zy Get the load action for this resource, if it is defined. :type: :py:class:`Action` or ``None`` r4N)rrrr+)rr7rrrr4¶s zResourceModel.loadcCsHg}x>|j di¡ ¡D](\}}| d|¡}| t|||jƒ¡qW|S)zc Get a list of actions for this resource. :type: list(:py:class:`Action`) r6r7)rrrErQrrr+)rr6rrrrrr6Äs  zResourceModel.actionscCsHg}x>|j di¡ ¡D](\}}| d|¡}| t|||jƒ¡qW|S)zi Get a list of batch actions for this resource. :type: list(:py:class:`Action`) Z batchActionsZ batch_action)rrrErQrrr+)rr6rrrrrr0Ós  zResourceModel.batch_actionsc CsÒ|j|jkrÀi}x¼|j ¡D]ž\}}d}|j di¡ ¡}x2|D]*\}}| di¡ d¡|kr@|||<d}q@W|sd|gdœi}x0| dg¡D] } |dd | dd d œ¡qŽW|||<qWn|j di¡}|S) aÑ Get a ``has`` relationship definition from a model, where the service resource model is treated special in that it contains a relationship to every resource defined for the service. This allows things like ``s3.Object('bucket-name', 'key')`` to work even though the JSON doesn't define it explicitly. :rtype: dict :return: Mapping of names to subresource and reference definitions. FZhasrr*T)r*r,r,rÚinput)rr)rr+rErrr) rrrZ resource_defÚfoundZ has_itemsZhas_nameZhas_defZfake_hasr5rrrrDâs&   z!ResourceModel._get_has_definitioncCsžg}x”| ¡ ¡D]„\}}|r0|jd|dd}n | d|¡}t|||jƒ}d}x |jjD]}|jdkrXd}PqXW|r„|s„| |¡q|s|r| |¡qW|S)a Get a list of sub-resources or references. :type subresources: bool :param subresources: ``True`` to get sub-resources, ``False`` to get references. :rtype: list(:py:class:`ResponseResource`) r9F)r:r;r8T) rDrErQrr+rr,rr)rÚ subresourcesÚ resourcesrrr7rJr5rrrÚ_get_related_resources!s    z$ResourceModel._get_related_resourcescCs | d¡S)za Get a list of sub-resources. :type: list(:py:class:`ResponseResource`) T)r\)rrrrrZ@szResourceModel.subresourcescCs | d¡S)zg Get a list of reference resources. :type: list(:py:class:`ResponseResource`) F)r\)rrrrÚ referencesIszResourceModel.referencescCsHg}x>|j di¡ ¡D](\}}| d|¡}| t|||jƒ¡qW|S)zk Get a list of collections for this resource. :type: list(:py:class:`Collection`) r<r=)rrrErQrr/r+)rÚ collectionsrrrrrr^Rs  zResourceModel.collectionscCsJg}x@|j di¡ ¡D]*\}}| dtj|¡}| t||ƒ¡qW|S)zc Get a list of waiters for this resource. :type: list(:py:class:`Waiter`) r>r?)rrrErQr(r)r)rr>rrrrrr>as zResourceModel.waiters)N)T)T)r r r r r rKrCrQrWrr,r4r6r0rDr\rZr]r^r>rrrrr-ís   M     ? r-)r ÚloggingZbotocorerÚ getLoggerr r!Úobjectrrrrrr(rr/r-rrrrÚs   -