Skip to content

Commit cc1f383

Browse files
Jimin/2025 ga (Azure#50191)
* autorest generated code * Apply outer models change * client changes * e2e tests pass * record tests * Update sdk/communication/Azure.Communication.Chat/src/ChatClient.cs Co-authored-by: Copilot <[email protected]> * regen code * Update samples * Update readme for samples * Comments on source code * update tests * Update recordings * fix model factory * rm factory method * update api --------- Co-authored-by: Copilot <[email protected]>
1 parent 2594095 commit cc1f383

37 files changed

+1476
-91
lines changed

sdk/communication/Azure.Communication.Chat/README.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ Once you initialized a `ChatClient` class, you can do the following chat operati
6565

6666
### Create a thread
6767
```C# Snippet:Azure_Communication_Chat_Tests_Samples_CreateThread_KeyConcepts
68-
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(topic: "Hello world!", participants: new ChatParticipant[] { });
68+
CreateChatThreadOptions createChatThreadOptions = new CreateChatThreadOptions("Hello world!");
69+
70+
createChatThreadOptions.Metadata.Add("MetadataKey1", "MetadataValue1");
71+
createChatThreadOptions.Metadata.Add("MetadataKey2", "MetadataValue2");
72+
73+
createChatThreadOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(40);
74+
75+
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(createChatThreadOptions);
6976
ChatThreadProperties chatThread = createChatThreadResult.ChatThread;
7077
```
7178
### Get a thread
@@ -85,9 +92,14 @@ Once you initialized a `ChatThreadClient` class, you can do the following chat o
8592

8693
### Update a thread
8794
```C# Snippet:Azure_Communication_Chat_Tests_Samples_UpdateThread_KeyConcepts
88-
chatThreadClient.UpdateTopic(topic: "Launch meeting");
89-
```
95+
UpdateChatThreadPropertiesOptions updateChatThreadPropertiesOptions = new UpdateChatThreadPropertiesOptions();
96+
updateChatThreadPropertiesOptions.Topic = "Launch meeting";
97+
updateChatThreadPropertiesOptions.Metadata.Add("UpdateMetadataKey", "UpdateMetadataValue");
9098

99+
updateChatThreadPropertiesOptions.RetentionPolicy = new NoneRetentionPolicy();
100+
101+
await chatThreadClient.UpdatePropertiesAsync(updateChatThreadPropertiesOptions);
102+
```
91103
### Send a message
92104
```C# Snippet:Azure_Communication_Chat_Tests_Samples_SendMessage_KeyConcepts
93105
SendChatMessageResult sendChatMessageResult = chatThreadClient.SendMessage("Let's meet at 11am");
@@ -179,7 +191,20 @@ var chatParticipant = new ChatParticipant(identifier: kimberly)
179191
{
180192
DisplayName = "Kim"
181193
};
182-
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(topic: "Hello world!", participants: new[] { chatParticipant });
194+
195+
chatParticipant.Metadata.Add("MetadataKey1", "MetadataValue1");
196+
chatParticipant.Metadata.Add("MetadataKey2", "MetadataValue2");
197+
198+
CreateChatThreadOptions createChatThreadOptions = new CreateChatThreadOptions("Hello world!");
199+
200+
createChatThreadOptions.Participants.Add(chatParticipant);
201+
202+
createChatThreadOptions.Metadata.Add("MetadataKey1", "MetadataValue1");
203+
createChatThreadOptions.Metadata.Add("MetadataKey2", "MetadataValue2");
204+
205+
createChatThreadOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(60);
206+
207+
CreateChatThreadResult createChatThreadResult = await chatClient.CreateChatThreadAsync(createChatThreadOptions);
183208
string threadId = createChatThreadResult.ChatThread.Id;
184209
ChatThreadClient chatThreadClient = chatClient.GetChatThreadClient(threadId);
185210
```
@@ -215,11 +240,15 @@ await chatClient.DeleteChatThreadAsync(threadId);
215240

216241
### Update a thread
217242

218-
Use `UpdateTopic` to update the chat thread topic.
219-
- `topic` is used to describe the updated topic for the thread.
220-
243+
Use `UpdatePropertiesAsync` to update the chat thread topic or metadata.
221244
```C# Snippet:Azure_Communication_Chat_Tests_Samples_UpdateThread
222-
await chatThreadClient.UpdateTopicAsync(topic: "new topic !");
245+
UpdateChatThreadPropertiesOptions updateChatThreadPropertiesOptions = new UpdateChatThreadPropertiesOptions();
246+
updateChatThreadPropertiesOptions.Topic = "new topic !";
247+
updateChatThreadPropertiesOptions.Metadata.Add("UpdateMetadataKey", "UpdateMetadataValue");
248+
249+
updateChatThreadPropertiesOptions.RetentionPolicy = new ThreadCreationDateRetentionPolicy(60);
250+
251+
await chatThreadClient.UpdatePropertiesAsync(updateChatThreadPropertiesOptions);
223252
```
224253

225254
## Message Operations
@@ -376,12 +405,12 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
376405
[coc_contact]: mailto:[email protected]
377406
[nuget]: https://www.nuget.org/
378407
[netstandars2mappings]:https://github.com/dotnet/standard/blob/master/docs/versions.md
379-
[useraccesstokens]:https://learn.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-csharp
380-
[communication_resource_docs]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
381-
[communication_resource_create_portal]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
382-
[communication_resource_create_power_shell]: https://learn.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
383-
[communication_resource_create_net]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net
384-
[nextsteps]:https://learn.microsoft.com/azure/communication-services/quickstarts/chat/get-started?pivots=programming-language-csharp
408+
[useraccesstokens]:https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-csharp
409+
[communication_resource_docs]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
410+
[communication_resource_create_portal]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
411+
[communication_resource_create_power_shell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
412+
[communication_resource_create_net]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net
413+
[nextsteps]:https://docs.microsoft.com/azure/communication-services/quickstarts/chat/get-started?pivots=programming-language-csharp
385414
[source]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/communication/Azure.Communication.Chat/src
386-
[product_docs]: https://learn.microsoft.com/azure/communication-services/overview
415+
[product_docs]: https://docs.microsoft.com/azure/communication-services/overview
387416
[package]: https://www.nuget.org/packages/Azure.Communication.Chat

sdk/communication/Azure.Communication.Chat/api/Azure.Communication.Chat.net8.0.cs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public partial class ChatClient
4242
{
4343
protected ChatClient() { }
4444
public ChatClient(System.Uri endpoint, Azure.Communication.CommunicationTokenCredential communicationTokenCredential, Azure.Communication.Chat.ChatClientOptions options = null) { }
45+
public virtual Azure.Response<Azure.Communication.Chat.CreateChatThreadResult> CreateChatThread(Azure.Communication.Chat.CreateChatThreadOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4546
public virtual Azure.Response<Azure.Communication.Chat.CreateChatThreadResult> CreateChatThread(string topic, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants, string idempotencyToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
47+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Chat.CreateChatThreadResult>> CreateChatThreadAsync(Azure.Communication.Chat.CreateChatThreadOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4648
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Chat.CreateChatThreadResult>> CreateChatThreadAsync(string topic, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants = null, string idempotencyToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4749
public virtual Azure.Response DeleteChatThread(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
4850
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteChatThreadAsync(string threadId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -52,13 +54,14 @@ public ChatClient(System.Uri endpoint, Azure.Communication.CommunicationTokenCre
5254
}
5355
public partial class ChatClientOptions : Azure.Core.ClientOptions
5456
{
55-
public ChatClientOptions(Azure.Communication.Chat.ChatClientOptions.ServiceVersion version = Azure.Communication.Chat.ChatClientOptions.ServiceVersion.V2024_03_07) { }
57+
public ChatClientOptions(Azure.Communication.Chat.ChatClientOptions.ServiceVersion version = Azure.Communication.Chat.ChatClientOptions.ServiceVersion.V2025_03_15) { }
5658
public enum ServiceVersion
5759
{
5860
V2021_03_07 = 1,
5961
V2021_09_07 = 2,
6062
V2023_11_07 = 3,
6163
V2024_03_07 = 4,
64+
V2025_03_15 = 5,
6265
}
6366
}
6467
public partial class ChatError
@@ -136,6 +139,7 @@ public static partial class ChatModelFactory
136139
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
137140
public static Azure.Communication.Chat.ChatMessageReadReceipt ChatMessageReadReceipt(Azure.Communication.CommunicationIdentifier sender, string chatMessageId, System.DateTimeOffset readOn) { throw null; }
138141
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime) { throw null; }
142+
public static Azure.Communication.Chat.ChatParticipant ChatParticipant(Azure.Communication.CommunicationIdentifier user, string displayName, System.DateTimeOffset? shareHistoryTime, System.Collections.Generic.IDictionary<string, string> metadata) { throw null; }
139143
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
140144
public static Azure.Communication.Chat.ChatThreadItem ChatThreadItem(string id, string topic, System.DateTimeOffset? deletedOn, System.DateTimeOffset? lastMessageReceivedOn) { throw null; }
141145
public static Azure.Communication.Chat.ChatThreadProperties ChatThreadProperties(string id, string topic, System.DateTimeOffset createdOn, Azure.Communication.CommunicationIdentifier createdBy, System.DateTimeOffset deletedOn) { throw null; }
@@ -146,9 +150,14 @@ public partial class ChatParticipant
146150
{
147151
public ChatParticipant(Azure.Communication.CommunicationIdentifier identifier) { }
148152
public string DisplayName { get { throw null; } set { } }
153+
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
149154
public System.DateTimeOffset? ShareHistoryTime { get { throw null; } set { } }
150155
public Azure.Communication.CommunicationIdentifier User { get { throw null; } set { } }
151156
}
157+
public abstract partial class ChatRetentionPolicy
158+
{
159+
protected ChatRetentionPolicy() { }
160+
}
152161
public partial class ChatThreadClient
153162
{
154163
protected ChatThreadClient() { }
@@ -186,6 +195,8 @@ public ChatThreadClient(string threadId, System.Uri endpoint, Azure.Communicatio
186195
public virtual Azure.Response UpdateMessage(string messageId, string content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
187196
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateMessageAsync(Azure.Communication.Chat.UpdateChatMessageOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
188197
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateMessageAsync(string messageId, string content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
198+
public virtual Azure.Response UpdateProperties(Azure.Communication.Chat.UpdateChatThreadPropertiesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
199+
public virtual System.Threading.Tasks.Task<Azure.Response> UpdatePropertiesAsync(Azure.Communication.Chat.UpdateChatThreadPropertiesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
189200
public virtual Azure.Response UpdateTopic(string topic, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
190201
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateTopicAsync(string topic, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
191202
}
@@ -204,6 +215,17 @@ internal ChatThreadProperties() { }
204215
public System.DateTimeOffset CreatedOn { get { throw null; } }
205216
public System.DateTimeOffset? DeletedOn { get { throw null; } }
206217
public string Id { get { throw null; } }
218+
public System.Collections.Generic.IReadOnlyDictionary<string, string> Metadata { get { throw null; } }
219+
public Azure.Communication.Chat.ChatRetentionPolicy RetentionPolicy { get { throw null; } }
220+
public string Topic { get { throw null; } }
221+
}
222+
public partial class CreateChatThreadOptions
223+
{
224+
public CreateChatThreadOptions(string topic) { }
225+
public string IdempotencyToken { get { throw null; } set { } }
226+
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
227+
public System.Collections.Generic.IList<Azure.Communication.Chat.ChatParticipant> Participants { get { throw null; } }
228+
public Azure.Communication.Chat.ChatRetentionPolicy RetentionPolicy { get { throw null; } set { } }
207229
public string Topic { get { throw null; } }
208230
}
209231
public partial class CreateChatThreadResult
@@ -212,6 +234,28 @@ internal CreateChatThreadResult() { }
212234
public Azure.Communication.Chat.ChatThreadProperties ChatThread { get { throw null; } }
213235
public System.Collections.Generic.IReadOnlyList<Azure.Communication.Chat.ChatError> InvalidParticipants { get { throw null; } }
214236
}
237+
public partial class NoneRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
238+
{
239+
public NoneRetentionPolicy() { }
240+
}
241+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
242+
public readonly partial struct RetentionPolicyKind : System.IEquatable<Azure.Communication.Chat.RetentionPolicyKind>
243+
{
244+
private readonly object _dummy;
245+
private readonly int _dummyPrimitive;
246+
public RetentionPolicyKind(string value) { throw null; }
247+
public static Azure.Communication.Chat.RetentionPolicyKind None { get { throw null; } }
248+
public static Azure.Communication.Chat.RetentionPolicyKind ThreadCreationDate { get { throw null; } }
249+
public bool Equals(Azure.Communication.Chat.RetentionPolicyKind other) { throw null; }
250+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
251+
public override bool Equals(object obj) { throw null; }
252+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
253+
public override int GetHashCode() { throw null; }
254+
public static bool operator ==(Azure.Communication.Chat.RetentionPolicyKind left, Azure.Communication.Chat.RetentionPolicyKind right) { throw null; }
255+
public static implicit operator Azure.Communication.Chat.RetentionPolicyKind (string value) { throw null; }
256+
public static bool operator !=(Azure.Communication.Chat.RetentionPolicyKind left, Azure.Communication.Chat.RetentionPolicyKind right) { throw null; }
257+
public override string ToString() { throw null; }
258+
}
215259
public partial class SendChatMessageOptions
216260
{
217261
public SendChatMessageOptions() { }
@@ -225,6 +269,11 @@ public partial class SendChatMessageResult
225269
internal SendChatMessageResult() { }
226270
public string Id { get { throw null; } }
227271
}
272+
public partial class ThreadCreationDateRetentionPolicy : Azure.Communication.Chat.ChatRetentionPolicy
273+
{
274+
public ThreadCreationDateRetentionPolicy(int deleteThreadAfterDays) { }
275+
public int DeleteThreadAfterDays { get { throw null; } set { } }
276+
}
228277
public partial class TypingNotificationOptions
229278
{
230279
public TypingNotificationOptions() { }
@@ -237,4 +286,11 @@ public UpdateChatMessageOptions() { }
237286
public string MessageId { get { throw null; } set { } }
238287
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
239288
}
289+
public partial class UpdateChatThreadPropertiesOptions
290+
{
291+
public UpdateChatThreadPropertiesOptions() { }
292+
public System.Collections.Generic.IDictionary<string, string> Metadata { get { throw null; } }
293+
public Azure.Communication.Chat.ChatRetentionPolicy RetentionPolicy { get { throw null; } set { } }
294+
public string Topic { get { throw null; } set { } }
295+
}
240296
}

0 commit comments

Comments
 (0)