o
    ,ifW	                     @   s   d dl mZmZ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 d dlmZ d dlmZ er:d dlmZ ed	ZG d
d de	e ZdS )    )TYPE_CHECKINGAnyOptionalTypeTypeVar)Entity)ClientObjectCollection)is_string_type)ResourcePath)
EntityPath)CreateEntityQuery)GraphClientTc                       sP   e Zd ZdZd fdd	Z fddZdd Zd fd	d
	Zedd Z	  Z
S )EntityCollectionzGA collection container which represents a named collections of entitiesNc                    s   t t| |||| d S N)superr   __init__)selfcontext	item_typeresource_pathparent	__class__ T/var/www/html/corbot_env/lib/python3.10/site-packages/office365/entity_collection.pyr      s   
zEntityCollection.__init__c                    s>   t |trtt| |S t|r| jt|| jdS t	d)z
        :param key: key is used to address an entity by either an index or by identifier
        :type key: int or str
        )r   zFInvalid key: expected either an entity index [int] or identifier [str])

isinstanceintr   r   __getitem__r	   create_typed_objectr   r   
ValueError)r   keyr   r   r   r      s   

zEntityCollection.__getitem__c                 K   s:   |  |td| j}| | t| ||}| j| |S )z(Creates an entity and prepares the queryN)r   r   r   	add_childr   r   	add_query)r   kwargsreturn_typeqryr   r   r   add*   s   
zEntityCollection.addc                    s&   |d u r
t d | j}tt| ||S r   )r   r   r   r   r   )r   initial_propertiesr   r   r   r   r   5   s
   
z$EntityCollection.create_typed_objectc                 C   s   | j S r   )_context)r   r   r   r   r   =   s   zEntityCollection.context)NN)__name__
__module____qualname____doc__r   r   r'   r   propertyr   __classcell__r   r   r   r   r      s    r   N)typingr   r   r   r   r   office365.entityr   *office365.runtime.client_object_collectionr   office365.runtime.compatr	   %office365.runtime.paths.resource_pathr
   !office365.runtime.paths.v4.entityr   'office365.runtime.queries.create_entityr   office365.graph_clientr   r   r   r   r   r   r   <module>   s    