ó
    Ú°›j³X  ã                   ó°   • S SK r S SKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
JrJr  SS	KJr  SS
KJr  SSKJrJr  \ R(                  " \5      r " S S5      rg)é    N)Úpartialé   )Ú	docstring)ÚResourceLoadExceptioné   )ÚServiceActionÚWaiterAction)ÚResourceMetaÚServiceResource)ÚCollectionFactory)ÚResourceModel)ÚResourceHandlerÚbuild_identifiersc                   ó„   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS r SS jrSrg)ÚResourceFactoryé   a?  
A factory to create new :py:class:`~boto3.resources.base.ServiceResource`
classes from a :py:class:`~boto3.resources.model.ResourceModel`. There are
two types of lookups that can be done: one on the service itself (e.g. an
SQS resource) and another on models contained within the service (e.g. an
SQS Queue resource).
c                 ó.   • [        5       U l        Xl        g ©N)r   Ú_collection_factoryÚ_emitter)ÚselfÚemitters     ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/boto3/resources/factory.pyÚ__init__ÚResourceFactory.__init__%   s   € Ü#4Ó#6ˆÔ Ø�ó    c                 óú  • [         R                  SUR                  U5        [        UUUR                  5      nSnUR
                  (       a%  UR                  R                  UR
                  5      nUR                  U5        [        UR                  US9nSU0nU R                  UUUUS9  U R                  UUUUS9  U R                  UUUUUS9  U R                  UUUS9  U R                  UUUUS9  U R                  UUUUS9  UnUR                  U:X  a  S	nUR                   S
U 3n[         /n	U R"                  b  U R"                  R%                  SU 3UU	US9  ['        [)        U5      [+        U	5      U5      $ )aû  
Loads a resource from a model, creating a new
:py:class:`~boto3.resources.base.ServiceResource` subclass
with the correct properties and methods, named based on the service
and resource name, e.g. EC2.Instance.

:type resource_name: string
:param resource_name: Name of the resource to look up. For services,
                      this should match the ``service_name``.

:type single_resource_json_definition: dict
:param single_resource_json_definition:
    The loaded json of a single service resource or resource
    definition.

:type service_context: :py:class:`~boto3.utils.ServiceContext`
:param service_context: Context about the AWS service

:rtype: Subclass of :py:class:`~boto3.resources.base.ServiceResource`
:return: The service or resource class.
zLoading %s:%sN)Úresource_modelÚmeta)Úattrsr   Úresource_namer   )r    r!   r   Úservice_context)r    r   r!   r   r"   )r    r   r"   r   Ú.zcreating-resource-class.)Úclass_attributesÚbase_classesr"   )ÚloggerÚdebugÚservice_namer   Úresource_json_definitionsÚshapeÚservice_modelÚ	shape_forÚload_rename_mapr
   Ú_load_identifiersÚ_load_actionsÚ_load_attributesÚ_load_collectionsÚ_load_has_relationsÚ_load_waitersr   r   ÚemitÚtypeÚstrÚtuple)
r   r!   Úsingle_resource_json_definitionr"   r   r*   r   r    Úcls_namer%   s
             r   Úload_from_definitionÚ$ResourceFactory.load_from_definition)   sé  € ô0 	�‰Ø˜_×9Ñ9¸=ô	
ô
 'ØØ+Ø×5Ñ5ó
