o
    ,ifk/                     @   s   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 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 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Z$dS )    )Optional)ResourceSpecificPermissionGrant)Entity)EntityCollection)ResourcePath)ServiceOperationQuery)TeamsAppInstallation)Channel)ChannelCollection)TeamFunSettings)TeamGuestSettings)TeamMemberSettings)TeamMessagingSettings)TeamsAsyncOperation)Schedule)TeamSummary)TeamworkTag)TeamsTemplatec                       s  e Zd ZdZdd Zdd Zdd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zed d! Zed"d# Zed$d% Zed&d' Zed(d) Zed*d+ Zed,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Zed6d7 Zd8d9 Z d:d; Z!d<d= Z"d>d? Z#dF fdAdB	Z$dG fdDdE	Z%  Z&S )HTeamzA team in Microsoft Teams is a collection of channel objects. A channel represents a topic, and therefore a
    logical isolation of discussion, within a team.c                 C   s   | j S N)display_nameself r   M/var/www/html/corbot_env/lib/python3.10/site-packages/office365/teams/team.py__str__   s   zTeam.__str__c                    s&    fdd}  d|  j   S )zX
        Submit request(s) to the server and waits until operation is completed
        c                      s    j d jdd d S )Nr   	succeeded)status_type)
operationspoll_for_statusr   r   r   r   _loaded$   s   z,Team.execute_query_and_wait.<locals>._loadedid)ensure_propertycontextexecute_query)r   r    r   r   r   execute_query_and_wait   s   
zTeam.execute_query_and_waitc                    s    fdd}  d|  S )zDeletes a teamc                     s    j j j } | d d S )NF)r#   groupsr!   delete_object)groupr   r   r   _team_loaded/   s   z(Team.delete_object.<locals>._team_loadedr!   )r"   )r   r)   r   r   r   r'   ,   s   zTeam.delete_objectc                 C      | j dt S )zDSettings to configure use of Giphy, memes, and stickers in the team.funSettings)
propertiesgetr   r   r   r   r   fun_settings6      zTeam.fun_settingsc                 C   r*   )zSettings to configure whether members can perform certain actions, for example,
        create channels and add bots, in the team.memberSettings)r,   r-   r   r   r   r   r   member_settings;   s   zTeam.member_settingsc                 C   r*   )zXSettings to configure whether guests can create, update, or delete channels in the team.guestSettings)r,   r-   r   r   r   r   r   guest_settingsA   r/   zTeam.guest_settingsc                 C   r*   )z9Settings to configure messaging and mentions in the team.r2   )r,   r-   r   r   r   r   r   messaging_settingsF   r/   zTeam.messaging_settingsc                 C      | j ddS )zThe name of the team.displayNameNr,   r-   r   r   r   r   r   K      zTeam.display_namec                 C   r5   )z%An optional description for the team.descriptionNr7   r   r   r   r   r9   Q   r8   zTeam.descriptionc                 C   r5   )zAn optional label. Typically describes the data or business sensitivity of the team.
        Must match one of a pre-configured set in the tenant's directory.
        classificationNr7   r   r   r   r   r:   W      zTeam.classificationc                 C   r5   )z'Whether this team is in read-only mode.
