microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
samples/migration-bot

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

core/src/Microsoft.Teams.Bot.Apps/Api/MeetingsApi.cs

166lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Bot.Apps.Schema;
5using Microsoft.Teams.Bot.Core.Schema;
6
7namespace Microsoft.Teams.Bot.Apps.Api;
8
9using CustomHeaders = Dictionary<string, string>;
10
11/// <summary>
12/// Provides meeting operations for managing Teams meetings.
13/// </summary>
14public class MeetingsApi
15{
16 private readonly TeamsApiClient _client;
17
18 /// <summary>
19 /// Initializes a new instance of the <see cref="MeetingsApi"/> class.
20 /// </summary>
21 /// <param name="teamsApiClient">The Teams API client for meeting operations.</param>
22 internal MeetingsApi(TeamsApiClient teamsApiClient)
23 {
24 _client = teamsApiClient;
25 }
26
27 /// <summary>
28 /// Gets information about a meeting.
29 /// </summary>
30 /// <param name="meetingId">The ID of the meeting, encoded as a BASE64 string.</param>
31 /// <param name="serviceUrl">The service URL for the Teams service.</param>
32 /// <param name="agenticIdentity">Optional agentic identity for authentication.</param>
33 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
34 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
35 /// <returns>A task that represents the asynchronous operation. The task result contains the meeting information.</returns>
36 public Task<MeetingInfo> GetByIdAsync(
37 string meetingId,
38 Uri serviceUrl,
39 AgenticIdentity? agenticIdentity = null,
40 CustomHeaders? customHeaders = null,
41 CancellationToken cancellationToken = default)
42 => _client.FetchMeetingInfoAsync(meetingId, serviceUrl, agenticIdentity, customHeaders, cancellationToken);
43
44 /// <summary>
45 /// Gets information about a meeting using activity context.
46 /// </summary>
47 /// <param name="meetingId">The ID of the meeting, encoded as a BASE64 string.</param>
48 /// <param name="activity">The activity providing service URL and identity context.</param>
49 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
50 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
51 /// <returns>A task that represents the asynchronous operation. The task result contains the meeting information.</returns>
52 public Task<MeetingInfo> GetByIdAsync(
53 string meetingId,
54 TeamsActivity activity,
55 CustomHeaders? customHeaders = null,
56 CancellationToken cancellationToken = default)
57 {
58 ArgumentNullException.ThrowIfNull(activity);
59 ArgumentNullException.ThrowIfNull(activity.ServiceUrl);
60
61 return _client.FetchMeetingInfoAsync(
62 meetingId,
63 activity.ServiceUrl,
64 activity.From?.GetAgenticIdentity(),
65 customHeaders,
66 cancellationToken);
67 }
68
69 /// <summary>
70 /// Gets details for a meeting participant.
71 /// </summary>
72 /// <param name="meetingId">The ID of the meeting.</param>
73 /// <param name="participantId">The ID of the participant.</param>
74 /// <param name="tenantId">The ID of the tenant.</param>
75 /// <param name="serviceUrl">The service URL for the Teams service.</param>
76 /// <param name="agenticIdentity">Optional agentic identity for authentication.</param>
77 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
78 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
79 /// <returns>A task that represents the asynchronous operation. The task result contains the participant details.</returns>
80 public Task<MeetingParticipant> GetParticipantAsync(
81 string meetingId,
82 string participantId,
83 string tenantId,
84 Uri serviceUrl,
85 AgenticIdentity? agenticIdentity = null,
86 CustomHeaders? customHeaders = null,
87 CancellationToken cancellationToken = default)
88 => _client.FetchParticipantAsync(meetingId, participantId, tenantId, serviceUrl, agenticIdentity, customHeaders, cancellationToken);
89
90 /// <summary>
91 /// Gets details for a meeting participant using activity context.
92 /// </summary>
93 /// <param name="meetingId">The ID of the meeting.</param>
94 /// <param name="participantId">The ID of the participant.</param>
95 /// <param name="activity">The activity providing service URL, tenant ID, and identity context.</param>
96 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
97 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
98 /// <returns>A task that represents the asynchronous operation. The task result contains the participant details.</returns>
99 public Task<MeetingParticipant> GetParticipantAsync(
100 string meetingId,
101 string participantId,
102 TeamsActivity activity,
103 CustomHeaders? customHeaders = null,
104 CancellationToken cancellationToken = default)
105 {
106 ArgumentNullException.ThrowIfNull(activity);
107 ArgumentNullException.ThrowIfNull(activity.ServiceUrl);
108 string? tenantId = activity.ChannelData?.Tenant?.Id;
109 ArgumentException.ThrowIfNullOrWhiteSpace(tenantId, "activity.ChannelData.Tenant.Id");
110 return _client.FetchParticipantAsync(
111 meetingId,
112 participantId,
113 tenantId,
114 activity.ServiceUrl,
115 activity.From?.GetAgenticIdentity(),
116 customHeaders,
117 cancellationToken);
118 }
119
120 /// <summary>
121 /// Sends a notification to meeting participants.
122 /// </summary>
123 /// <param name="meetingId">The ID of the meeting.</param>
124 /// <param name="notification">The notification to send.</param>
125 /// <param name="serviceUrl">The service URL for the Teams service.</param>
126 /// <param name="agenticIdentity">Optional agentic identity for authentication.</param>
127 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
128 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
129 /// <returns>A task that represents the asynchronous operation. The task result contains information about failed recipients.</returns>
130 public Task<MeetingNotificationResponse> SendNotificationAsync(
131 string meetingId,
132 TargetedMeetingNotification notification,
133 Uri serviceUrl,
134 AgenticIdentity? agenticIdentity = null,
135 CustomHeaders? customHeaders = null,
136 CancellationToken cancellationToken = default)
137 => _client.SendMeetingNotificationAsync(meetingId, notification, serviceUrl, agenticIdentity, customHeaders, cancellationToken);
138
139 /// <summary>
140 /// Sends a notification to meeting participants using activity context.
141 /// </summary>
142 /// <param name="meetingId">The ID of the meeting.</param>
143 /// <param name="notification">The notification to send.</param>
144 /// <param name="activity">The activity providing service URL and identity context.</param>
145 /// <param name="customHeaders">Optional custom headers to include in the request.</param>
146 /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
147 /// <returns>A task that represents the asynchronous operation. The task result contains information about failed recipients.</returns>
148 public Task<MeetingNotificationResponse> SendNotificationAsync(
149 string meetingId,
150 TargetedMeetingNotification notification,
151 TeamsActivity activity,
152 CustomHeaders? customHeaders = null,
153 CancellationToken cancellationToken = default)
154 {
155 ArgumentNullException.ThrowIfNull(activity);
156 ArgumentNullException.ThrowIfNull(activity.ServiceUrl);
157
158 return _client.SendMeetingNotificationAsync(
159 meetingId,
160 notification,
161 activity.ServiceUrl,
162 activity.From?.GetAgenticIdentity(),
163 customHeaders,
164 cancellationToken);
165 }
166}
167