ˆð ˆØ××Ø#×1Ñ1×;Ñ;Ø×$Ñ$óˆEð 	×&Ñ& uÔ-ô Ø×(Ñ(¸ñ
ˆð �Dð
ˆð 	×ÑØØØ'Ø)ð	 	ñ 	
ð 	×ÑØØ'Ø)Ø+ð	 	ñ 	
ð 	×ÑØØØ'Ø)Ø+ð 	ñ 	
ð 	×ÑØØ)Ø+ð 	ñ 	
ð 	× Ñ ØØ'Ø)Ø+ð	 	!ñ 	
ð 	×ÑØØ'Ø)Ø+ð	 	ñ 	
ð !ˆØ×'Ñ'¨=Ó8Ø(ˆHØ%×2Ñ2Ð3°1°X°JÐ?ˆä'Ð(ˆØ�=‰=Ñ$Ø�M‰M×ÑØ*¨8¨*Ð5Ø!&Ø)Ø /ð	 ñ ô ”C˜“M¤5¨Ó#6¸Ó>Ð>r   c                 ó®   • UR                    HE  nUR                   R                  UR                  5        U R                  XT5      XR                  '   MG     g)zœ
Populate required identifiers. These are arguments without which
the resource cannot be used. Identifiers become arguments for
operations on the resource.
N)ÚidentifiersÚappendÚnameÚ_create_identifier)r   r    r   r   r!   Ú
identifiers         r   r.   Ú!ResourceFactory._load_identifiers    sF   € ð )×4Ô4ˆJØ×Ñ×#Ñ# J§O¡OÔ4Ø%)×%<Ñ%<Øó&ˆE—/‘/Ó"ò 5r   c                 óÔ   • UR                   (       a'  U R                  UR                   UUSS9US'   US   US'   UR                   H   nU R                  UUUS9XR                  '   M"     g)z©
Actions on the resource become methods, with the ``load`` method
being a special case which sets internal data for attributes, and
``reload`` is an alias for ``load``.
T)Úaction_modelr!   r"   Úis_loadÚloadÚreload)rD   r!   r"   N)rF   Ú_create_actionÚactionsr?   )r   r    r!   r   r"   Úactions         r   r/   ÚResourceFactory._load_actions¬   s|   € ð ××Ø ×/Ñ/Ø+×0Ñ0Ø+Ø /Øð	 0ð ˆE�&‰Mð $ F™mˆE�(‰Oà$×,Ô,ˆFØ!%×!4Ñ!4Ø#Ø+Ø /ð "5ð "ˆE—+‘+Óò -r   c           	      ó¬  • UR                   (       d  gUR                  R                  UR                   5      nUR                   Vs0 s H#  nUR                  (       d  M  UR                  U_M%     nnUR                  U5      n	U	R                  5        H9  u  n
u  p¼X¨;   a  U R                  UXŠ   UUS9nOU R                  UUU
UUS9nXÑU
'   M;     gs  snf )zÜ
Load resource attributes based on the resource shape. The shape
name is referenced in the resource JSON, but the shape itself
is defined in the Botocore service JSON, hence the need for
access to the ``service_model``.
N)r!   rA   Úmember_modelr"   )r!   r?   Úsnake_casedrM   r"   )	r*   r+   r,   r=   Úmember_nameÚget_attributesÚitemsÚ_create_identifier_aliasÚ_create_autoload_property)r   r    r   r!   r   r"   r*   Úir=   Ú
attributesr?   Ú	orig_nameÚmemberÚprops                 r   r0   Ú ResourceFactory._load_attributesÄ   sñ   € ð ×#×#Øà×-Ñ-×7Ñ7¸×8LÑ8LÓMˆð $×/Ò/ó
â/�Ø�}�}ó ˆA�M‰M˜1ÒÙ/ð 	ð 
ð
 $×2Ñ2°5Ó9ˆ
