|
27 | 27 | TeamsMeetingParticipant, |
28 | 28 | MeetingNotificationBase, |
29 | 29 | MeetingNotificationResponse, |
| 30 | + BatchFailedEntriesResponse, |
| 31 | + BatchOperationState, |
| 32 | + TeamMember, |
30 | 33 | ) |
31 | 34 |
|
32 | 35 |
|
@@ -137,6 +140,111 @@ async def _create_conversation_callback( |
137 | 140 | ) |
138 | 141 | return (conversation_reference, new_activity_id) |
139 | 142 |
|
| 143 | + @staticmethod |
| 144 | + async def send_message_to_list_of_users( |
| 145 | + turn_context: TurnContext, |
| 146 | + activity: Activity, |
| 147 | + teams_members: List["TeamMember"], |
| 148 | + tenant_id: str, |
| 149 | + ) -> str: |
| 150 | + """Sends a message to the provided list of Teams members.""" |
| 151 | + if activity is None: |
| 152 | + raise ValueError("activity is required.") |
| 153 | + if not teams_members: |
| 154 | + raise ValueError("teamsMembers is required.") |
| 155 | + if not tenant_id: |
| 156 | + raise ValueError("tenantId is required.") |
| 157 | + |
| 158 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 159 | + return await connector_client.teams.send_message_to_list_of_users( |
| 160 | + activity, teams_members, tenant_id |
| 161 | + ) |
| 162 | + |
| 163 | + @staticmethod |
| 164 | + async def send_message_to_all_users_in_tenant( |
| 165 | + turn_context: TurnContext, activity: Activity, tenant_id: str |
| 166 | + ) -> str: |
| 167 | + """Sends a message to all the users in a tenant.""" |
| 168 | + if activity is None: |
| 169 | + raise ValueError("activity is required.") |
| 170 | + if not tenant_id: |
| 171 | + raise ValueError("tenantId is required.") |
| 172 | + |
| 173 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 174 | + return await connector_client.teams.send_message_to_all_users_in_tenant( |
| 175 | + activity, tenant_id |
| 176 | + ) |
| 177 | + |
| 178 | + @staticmethod |
| 179 | + async def send_message_to_all_users_in_team( |
| 180 | + turn_context: TurnContext, activity: Activity, team_id: str, tenant_id: str |
| 181 | + ) -> str: |
| 182 | + """Sends a message to all the users in a team.""" |
| 183 | + if activity is None: |
| 184 | + raise ValueError("activity is required.") |
| 185 | + if not team_id: |
| 186 | + raise ValueError("teamId is required.") |
| 187 | + if not tenant_id: |
| 188 | + raise ValueError("tenantId is required.") |
| 189 | + |
| 190 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 191 | + return await connector_client.teams.send_message_to_all_users_in_team( |
| 192 | + activity, team_id, tenant_id |
| 193 | + ) |
| 194 | + |
| 195 | + @staticmethod |
| 196 | + async def send_message_to_list_of_channels( |
| 197 | + turn_context: TurnContext, |
| 198 | + activity: Activity, |
| 199 | + channels_members: List["TeamMember"], |
| 200 | + tenant_id: str, |
| 201 | + ) -> str: |
| 202 | + """Sends a message to the provided list of Teams channels.""" |
| 203 | + if activity is None: |
| 204 | + raise ValueError("activity is required.") |
| 205 | + if not channels_members: |
| 206 | + raise ValueError("channelsMembers is required.") |
| 207 | + if not tenant_id: |
| 208 | + raise ValueError("tenantId is required.") |
| 209 | + |
| 210 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 211 | + return await connector_client.teams.send_message_to_list_of_channels( |
| 212 | + activity, channels_members, tenant_id |
| 213 | + ) |
| 214 | + |
| 215 | + @staticmethod |
| 216 | + async def get_operation_state( |
| 217 | + turn_context: TurnContext, operation_id: str |
| 218 | + ) -> BatchOperationState: |
| 219 | + """Gets the state of an operation.""" |
| 220 | + if not operation_id: |
| 221 | + raise ValueError("operationId is required.") |
| 222 | + |
| 223 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 224 | + return await connector_client.teams.get_operation_state(operation_id) |
| 225 | + |
| 226 | + @staticmethod |
| 227 | + async def get_paged_failed_entries( |
| 228 | + turn_context: TurnContext, operation_id: str, continuation_token: str = None |
| 229 | + ) -> BatchFailedEntriesResponse: |
| 230 | + """Gets the failed entries of a batch operation.""" |
| 231 | + if not operation_id: |
| 232 | + raise ValueError("operationId is required.") |
| 233 | + |
| 234 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 235 | + return await connector_client.teams.get_paged_failed_entries( |
| 236 | + operation_id, continuation_token |
| 237 | + ) |
| 238 | + |
| 239 | + @staticmethod |
| 240 | + async def cancel_operation(turn_context: TurnContext, operation_id: str) -> None: |
| 241 | + """Cancels a batch operation by its id.""" |
| 242 | + if not operation_id: |
| 243 | + raise ValueError("operationId is required.") |
| 244 | + |
| 245 | + connector_client = await TeamsInfo.get_teams_connector_client(turn_context) |
| 246 | + await connector_client.teams.cancel_operation(operation_id) |
| 247 | + |
140 | 248 | @staticmethod |
141 | 249 | async def get_team_details( |
142 | 250 | turn_context: TurnContext, team_id: str = "" |
|
0 commit comments