U
    Y+d+                     @   s   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
 d dlmZ d dlmZmZ G d	d
 d
e
ZdddZdddZdddZdS )    N)
xform_name)DocumentStructure)get_instance_public_methods)DocumentedShape)NestedDocumenter)%document_model_driven_resource_method)add_resource_type_overviewget_resource_ignore_paramsc                   @   s   e Zd Zdd Zdd ZdS )CollectionDocumenterc                 C   s   | j jjj}g }t|dddd || jd< |D ]j}||j t|jdd}|	|j |
|j}| || tj| j| j | j }|||j q.d S )NZCollectionszUCollections provide an interface to iterate over and manipulate groups of resources. Zguide_collections)sectionZresource_typedescriptionZ
intro_linkcollectionshtml)target)	_resourcemetaZresource_modelr   r   
member_mapappendnamer   Zadd_title_sectionadd_new_section_document_collectionospathjoinZ_root_docs_pathZ_service_nameZ_resource_sub_pathZwrite_to_file)selfr   r   Zcollections_list
collectionZcollection_docZcollection_sectionZcollections_dir_path r   9/tmp/pip-unpacked-wheel-9vn2nznc/boto3/docs/collection.pydocument_collections   s.    	
z)CollectionDocumenter.document_collectionsc              	   C   s   t t| j|j}t|| i }|jD ]}|||j< q&t|D ]p}||}||krt|| j	| jj
jj
j|| || jj
jj
jd q>t|| j	|| jj
jj
j|| jj
jj
jd q>d S )N)r   resource_nameevent_emitterbatch_action_modelcollection_modelservice_model)r   r   action_namer    r"   r#   )r   getattrr   r   document_collection_objectbatch_actionssortedr   document_batch_actionZ_resource_namer   clienteventsr#   document_collection_method)r   r   r   methodsr'   Zbatch_actionmethodZmethod_sectionr   r   r   r   =   s4    


	z)CollectionDocumenter._document_collectionN)__name__
__module____qualname__r   r   r   r   r   r   r
      s    r
   Tc                 C   sB   |r| j |j | d|jj d | d|jj d dS )a
  Documents a collection resource object

    :param section: The section to write to

    :param collection_model: The model of the collection

    :param include_signature: Whether or not to include the signature.
        It is useful for generating docstrings.
    zA collection of z resources.zA z Collection will include all resources by default, and extreme caution should be taken when performing actions on all resources.N)styleZstart_sphinx_py_attrr   Zinclude_doc_stringresourcetype)r   r"   include_signaturer   r   r   r&   \   s    r&   c                 C   s|   | |jj}t|jj}d}	|jr0t|jj}	t|}
|j|krF|}
d	|	|
|j
|j
}t| |j
|||j||||d	 dS )ai  Documents a collection's batch action

    :param section: The section to write to

    :param resource_name: The name of the resource

    :param action_name: The name of collection action. Currently only
        can be all, filter, limit, or page_size

    :param event_emitter: The event emitter to use to emit events

    :param batch_action_model: The model of the batch action

    :param collection_model: The model of the collection

    :param service_model: The model of the service

    :param include_signature: Whether or not to include the signature.
        It is useful for generating docstrings.
    responsez{} = {}.{}.{})	r   method_nameoperation_modelr    method_descriptionexample_prefixexclude_inputresource_action_modelr5   N)r8   request	operationr	   paramsr3   r   r4   service_nameformatr   r   documentation)r   r   r    r!   r#   r"   r5   r8   Zignore_paramsZexample_return_valueexample_resource_namer:   r   r   r   r)   t   s:    
r)   c              
   C   sD  | |jj}g }|jr |jj}t|}	|j|kr6|}	d|jj dd	t|jj|	|j
|dd|jj d|jj dd	t|jj|	|j
t|jjdd|jj dd		t|jj|	|j
td
dddg|dd|jj dd	t|jj|	|j
td
dddg|dd}
||
kr@|
| }tf | |||||d| dS )a#  Documents a collection method

    :param section: The section to write to

    :param resource_name: The name of the resource

    :param action_name: The name of collection action. Currently only
        can be all, filter, limit, or page_size

    :param event_emitter: The event emitter to use to emit events

    :param collection_model: The model of the collection

    :param service_model: The model of the service

    :param include_signature: Whether or not to include the signature.
        It is useful for generating docstrings.
    zCreates an iterable of all z resources in the collection.z{}_iterator = {}.{}.all)r9   r:   r;   zD resources in the collection filtered by kwargs passed to method. A z collection will include all resources by default if no filters are provided, and extreme caution should be taken when performing actions on all resources.z{}_iterator = {}.{}.filterz0Creates an iterable up to a specified amount of z{}_iterator = {}.{}.limitcountintegerz5The limit to the number of resources in the iterable.)r   	type_namerB   )r9   r:   Zinclude_inputr;   zs resources in the collection, but limits the number of items returned by each service call by the specified amount.z{}_iterator = {}.{}.page_sizez1The number of items returned by each service call)allfilterlimitZ	page_size)r   r7   r8   r    r<   r5   N)r8   r=   r>   Zinput_shapemembersr   r@   r3   r4   rA   r   r	   r?   r   r   )r   r   r$   r    r"   r#   r5   r8   Zunderlying_operation_membersrC   Zcustom_action_info_dictZaction_infor   r   r   r,      s    





	L
r,   )T)T)T)r   Zbotocorer   Zbotocore.docs.bcdoc.restdocr   Zbotocore.docs.methodr   Zbotocore.docs.utilsr   Zboto3.docs.baser   Zboto3.docs.methodr   Zboto3.docs.utilsr   r	   r
   r&   r)   r,   r   r   r   r   <module>   s   A 
 
E 