Ø)3×)9Ñ)9Ö);Ñ%ˆDÑ%�9ØÓ"Ø×4Ñ4Ø"/Ø*Ñ0Ø!'Ø$3ð	 5ð ‘ð ×5Ñ5Ø"/Ø"Ø $Ø!'Ø$3ð 6ð �ð �$‹Kò! *<ùò
s   ÁCÁCc                 óx   • UR                    H*  nU R                  UR                  UUS9XR                  '   M,     g)zé
Load resource collections from the model. Each collection becomes
a :py:class:`~boto3.resources.collection.CollectionManager` instance
on the resource instance, which allows you to iterate and filter
through the collection's items.
)r!   Úcollection_modelr"   N)ÚcollectionsÚ_create_collectionr?   )r   r    r   r"   r[   s        r   r1   Ú!ResourceFactory._load_collectionsê   sC   € ð !/× :Ô :ÐØ+/×+BÑ+BØ,×1Ñ1Ø!1Ø /ð ,Cð ,ˆE×'Ñ'Ó(ò !;r   c                 óú   • UR                    H   nU R                  UUUS9XR                  '   M"     UR                   H   nU R	                  UUUS9XR                  '   M"     U R                  XR                  5        g)až  
Load related resources, which are defined via a ``has``
relationship but conceptually come in two forms:

1. A reference, which is a related resource instance and can be
   ``None``, such as an EC2 instance's ``vpc``.
2. A subresource, which is a resource constructor that will always
   return a resource instance which shares identifiers/data with
   this resource, such as ``s3.Bucket('name').Object('key')``.
)Úreference_modelr!   r"   )Úsubresource_modelr!   r"   N)Ú
referencesÚ_create_referencer?   ÚsubresourcesÚ_create_class_partialÚ&_create_available_subresources_command)r   r    r!   r   r"   Ú	referenceÚsubresources          r   r2   Ú#ResourceFactory._load_has_relationsø   s�   € ð (×2Ô2ˆIð %)×$:Ñ$:Ø )Ø+Ø /ð %;ð %ˆE—.‘.Ó!ñ	 3ð *×6Ô6ˆKð '+×&@Ñ&@Ø"-Ø+Ø /ð 'Að 'ˆE×"Ñ"Ó#ñ 7ð 	×3Ñ3Ø×.Ñ.õ	
r   c                 ór   ^• U Vs/ s H  o3R                   PM     snm[        T5      mU4S jnXAS'   g s  snf )Nc                 ó   >• T$ )z«
Returns a list of all the available sub-resources for this
Resource.

:returns: A list containing the name of each sub-resource for this
    resource
:rtype: list of str
© )Úfactory_selfÚ_subresourcess    €r   Úget_available_subresourcesÚZResourceFactory._create_available_subresources_command.<locals>.get_available_subresources   s   ø€ ð !Ð r   ro   )r?   Úsorted)r   r    rd   rh   ro   rn   s        @r   rf   Ú6ResourceFactory._create_available_subresources_command  s<   ø€ Ù=IÓJº\¨k×)Ô)¹\ÑJˆÜ˜}Ó-ˆõ		!ð /IÐ*Ò+ùò Ks   †4c                 ód   • UR                    H   nU R                  UUUS9XR                  '   M"     g)z–
Load resource waiters from the model. Each waiter allows you to
wait until a resource reaches a specific state by polling the state
of the resource.
)Úresource_waiter_modelr!   r"   N)ÚwaitersÚ_create_waiterr?   )r   r    r!   r   r"   Úwaiters         r   r3   ÚResourceFactory._load_waiters-  s9   € ð %×,Ô,ˆFØ!%×!4Ñ!4Ø&,Ø+Ø /ð "5ð "ˆE—+‘+Óò -r   c                 ó�   ^• U4S jn[        TR                  5      Ul        [        R                  " UTSS9Ul        [        U5      $ )z9
Creates a read-only property for identifier attributes.
c                 ó8   >• [        U STR                   3S 5      $ ©NÚ_©Úgetattrr?   ©r   rA   s    €r   Úget_identifierÚ:ResourceFactory._create_identifier.<locals>.get_identifierA  s    ø€ ô ˜4 1 Z§_¡_Ð$5Ð!6¸Ó=Ð=r   F)r!   Úidentifier_modelÚinclude_signature)r6   r?   Ú__name__r   ÚIdentifierDocstringÚ__doc__Úproperty)rm   rA   r!   r€   s    `  r   r@   Ú"ResourceFactory._create_identifier<  sD   ø€ õ
	>ô #& j§o¡oÓ"6ˆÔÜ!*×!>Ò!>Ø'Ø'Ø#ñ"
ˆÔô ˜Ó'Ð'r   c           	      óÒ   ^• U4S jn[        TR                  5      Ul        [        R                  " UR
                  UTR                  U R                  USS9Ul        [        U5      $ )z:
Creates a read-only property that aliases an identifier.
c                 ó8   >• [        U STR                   3S 5      $ r{   r}   r   s    €r   r€   Ú@ResourceFactory._create_identifier_alias.<locals>.get_identifierZ  s   ø€ Ü˜4 1 Z§_¡_Ð$5Ð!6¸Ó=Ð=r   F©r(   r!   Ú	attr_nameÚevent_emitterÚ
attr_modelrƒ   )	r6   rO   r„   r   ÚAttributeDocstringr(   r   r†   r‡   )rm   r!   rA   rM   r"   r€   s     `   r   rR   Ú(ResourceFactory._create_identifier_aliasS  sa   ø€ õ	>ô #& j×&<Ñ&<Ó"=ˆÔÜ!*×!=Ò!=Ø(×5Ñ5Ø'Ø ×,Ñ,Ø&×/Ñ/Ø#Ø#ñ"
ˆÔô ˜Ó'Ð'r   c           	      óª   ^• U4S jn[        U5      Ul        [        R                  " UR                  UUU R
                  USS9Ul        [        U5      $ )zr
Creates a new property on the resource to lazy-load its value
via the resource's ``load`` method (if it exists).
c                 ó  >• U R                   R                  cD  [        U S5      (       a  U R                  5         O"[	        U R
                  R                   S35      eU R                   R                  R                  T5      $ )NrF   z has no load method)r   ÚdataÚhasattrrF   r   Ú	__class__r„   Úget)r   r?   s    €r   Úproperty_loaderÚBResourceFactory._create_autoload_property.<locals>.property_loaderz  se   ø€ Ø�y‰y�~‰~Ñ%Ü˜4 ×(Ñ(Ø—I‘I•Kä/ØŸ>™>×2Ñ2Ð3Ð3FÐGóð ð —9‘9—>‘>×%Ñ% dÓ+Ð+r   FrŒ   )r6   r„   r   r�   r(   r   r†   r‡   )rm   r!   r?   rN   rM   r"   r˜   s     `    r   rS   Ú)ResourceFactory._create_autoload_propertyi  sU   ø€ õ"		,ô $' {Ó#3ˆÔ Ü"+×">Ò">Ø(×5Ñ5Ø'Ø!Ø&×/Ñ/Ø#Ø#ñ#
ˆÔô ˜Ó(Ð(r   c           	      óè   ^• [        UUR                  S9mU4S jn[        UR                  5      Ul        [        R
                  " UU R                  UR                  UUR                  SS9Ul	        U$ )z`
Creates a new wait method for each resource where both a waiter and
resource model is defined.
)Úwaiter_resource_namec                 ó   >• T" U /UQ70 UD6  g r   rl   )r   ÚargsÚkwargsrw   s      €r   Ú	do_waiterÚ1ResourceFactory._create_waiter.<locals>.do_waiter�  s   ø€ Ù�4Ð)˜$Ò) &Ó)r   F)r!   rŽ   r+   rt   Úservice_waiter_modelrƒ   )
r	   r?   r6   r„   r   ÚResourceWaiterDocstringr   r+   r¢   r†   )rm   rt   r!   r"   r    rw   s        @r   rv   ÚResourceFactory._create_waiter‘  su   ø€ ô Ø!Ø!6×!;Ñ!;ñ
ˆõ
	*ô !Ð!6×!;Ñ!;Ó<ˆ	ÔÜ%×=Ò=Ø'Ø&×/Ñ/Ø)×7Ñ7Ø"7Ø!0×!EÑ!EØ#ñ
ˆ	Ôð Ðr   c                 óæ   ^ ^^^• T R                   R                  UTTT R                  S9mUUU U4S jn[        TR                  5      Ul        [        R                  " TSS9Ul        [        U5      $ )zC
Creates a new property on the resource to lazy-load a collection.
)r!   r[   r"   rŽ   c                 ó   >• T" TU TTS9$ )N)r[   ÚparentÚfactoryr"   rl   )r   Úclsr[   rm   r"   s    €€€€r   Úget_collectionÚ:ResourceFactory._create_collection.<locals>.get_collection¸  s   ø€ ÙØ!1ØØ$Ø /ñ	ð r   F)r[   rƒ   )
r   r:   r   r6   r?   r„   r   ÚCollectionDocstringr†   r‡   )rm   r!   r[   r"   rª   r©   s   ` `` @r   r]   Ú"ResourceFactory._create_collection«  sx   û€ ð ×.Ñ.×CÑCØ'Ø-Ø+Ø&×/Ñ/ð	 Dð 
ˆ÷	ð 	ô #&Ð&6×&;Ñ&;Ó"<ˆÔÜ!*×!>Ò!>Ø-Àñ"
ˆÔô ˜Ó'Ð'r   c                 ó2  ^^• [        UR                  R                  U UR                  US9m[        S UR                  R                   5       5      mUU4S jn[        UR                  5      Ul        [        R                  " USS9Ul
        [        U5      $ )zB
Creates a new property on the resource to lazy-load a reference.
)Úsearch_pathr¨   r   r"   c              3   ó>   #   • U  H  oR                   S :H  v •  M     g7f)r”   N)Úsource)Ú.0rT   s     r   Ú	<genexpr>Ú4ResourceFactory._create_reference.<locals>.<genexpr>Ù  s   é € ð 
Ú(L 1�H‰H˜ÖÒ(Lùs   ‚c                 ó¾   >• T(       a8  U R                   R                  c!  [        U S5      (       a  U R                  5         T" U 0 U R                   R                  5      $ ©NrF   )r   r”   r•   rF   )r   ÚhandlerÚ
needs_datas    €€r   Úget_referenceÚ8ResourceFactory._create_reference.<locals>.get_referenceÝ  sA   ø€ ö ˜dŸi™iŸn™nÑ4¼ÀÀv×9NÑ9NØ—	‘	”Ù˜4  T§Y¡Y§^¡^Ó4Ð4r   F)r`   rƒ   )r   ÚresourceÚpathÚanyr=   r6   r?   r„   r   ÚReferenceDocstringr†   r‡   )rm   r`   r!   r"   r¹   r·   r¸   s        @@r   rc   Ú!ResourceFactory._create_referenceÆ  s‘   ù€ ô "Ø'×0Ñ0×5Ñ5Ø Ø*×3Ñ3Ø+ñ	
ˆô ñ 
Ø(7×(@Ñ(@×(LÒ(Ló
ó 
ˆ
ö
	5ô "% _×%9Ñ%9Ó!:ˆÔÜ )× <Ò <Ø+¸uñ!
ˆÔô ˜Ó&Ð&r   c                 ó¸   ^ ^^^• TR                   R                  mU UUU4S jn[        T5      Ul        [        R
                  " UTTR                  SS9Ul        U$ )z‘
Creates a new method which acts as a functools.partial, passing
along the instance's low-level `client` to the new resource
class' constructor.
c                 ó0  >• / nTR                   R                  T
0 5      nT	R                  T
UTS9nTR                  R                  nUb%  [        X`5       H  u  pxUR                  U5        M     [        U/UQ7SU R                  R                  06" U0 UD6$ )N)r!   r8   r"   Úclient)
r)   r—   r:   r»   r=   r   r>   r   r   rÂ   )r   rž   rŸ   Úpositional_argsÚjson_defÚresource_clsr=   rA   Úvaluerm   r?   r"   ra   s            €€€€r   Úcreate_resourceÚ>ResourceFactory._create_class_partial.<locals>.create_resourceù  s¸   ø€ ð !ˆOð '×@Ñ@×DÑDÀTÈ2ÓNˆHØ'×<Ñ<Ø"Ø08Ø /ð =ð ˆLð ,×4Ñ4×@Ñ@ˆKØÑ&Ü):¸;Ö)MÑ%�JØ#×*Ñ*¨5Ö1ñ *Nô ØðØ.òØ7;·y±y×7GÑ7Gòàðàñð r   F)r!   Úsub_resource_modelr+   rƒ   )r»   r5   r6   r„   r   ÚSubResourceDocstringr+   r†   )rm   ra   r!   r"   rÇ   r?   s   `` ` @r   re   Ú%ResourceFactory._create_class_partialï  s[   û€ ð !×)Ñ)×.Ñ.ˆ÷	ð 	ô6 $' t£9ˆÔ Ü"+×"@Ò"@Ø'Ø0Ø)×7Ñ7Ø#ñ	#
ˆÔð Ðr   c           	      óJ  ^• [        XUS9mU(       a>  U4S jn[        R                  " UR                  UU R                  UUR
                  SS9nO2U4S jn[        R                  " UU R                  UUR
                  SS9n[        UR                  5      Ul        Xel	        U$ )zK
Creates a new method which makes a request to the underlying
AWS service.
)r¨   r"   c                 ó>   >• T" U /UQ70 UD6nX0R                   l        g r   )r   r”   ©r   rž   rŸ   ÚresponserJ   s       €r   Ú	do_actionÚ1ResourceFactory._create_action.<locals>.do_action4  s    ø€ Ù! $Ð8¨Ò8°Ñ8�Ø!)—	‘	•r   F)Úaction_namer!   rŽ   Ú
load_modelr+   rƒ   c                 ód   >• T" U /UQ70 UD6n[        U S5      (       a  S U R                  l        U$ r¶   )r•   r   r”   rÎ   s       €r   rÐ   rÑ   D  s6   ø€ Ù! $Ð8¨Ò8°Ñ8�ä˜4 ×(Ñ(ð &*�D—I‘I”Nà�r   )r!   rŽ   rD   r+   rƒ   )
r   r   ÚLoadReloadDocstringr?   r   r+   ÚActionDocstringr6   r„   r†   )rm   rD   r!   r"   rE   rÐ   Úlazy_docstringrJ   s          @r   rH   ÚResourceFactory._create_action  s§   ø€ ô ØÀñ
ˆö õ*ô
 '×:Ò:Ø(×-Ñ-Ø+Ø*×3Ñ3Ø'Ø-×;Ñ;Ø"'ñ‰Nõ	 ô '×6Ò6Ø+Ø*×3Ñ3Ø)Ø-×;Ñ;Ø"'ñˆNô ! ×!2Ñ!2Ó3ˆ	ÔØ*ÔØÐr   )r   r   N)F)r„   Ú
__module__Ú__qualname__Ú__firstlineno__r†   r   r:   r.   r/   r0   r1   r2   rf   r3   r@   rR   rS   rv   r]   rc   re   rH   Ú__static_attributes__rl   r   r   r   r      si   † ñò òu?òn
òò0$òLò"
òHIò"ò(ò.(ò,&)òPò4(ò6''òR,ðf ÷<r   r   )ÚloggingÚ	functoolsr   Údocsr   Ú
exceptionsr   rJ   r   r	   Úbaser
   r   Ú
collectionr   Úmodelr   rÏ   r   r   Ú	getLoggerr„   r&   r   rl   r   r   Ú<module>rå      s>   ðó Ý å Ý .ß /ß /Ý )Ý  ß 8à	×	Ò	˜8Ó	$€÷}ò }r   