isArchivedNr7   r   r   r   r   is_archived_   r8   zTeam.is_archivedc                 C   r5   )z9The visibility of the group and team. Defaults to Public.
visibilityNr7   r   r   r   r   r>   e      zTeam.visibilityc                 C   r5   )a  A hyperlink that will go to the team in the Microsoft Teams client. This is the URL that you get when
        you right-click a team in the Microsoft Teams client and select Get link to team. This URL should be treated
        as an opaque blob, and not parsed.webUrlNr7   r   r   r   r   web_urlj   r;   zTeam.web_urlc                 C   r5   )z(Timestamp at which the team was created.createdDateTimeNr7   r   r   r   r   created_datetimer   r?   zTeam.created_datetimec                 C      | j dt| jtd| jS )z`
        List of channels either hosted in or shared with the team (incoming channels).
        allChannelsr,   r-   r
   r#   r   resource_pathr   r   r   r   all_channelsw   s   zTeam.all_channelsc                 C   rD   )z&List of channels shared with the team.incomingChannelsrF   r   r   r   r   incoming_channels      zTeam.incoming_channelsc                 C   rD   )z?The collection of channels & messages associated with the team.channelsrF   r   r   r   r   rL      rK   zTeam.channelsc                 C   s*   ddl m} | jd|| jtd| jS ) r   )Groupr(   ) office365.directory.groups.grouprN   r,   r-   r#   r   rG   )r   rN   r   r   r   r(      s   z
Team.groupc                 C   rD   )z!The general channel for the team.primaryChannel)r,   r-   r	   r#   r   rG   r   r   r   r   primary_channel   s   zTeam.primary_channelc                 C   rD   )z%The schedule of shifts for this team.schedule)r,   r-   r   r#   r   rG   r   r   r   r   rR         zTeam.schedulec              	   C       | j dt| jttd| jS )z The apps installed in this team.installedApps)r,   r-   r   r#   r   r   rG   r   r   r   r   installed_apps      
zTeam.installed_appsc              	   C   rT   )z:The async operations that ran or are running on this team.r   )r,   
setdefaultr   r#   r   r   rG   r   r   r   r   r      rW   zTeam.operationsc                 C   s   | j dt| jttdS )z>
        List all resource-specific permission grants
        permissionGrants)r,   rX   r   r#   r   r   r   r   r   r   permission_grants   s   zTeam.permission_grantsc                 C   r*   )z]Contains summary information about the team, including number of owners, members, and guests.summary)r,   r-   r   r   r   r   r   r[      r/   zTeam.summaryc                 C   r5   )z,The ID of the Azure Active Directory tenant.tenantIdNr7   r   r   r   r   	tenant_id   r8   zTeam.tenant_idc              	   C   rT   )z"The tags associated with the team.tags)r,   r-   r   r#   r   r   rG   r   r   r   r   r^      s   z	Team.tagsc                 C   rD   )z'The template this team was created fromtemplate)r,   r-   r   r#   r   rG   r   r   r   r   r_      rS   zTeam.templatec                 C      t | d}| j| | S )a$  Archive the specified team. When a team is archived, users can no longer send or like messages on any
        channel in the team, edit the team's name, description, or other settings, or in general make most changes to
        the team. Membership changes to the team continue to be allowed.archiver   r#   	add_queryr   qryr   r   r   ra      s   
zTeam.archivec                 C   r`   )zRestore an archived team. This restores users' ability to send messages and edit the team, abiding by
        tenant and team settings.	unarchiverb   rd   r   r   r   rf     s   
zTeam.unarchivec                 C   r`   )zWCreate a copy of a team. This operation also creates a copy of the corresponding group.clonerb   rd   r   r   r   rg   	  s   
z
Team.clonec           	      C   s0   ||||||d}t | dd|}| j| | S )a  
        Send an activity feed notification in the scope of a team.
        For more details about sending notifications and the requirements for doing so,
        see sending Teams activity notifications:
        https://docs.microsoft.com/en-us/graph/teams-send-activityfeednotifications

        :param teamworkActivityTopic topic: Topic of the notification. Specifies the resource being talked about.
        :param str activity_type: Activity type. This must be declared in the Teams app manifest.
        :param str chain_id: Optional. Used to override a previous notification. Use the same chainId in subsequent
            requests to override the previous notification.
        :param str preview_text: Preview text for the notification. Microsoft Teams will only show first 150 characters
        :param dict template_parameters: Values for template variables defined in the activity feed entry corresponding
            to activityType in Teams app manifest.
        :param dict template_parameters: Recipient of the notification.
             Only Azure AD users are supported.
        :param teamworkNotificationRecipient recipient: Recipient of the notification
        )topicactivityTypechainIdpreviewTexttemplateParameters	recipientsendActivityNotificationNrb   )	r   rh   activity_typechain_idpreview_texttemplate_parametersrm   payloadre   r   r   r   send_activity_notification  s   zTeam.send_activity_notificationNc                    s@   |d u r| j | j| j| j| jd}||d }tt| ||S )N)rE   rI   rU   rY   rP   )	rH   rJ   rV   rZ   rQ   r-   superr   get_property)r   namedefault_valueproperty_mapping	__class__r   r   rv   5  s   zTeam.get_propertyTc                    s<   t t| ||| |dkr| jjdkrt|td| _| S )Nr!   teamteams)ru   r   set_property_resource_pathsegmentr   )r   rw   valuepersist_changesrz   r   r   r~   A  s   zTeam.set_propertyr   )T)'__name__
__module____qualname____doc__r   r%   r'   propertyr.   r1   r3   r4   r   r9   r:   r=   r>   rA   rC   rH   rJ   rL   r(   rQ   rR   rV   r   rZ   r[   r]   r^   r_   ra   rf   rg   rt   rv   r~   __classcell__r   r   rz   r   r      sv    

























	
&r   N)%typingr   8office365.directory.permissions.grants.resource_specificr   office365.entityr   office365.entity_collectionr   %office365.runtime.paths.resource_pathr   +office365.runtime.queries.service_operationr   !office365.teams.apps.installationr    office365.teams.channels.channelr	   #office365.teams.channels.collectionr
   office365.teams.fun_settingsr   office365.teams.guest_settingsr    office365.teams.members.settingsr   "office365.teams.messaging_settingsr   *office365.teams.operations.async_operationr   !office365.teams.schedule.scheduler   office365.teams.summaryr   !office365.teams.teamwork.tags.tagr   office365.teams.templater   r   r   r   r   r   <module>   s&    