
    /Jf;                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZmZ d dlmZ  G d de          Z G d de          ZdS )    N)
xform_name)DocumentStructure)get_official_service_name)ActionDocumenter)document_attributedocument_identifierdocument_reference)BaseDocumenter)CollectionDocumenter)SubResourceDocumenter)add_resource_type_overview!get_identifier_args_for_signatureget_identifier_description!get_identifier_values_for_example)WaiterResourceDocumenterc                   x     e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Z xZS )ResourceDocumenterc                     t                                          |           || _        || _        | j                                        | _        | j        | j        k    r	d| _        d S d S )Nzservice-resource)super__init___botocore_session_root_docs_path_resource_namelower_resource_sub_path_service_name)selfresourcebotocore_sessionroot_docs_path	__class__s       V/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/boto3/docs/resource.pyr   zResourceDocumenter.__init__&   si    """!1-"&"5";";"="=$"444&8D### 54    c                    |                      |           |                     |           |                     |           |                     |           |                     |           |                     |           |                     |           |                     |           |                     |           | 	                    |           d S )N)

_add_title_add_resource_note
_add_intro_add_identifiers_add_attributes_add_references_add_actions_add_sub_resources_add_collections_add_waitersr   sections     r"   document_resourcez$ResourceDocumenter.document_resource.   s       (((   g&&&W%%%W%%%'"""(((g&&&'"""""r#   c                 n    |                     d          }|j                            | j                   d S )Ntitle)add_new_sectionstyleh2r   r   r0   title_sections      r"   r%   zResourceDocumenter._add_title:   s5    //88t233333r#   c                 d   g }| j         j        r)| j         j        D ]}|                    |j                   t	          |          }|                    d          }|j                            | j         d| d           |                    d          }| 	                    |           |                    d          }| 
                    ||           |                    d          }|                     ||           |                    d          }	|	j                                         d S )	Nstart_class())
class_namedescriptionexampleparams	end_class)_resource_modelidentifiersappendnamer   r4   r5   start_sphinx_py_classr=   _add_description_add_example_add_params_descriptionend_sphinx_py_class)
r   r0   identifier_names
identifier
class_argsr:   description_sectionexample_sectionparam_sectionrA   s
             r"   r'   zResourceDocumenter._add_intro>   sM   + 	9"2> 9 9
 ''
8888 77GHH
--m<<///99J999 	0 	
 	
 	

 *99-HH1222 &55i@@/+;<<< $33H==$$]4DEEE++K88	++-----r#   c                     t          | j                  }|                    d                    || j                             d S )Nz A resource representing an {} {})r   _service_modelwriteformatr   r   r0   official_service_names      r"   rG   z#ResourceDocumenter._add_description[   sN     9$:M N N.55%t': 	
 	
 	
 	
 	
r#   c                 n   |j                                          |j                                          |                    d           |j                                          |j                                          |                    d                    | j        | j                             |j                                          t          |          }|                    d                    t          | j                  | j        | j        |                     |j         	                                 d S )Nimport boto3z{} = boto3.resource('{}')z{} = {}.{}({}))
r5   start_codeblocknew_linerS   rT   r   r   r   r   end_codeblock)r   r0   rK   example_valuess       r"   rH   zResourceDocumenter._add_examplec   s   %%'''   n%%%      )00"D$6 	
 	
 	

 	   :;KLL##4.//"#	 	
 	
 	
 	##%%%%%r#   c                    |D ]}}t          | j        |          }|                    d| d           |j                                         |                    d| d|            |j                                         ~d S )Nz:type z: stringz:param z: )r   r   rS   r5   rZ   )r   r0   rK   identifier_namer>   s        r"   rI   z*ResourceDocumenter._add_params_descriptionz   s    / 	% 	%O4#_ K MM<?<<<===M""$$$MMDODD{DDEEEM""$$$$	% 	%r#   c                 $   |j                                          |                    d| d           |j                                          |j                                          | j        |         D ]}|j                             |            d S )Nz#These are the resource's available :)r5   rZ   rS   toctree
member_maptocitem)r   r0   resource_member_typemembers       r"   _add_overview_of_member_typez/ResourceDocumenter._add_overview_of_member_type   s       J3GJJJ	
 	
 	
 	   o&:; 	/ 	/FM!!V+....	/ 	/r#   c                 ,   | j         j        j        j        }|                    d          }g }|r|| j        d<   t          |ddd           |D ])}|                    |j                   t          |j        d          }|                    d          }|j
                            | j        d	           |                    d
