o
    ,if.
                     @   s   d dl mZ 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 G d
d dee ZdS )    )CallableN)Self)EntityCollection)ODataPathBuilder)ResourcePath)CreateEntityQuery)TeamsAsyncOperation)Teamc                       s6   e Zd ZdZd	 fdd	Zd
ddZd	ddZ  ZS )TeamCollectionzTeam's collectionNc                    s   t t| |t| d S N)superr
   __init__r	   )selfcontextresource_path	__class__ S/var/www/html/corbot_env/lib/python3.10/site-packages/office365/teams/collection.pyr      s   zTeamCollection.__init__c                    s"    fdd} j jj||d  S )z5List all teams in Microsoft Teams for an organizationc                    s\   | D ])}d|j d v r+t jt|j j}|j  D ]
\}}||| q | qd S )Nr	   resourceProvisioningOptions)	
propertiesr	   r   r   idr   itemsset_property	add_child)groupsgrpteamkvr   r   r   _init_teams   s   
z+TeamCollection.get_all.<locals>._init_teams)page_loaded)r   r   get_all)r   	page_sizer"   r!   r   r    r   r#      s   	zTeamCollection.get_allc                    sP   t j    fdd}||dd}t| }j||  S )zCreate a new team.

        This is async operation.

        :param str display_name: The name of the team.
        :param str or None description: An optional description for the team. Maximum length: 1024 characters.
        c                    s\   | j dd }t|} d|jd | j dd }t|}tj|} j	| d S )NzContent-Locationr   FLocation)
headersgetr   	parse_urlr   segmentr   r   
operationsr   )respcontent_loc	team_pathlocoperation_path	operationreturn_typer   r   r   _process_response/   s   

z0TeamCollection.create.<locals>._process_responsez;https://graph.microsoft.com/v1.0/teamsTemplates('standard'))displayNamedescriptionztemplate@odata.bind)r	   r   r   r   	add_queryafter_execute)r   display_namer5   r3   payloadqryr   r1   r   create$   s   

zTeamCollection.creater   )NN)__name__
__module____qualname____doc__r   r#   r;   __classcell__r   r   r   r   r
      s
    
r
   )typingr   requeststyping_extensionsr   office365.entity_collectionr   office365.runtime.paths.builderr   %office365.runtime.paths.resource_pathr   'office365.runtime.queries.create_entityr   *office365.teams.operations.async_operationr   office365.teams.teamr	   r
   r   r   r   r   <module>   s    