Skip to content

Commit 902b246

Browse files
RezaJooyandehMinnie LiuDominikMe
authored
[Communication] - New version of Identity Service (Azure#18066)
* Adding new Identity API design * Rename token to access token * Use some of the previous type names * Update the livetest recordings * Communication - Extract the Identity Client out of the Administration library * Remove optional properties of CommunicationIdentityClientOptions.ctor * Update the Changelogs * Update ReadMe * Remove unused files * Use the approved swagger * Update the status code in the chat recorded tests * Update the Administration package README * Update README Co-authored-by: Minnie Liu <peiliu@microsoft.com> Co-authored-by: Dominik <domessin@microsoft.com>
1 parent 735d6d0 commit 902b246

File tree

80 files changed

+3019
-2293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3019
-2293
lines changed

sdk/communication/Azure.Communication.Administration/CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
## 1.0.0-beta.4 (Unreleased)
44

55
### Added
6-
- Added support to create CommunicationIdentityClient with TokenCredential.
7-
- Added support to create CommunicationIdentityClient with AzureKeyCredential.
86
- Added support to create PhoneNumberAdministrationClient with AzureKeyCredential.
97
- Added support to create PhoneNumberAdministrationClient with TokenCredential
108

119
### Fixed
1210
- Issue with paging results not pulling next pages
1311

1412
### Breaking
15-
- CommunicationTokenScope.Pstn is removed.
13+
- CommunicationIdentityClient is moved to a new NuGet package, `Azure.Communication.Identity`.
1614

1715

1816
## 1.0.0-beta.3 (2020-11-16)

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

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Azure Communication Administration client library for .NET
22

33
> Server Version:
4-
> Identity client: 2020-07-20-preview2
54
65
> Phone number administration client: 2020-07-20-preview1
76
8-
Azure Communication Administration is managing tokens and phone numbers for Azure Communication Services.
7+
Azure Communication Administration is managing phone numbers for Azure Communication Services.
98

109
[Source code][source] | [Package (NuGet)][package] | [Product documentation][product_docs] | [Samples][source_samples]
1110

@@ -33,90 +32,13 @@ Here's an example using the Azure CLI:
3332
```
3433
-->
3534

36-
### Authenticate the client
37-
38-
Administration clients can be authenticated using connection string acquired from an Azure Communication Resources in the [Azure Portal][azure_portal].
39-
40-
```C# Snippet:CreateCommunicationIdentityClient
41-
// Get a connection string to our Azure Communication resource.
42-
var connectionString = "<connection_string>";
43-
var client = new CommunicationIdentityClient(connectionString);
44-
```
45-
46-
Clients also have the option to authenticate using a valid token.
47-
48-
```C# Snippet:CreateCommunicationIdentityFromToken
49-
var endpoint = new Uri("https://my-resource.communication.azure.com");
50-
TokenCredential tokenCredential = new DefaultAzureCredential();
51-
var client = new CommunicationIdentityClient(endpoint, tokenCredential);
52-
```
53-
5435
### Key concepts
5536

56-
`CommunicationIdentityClient` provides the functionalities to manage user access tokens: creating new ones, renewing and revoking them.
57-
58-
## Examples
59-
60-
### Create a new identity
61-
62-
```C# Snippet:CreateCommunicationUserAsync
63-
Response<CommunicationUserIdentifier> userResponse = await client.CreateUserAsync();
64-
CommunicationUserIdentifier user = userResponse.Value;
65-
Console.WriteLine($"User id: {user.Id}");
66-
```
67-
68-
### Issuing or Refreshing a token for an existing identity
69-
70-
```C# Snippet:CreateCommunicationTokenAsync
71-
Response<CommunicationUserToken> tokenResponse = await client.IssueTokenAsync(user, scopes: new[] { CommunicationTokenScope.Chat });
72-
string token = tokenResponse.Value.Token;
73-
DateTimeOffset expiresOn = tokenResponse.Value.ExpiresOn;
74-
Console.WriteLine($"Token: {token}");
75-
Console.WriteLine($"Expires On: {expiresOn}");
76-
```
77-
78-
### Revoking a user's tokens
79-
80-
In case a user's tokens are compromised or need to be revoked:
81-
82-
```C# Snippet:RevokeCommunicationUserToken
83-
Response revokeResponse = client.RevokeTokens(
84-
user,
85-
issuedBefore: DateTimeOffset.UtcNow.AddDays(-1) /* optional */);
86-
```
87-
88-
### Deleting a user
89-
90-
```C# Snippet:DeleteACommunicationUser
91-
Response deleteResponse = client.DeleteUser(user);
92-
```
93-
94-
## Troubleshooting
95-
96-
All User token service operations will throw a RequestFailedException on failure.
97-
98-
```C# Snippet:CommunicationIdentityClient_Troubleshooting
99-
// Get a connection string to our Azure Communication resource.
100-
var connectionString = "<connection_string>";
101-
var client = new CommunicationIdentityClient(connectionString);
102-
103-
try
104-
{
105-
Response<CommunicationUserIdentifier> response = await client.CreateUserAsync();
106-
}
107-
catch (RequestFailedException ex)
108-
{
109-
Console.WriteLine(ex.Message);
110-
}
111-
```
112-
113-
### Phone plans overview
114-
11537
Phone plans come in two types; Geographic and Toll-Free. Geographic phone plans are phone plans associated with a location, whose phone numbers' area codes are associated with the area code of a geographic location. Toll-Free phone plans are phone plans not associated location. For example, in the US, toll-free numbers can come with area codes such as 800 or 888.
11638

11739
All geographic phone plans within the same country are grouped into a phone plan group with a Geographic phone number type. All Toll-Free phone plans within the same country are grouped into a phone plan group.
11840

119-
### Authenticate the Phone Number Administration client
41+
### Authenticate the client
12042

12143
Phone Number Administration clients can be authenticated using connection string acquired from an Azure Communication Resources in the [Azure Portal][azure_portal].
12244

@@ -256,6 +178,7 @@ await releasePhoneNumberOperation.WaitForCompletionAsync().ConfigureAwait(false)
256178

257179
Console.WriteLine($"ReleaseId: {releasePhoneNumberOperation.Value.ReleaseId}, Status: {releasePhoneNumberOperation.Value.Status}");
258180
```
181+
## Troubleshooting
259182

260183
## Next steps
261184

@@ -280,7 +203,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
280203
[package]: https://www.nuget.org/packages/Azure.Communication.Administration
281204
[product_docs]: https://docs.microsoft.com/azure/communication-services/overview
282205
[nuget]: https://www.nuget.org/
283-
[user_access_token]: https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-csharp
284206
[communication_resource_docs]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
285207
[communication_resource_create_portal]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
286208
[communication_resource_create_power_shell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice

sdk/communication/Azure.Communication.Administration/api/Azure.Communication.Administration.netstandard2.0.cs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
namespace Azure.Communication.Administration
22
{
3-
public partial class CommunicationIdentityClient
4-
{
5-
protected CommunicationIdentityClient() { }
6-
public CommunicationIdentityClient(string connectionString, Azure.Communication.Administration.CommunicationIdentityClientOptions? options = null) { }
7-
public CommunicationIdentityClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Administration.CommunicationIdentityClientOptions? options = null) { }
8-
public CommunicationIdentityClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Administration.CommunicationIdentityClientOptions? options = null) { }
9-
public virtual Azure.Response<Azure.Communication.CommunicationUserIdentifier> CreateUser(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
10-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CommunicationUserIdentifier>> CreateUserAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
11-
public virtual Azure.Response DeleteUser(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
12-
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteUserAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
13-
public virtual Azure.Response<Azure.Communication.Administration.Models.CommunicationUserToken> IssueToken(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Administration.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
14-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Administration.Models.CommunicationUserToken>> IssueTokenAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Administration.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
15-
public virtual Azure.Response RevokeTokens(Azure.Communication.CommunicationUserIdentifier communicationUser, System.DateTimeOffset? issuedBefore = default(System.DateTimeOffset?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
16-
public virtual System.Threading.Tasks.Task<Azure.Response> RevokeTokensAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.DateTimeOffset? issuedBefore = default(System.DateTimeOffset?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
17-
}
18-
public partial class CommunicationIdentityClientOptions : Azure.Core.ClientOptions
19-
{
20-
public const Azure.Communication.Administration.CommunicationIdentityClientOptions.ServiceVersion LatestVersion = Azure.Communication.Administration.CommunicationIdentityClientOptions.ServiceVersion.V1;
21-
public CommunicationIdentityClientOptions(Azure.Communication.Administration.CommunicationIdentityClientOptions.ServiceVersion version = Azure.Communication.Administration.CommunicationIdentityClientOptions.ServiceVersion.V1, Azure.Core.RetryOptions? retryOptions = null, Azure.Core.Pipeline.HttpPipelineTransport? transport = null) { }
22-
public enum ServiceVersion
23-
{
24-
V1 = 1,
25-
}
26-
}
27-
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
28-
public readonly partial struct CommunicationTokenScope : System.IEquatable<Azure.Communication.Administration.CommunicationTokenScope>
29-
{
30-
private readonly object _dummy;
31-
private readonly int _dummyPrimitive;
32-
public CommunicationTokenScope(string value) { throw null; }
33-
public static Azure.Communication.Administration.CommunicationTokenScope Chat { get { throw null; } }
34-
public static Azure.Communication.Administration.CommunicationTokenScope VoIP { get { throw null; } }
35-
public bool Equals(Azure.Communication.Administration.CommunicationTokenScope other) { throw null; }
36-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
37-
public override bool Equals(object obj) { throw null; }
38-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
39-
public override int GetHashCode() { throw null; }
40-
public static bool operator ==(Azure.Communication.Administration.CommunicationTokenScope left, Azure.Communication.Administration.CommunicationTokenScope right) { throw null; }
41-
public static implicit operator Azure.Communication.Administration.CommunicationTokenScope (string value) { throw null; }
42-
public static bool operator !=(Azure.Communication.Administration.CommunicationTokenScope left, Azure.Communication.Administration.CommunicationTokenScope right) { throw null; }
43-
public override string ToString() { throw null; }
44-
}
453
public partial class PhoneNumberAdministrationClient
464
{
475
protected PhoneNumberAdministrationClient() { }
486
public PhoneNumberAdministrationClient(string connectionString, Azure.Communication.Administration.PhoneNumberAdministrationClientOptions? options = null) { }
49-
public PhoneNumberAdministrationClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Administration.CommunicationIdentityClientOptions? options = null) { }
7+
public PhoneNumberAdministrationClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Administration.PhoneNumberAdministrationClientOptions? options = null) { }
508
public PhoneNumberAdministrationClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Administration.PhoneNumberAdministrationClientOptions? options = null) { }
519
public virtual Azure.Response CancelReservation(string reservationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
5210
public virtual System.Threading.Tasks.Task<Azure.Response> CancelReservationAsync(string reservationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -137,7 +95,6 @@ public static partial class AdministrationModelFactory
13795
public static Azure.Communication.Administration.Models.AcquiredPhoneNumber AcquiredPhoneNumber(string phoneNumber, System.Collections.Generic.IEnumerable<Azure.Communication.Administration.Models.PhoneNumberCapability> acquiredCapabilities, System.Collections.Generic.IEnumerable<Azure.Communication.Administration.Models.PhoneNumberCapability> availableCapabilities) { throw null; }
13896
public static Azure.Communication.Administration.Models.AreaCodes AreaCodes(System.Collections.Generic.IReadOnlyList<string> primaryAreaCodes, System.Collections.Generic.IReadOnlyList<string> secondaryAreaCodes, string nextLink) { throw null; }
13997
public static Azure.Communication.Administration.Models.CarrierDetails CarrierDetails(string name, string localizedName) { throw null; }
140-
public static Azure.Communication.Administration.Models.CommunicationUserToken CommunicationUserToken(string id, string token, System.DateTimeOffset expiresOn) { throw null; }
14198
public static Azure.Communication.Administration.Models.LocationOptions LocationOptions(string labelId, string labelName, System.Collections.Generic.IList<Azure.Communication.Administration.Models.LocationOptionsDetails> options) { throw null; }
14299
public static Azure.Communication.Administration.Models.LocationOptionsDetails LocationOptionsDetails(string name, string value, System.Collections.Generic.IList<Azure.Communication.Administration.Models.LocationOptions> locationOptions) { throw null; }
143100
public static Azure.Communication.Administration.Models.LocationOptionsResponse LocationOptionsResponse(Azure.Communication.Administration.Models.LocationOptions locationOptions) { throw null; }
@@ -213,13 +170,6 @@ internal CarrierDetails() { }
213170
public string LocalizedName { get { throw null; } }
214171
public string Name { get { throw null; } }
215172
}
216-
public partial class CommunicationUserToken
217-
{
218-
internal CommunicationUserToken() { }
219-
public System.DateTimeOffset ExpiresOn { get { throw null; } }
220-
public string Token { get { throw null; } }
221-
public Azure.Communication.CommunicationUserIdentifier User { get { throw null; } }
222-
}
223173
public partial class CreateReservationOptions
224174
{
225175
public CreateReservationOptions(string displayName, string description, System.Collections.Generic.IEnumerable<string> phonePlanIds, string areaCode) { }

sdk/communication/Azure.Communication.Administration/src/CommunicationTokenScope.cs

Lines changed: 0 additions & 72 deletions
This file was deleted.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CommunicationIdentityUpdateRequest.Serialization.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CommunicationIdentityUpdateRequest.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)