|j                    |                    |j                   |                    |j        d| j         di          }t!          || j        |           t$          j                            | j        | j         | j                   }|                    ||j                   +|r|                     |d           d S d S )NrC   IdentifierszYIdentifiers are properties of a resource that are set upon instantiation of the resource.identifiers_attributes_intror0   resource_typer>   
intro_linkhtmltarget
breadcrumbindexz / Identifier / 	qualifier.context)r0   resource_nameidentifier_model)	_resourcemetaresource_modelrC   r4   rb   r   rD   rE   r   r5   ref_resource_class_namerS   add_title_sectionr=   r   r   ospathjoinr   r   r   write_to_filerf   )	r   r0   rC   member_listrL   identifier_docbreadcrumb_sectionidentifier_sectionidentifiers_dir_paths	            r"   r(   z#ResourceDocumenter._add_identifiers   s   n)8D))-88 
	-8DOM*&+> :    & 	P 	PJz///.zvNNNN!/!?!?!M!M$(()BGLLL$$%I
%I%IJJJ,,Z_===!/!?!?$&;&;&;< "@ " "  *"1!+    $&7<<$%'*,$ $ 
 (()=zOOOO 	F--g}EEEEE	F 	Fr#   c           	      6   | j         j        j        j        j        }i }| j         j        j        j        rM|                    | j         j        j        j                  }| j         j        j                            |          }|                    d          }g }|rt          |ddd           || j
        d<   t          |          D ]7}||         \  }}|                    |           t          |d          }	|	                    d          }
|
j                            | j        d	           |
                    d
|            |	                    |           |	                    |d| j         di          }t)          || j        | j        || j         j        j        j        j        |           t0          j                            | j        | j         | j                   }|	                    ||           9|r|                     |d           d S d S )N
attributes
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.ri   rj   rm   rn   rp   rq   z / Attribute / rr   rs   rt   )r0   service_namerv   	attr_nameevent_emitter
attr_model)rx   ry   clientservice_modelrz   shape	shape_forget_attributesr4   r   rb   sortedrD   r   r5   r{   r|   rS   r}   r=   r   r   r   eventsr~   r   r   r   r   r   rf   )r   r0   r   r   r   attribute_listr   _
attr_shapeattribute_docr   attribute_sectionattributes_dir_paths                r"   r)   z"ResourceDocumenter._add_attributes   sd   +27E
>-3 	!++#28 E ,;JJ J )),77 	;&*/
 :
 
 
 
 -;DOL)
++ 	H 	HI&y1MAz!!),,,-iGGGM!.!>!>|!L!L$(()BGLLL$$%By%B%BCCC++I666 - = =$&;&;&;< !> ! ! )!/"1#"n18=D%    #%',,$%'*,# #
 ''(;YGGGG 	E--g|DDDDD	E 	Er#   c                     |                     d          }| j        j        j        j        }g }|rt          |ddd           || j        d<   |D ]#}|                    |j                   t          |j        d          }|                     d          }|j
                            | j        d	           |                    d
|j                    |                    |j                   |                     |j        d| j         di          }t!          ||           t"          j                            | j        | j         | j                   }|                    ||j                   %|r|                     |d           d S d S )N
references
ReferenceszNReferences are related resource instances that have a belongs-to relationship.references_introrj   rm   rn   rp   rq   z / Reference / rr   rs   rt   )r0   reference_model)r4   rx   ry   rz   r   r   rb   rD   rE   r   r5   r{   r|   rS   r}   r=   r	   r~   r   r   r   r   r   r   rf   )	r   r0   r   reference_list	referencereference_docr   reference_sectionreferences_dir_paths	            r"   r*   z"ResourceDocumenter._add_references   s   )),77^(7B
 
	;&*1 .    -;DOL)# 	M 	MI!!).111-inVLLLM!.!>!>|!L!L$(()BGLLL$$%Gy~%G%GHHH++IN;;; - = =$&;&;&;< !> ! ! ) )    #%',,$%'*,# #
 ''(;Y^LLLL 	E--g|DDDDD	E 	Er#   c                    |                     d          }| j        j        j        j        }|rSt          | j        | j                  }| j        |_        |                    |           | 	                    |d           d S d S )Nactions)
r4   rx   ry   rz   r   r   r   rb   document_actionsrf   )r   r0   r   
documenters       r"   r+   zResourceDocumenter._add_actions  s    )))44.%4< 	B)$.$:NOOJ$(OJ!''000--gyAAAAA		B 	Br#   c                    |                     d          }| j        j        j        j        }|rSt          | j        | j                  }| j        |_        |                    |           | 	                    |d           d S d S )Nzsub-resources)
r4   rx   ry   rz   subresourcesr   r   rb   document_sub_resourcesrf   )r   r0   sub_resourcesr   s       r"   r,   z%ResourceDocumenter._add_sub_resources&  s    ))/::+:G 	H. 4 J %)OJ!--g666--gGGGGG	H 	Hr#   c                    |                     d          }| j        j        j        j        }|rSt          | j        | j                  }| j        |_        |                    |           | 	                    |d           d S d S )Ncollections)
r4   rx   ry   rz   r   r   r   rb   document_collectionsrf   )r   r0   r   r   s       r"   r-   z#ResourceDocumenter._add_collections1  s    ))-88n)8D 	F- 4 J %)OJ!++G444--g}EEEEE	F 	Fr#   c                 F   |                     d          }| j        j        j        j        }|rs| j                            | j                  }t          | j        || j	                  }| j
        |_
        |                    |           |                     |d           d S d S )Nwaiters)r4   rx   ry   rz   r   r   get_waiter_modelr   r   r   rb   document_resource_waitersrf   )r   r0   r   service_waiter_modelr   s        r"   r.   zResourceDocumenter._add_waiters<  s    )))44.%4< 		B#'#9#J#J"$ $  2 4d6J J %)OJ!00999--gyAAAAA		B 		Br#   c                     |                     d          }|j                                         |                    d           |j                                         d S )Nzfeature-freezezBefore using anything on this page, please refer to the resources :doc:`user guide <../../../../guide/resources>` for the most recent guidance on using resources.)r4   r5   
start_noterS   end_noter/   s     r"   r&   z%ResourceDocumenter._add_resource_noteJ  sa    ))*:;;  """+	
 	
 	

 	     r#   )__name__
__module____qualname__r   r1   r%   r'   rG   rH   rI   rf   r(   r)   r*   r+   r,   r-   r.   r&   __classcell__)r!   s   @r"   r   r   %   s1       9 9 9 9 9
# 
# 
#4 4 4. . .:
 
 
& & &.% % %/ / /*F *F *FX7E 7E 7Er(E (E (ETB B B	H 	H 	H	F 	F 	FB B B! ! ! ! ! ! !r#   r   c                   6    e Zd Zed             Zd Zd Zd ZdS )ServiceResourceDocumenterc                     | j          dS )Nz.ServiceResource)_service_docs_name)r   s    r"   r=   z$ServiceResourceDocumenter.class_nameV  s    );;;;r#   c                 d    |                     d          }|j                            d           d S )Nr3   zService Resource)r4   r5   r6   r7   s      r"   r%   z$ServiceResourceDocumenter._add_titleZ  s3    //88122222r#   c                 ^    t          | j                  }|                    d|            d S )NzA resource representing )r   rR   rS   rU   s      r"   rG   z*ServiceResourceDocumenter._add_description^  s5     9$:M N NH1FHHIIIIIr#   c                 t   |j                                          |j                                          |                    d           |j                                          |j                                          |                    | j         d| j         d           |j                                          d S )NrX   z = boto3.resource('z'))r5   rY   rZ   rS   r   r[   )r   r0   rK   s      r"   rH   z&ServiceResourceDocumenter._add_exampleb  s    %%'''   n%%%      !NNt7INNN	
 	
 	
 	##%%%%%r#   N)r   r   r   propertyr=   r%   rG   rH    r#   r"   r   r   U  s]        < < X<3 3 3J J J	& 	& 	& 	& 	&r#   r   )r~   botocorer   botocore.docs.bcdoc.restdocr   botocore.docs.utilsr   boto3.docs.actionr   boto3.docs.attrr   r   r	   boto3.docs.baser
   boto3.docs.collectionr   boto3.docs.subresourcer   boto3.docs.utilsr   r   r   r   boto3.docs.waiterr   r   r   r   r#   r"   <module>r      sz   
			       9 9 9 9 9 9 9 9 9 9 9 9 . . . . . .         
 + * * * * * 6 6 6 6 6 6 8 8 8 8 8 8            7 6 6 6 6 6m! m! m! m! m! m! m! m!`	& & & & & 2 & & & & &r#   