Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, iOS) #4473

Closed
petrsvihlik opened this issue Jun 23, 2022 · 8 comments
Assignees
Labels
architecture board-review Request for an Architectural Board Review

Comments

@petrsvihlik
Copy link
Contributor

petrsvihlik commented Jun 23, 2022

Contacts and Timeline

  • Responsible service team: ACS Dev Security (former part of the ACS Auth team)
  • Main contacts: Dominik Messinger (@DominikMe), Petr Svihlik (@petrsvihlik)
  • Expected code complete date: 2022-07-01
  • Expected release date: 2022-07-31

About the Service

  • Link to documentation introducing/describing the service: N/A - not a service client library
  • Link to the service REST APIs: N/A - not a service client library
  • Link to GitHub issue for previous review sessions, if applicable: N/A - not a service client library

About the client library

  • Name of the client library: Azure.Communication.Common
  • Languages for this review: C#, JS, Java (+ Android), Python, iOS

Artifacts required (per language)

Please read through “API Review” section here to understand how these artifacts are generated. It is critical that these artifacts are present and are in the right format. If not, the language architects cannot review them with the SDK Team’s API review tool.

.NET

Java

Android

Python

TypeScript

iOS

About the change

Motivation

While the CommunicationIdentifier types for both SDK runtime models as well as REST models do a good job of

  • providing good auto-complete in IDEs
  • avoid having customers to parse and construct MRIs with cryptic strings like 4: or 8:orgid:
  • allow switch-case by type
  • allow restricting communication to specific types

they don't do a good job of

  • explaining how to persist them in Databases and use them as keys
  • how to use them as key in dictionaries, example use case messages or read notifications by user
  • how to use them as key in declarative UI frameworks such as React to avoid unnecessary re-renders
  • use them as key in REST API paths, instead of having to rely on POST payloads leading to less-intuitive REST CRUD APIs

Customers can serialize identifiers themselves but it's not clear how to do so in a safe manner. For example, the MicrosoftTeamsUserIdentifier has multiple properties such as IsAnonymous or Cloud and it's not clear in which order these properties should get serialized into a string. ACS can introduce new properties in the future which can potentially break any serialization logic that the customer came up with.

One particular scenario (submitted by the UI Library team) that this feature will unblock is mapping MRIs to AAD ObjectIds to enable calling Graph API and provide a rich experience for calling participants.

Proposed change

Introduce a canonical serialization format of identifiers that can be used for all of the above cases.
Implementation details - Design change request: RawId support for (de)serialization

Champion Scenario

        public class ContosoUser
        {
            public string Name { get; set; }
            public string Email { get; set; }
            public string CommunicationIdentifier { get; set; }
        }

        public void SerializationExample()
        {
            // The value can come from the Identity API, Calling/Chat API (participants), etc.
            // It can be a CommunicationUser, PhoneNumber, MicrosoftTeamsUser
            CommunicationIdentifier communicationIdentifier;

            ContosoUser user = new ContosoUser()
            {
                Name = "John",
                Email = "john@doe.com",
                // store the MRI no matter what's the underlying type
                CommunicationIdentifier = communicationIdentifier.RawId
            };
            SaveToDb(user);
        }

        public void DeserializationExample()
        {
            ContosoUser user = GetFromDb("john@doe.com");

            string rawId = user.CommunicationIdentifier;
            CommunicationIdentifier communicationIdentifier = CommunicationIdentifier.FromRawId(rawId);
            switch (communicationIdentifier)
            {
                case MicrosoftTeamsUserIdentifier teamsUser:
                    string getPhotoUri = $"https://graph.microsoft.com/v1.0/users/{teamsUser.UserId}/photo/$value";
                    // GET /users/<oid>/photo/$value
                    break;

                case CommunicationIdentifier communicationUser:
                    // ...
                    break;
            }
        }
@petrsvihlik petrsvihlik added architecture board-review Request for an Architectural Board Review labels Jun 23, 2022
@petrsvihlik petrsvihlik changed the title [Draft] Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, iOS) Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, iOS) Jul 11, 2022
@petrsvihlik petrsvihlik changed the title Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, iOS) Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, and eventually iOS) Jul 11, 2022
@petrsvihlik petrsvihlik changed the title Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, and eventually iOS) Board Review: Azure Communication Services [Common] (.NET, JS, Java, Python, Android, iOS) Jul 18, 2022
@kyle-patterson
Copy link
Member

Scheduled for 7/28 9a-11a PDT

@petrsvihlik
Copy link
Contributor Author

Should we use implicit or explicit operator? The guidelines say that implicit shouldn't be used for something that can throw.

We already use implicit for enum-like structures (e.g. CommunicationCloudEnvironment) - are there any guidelines for non-enum-like structures?

Would be cool to be able to do something like this:

            ContosoUser user = GetFromDb("john@doe.com");
            var chatParticipant = new ChatParticipant(identifier: user.RawId)
            {
                DisplayName = "UserDisplayName"
            };

Instead of this:

            var chatParticipant = new ChatParticipant(identifier: new CommunicationUserIdentifier(id: "<Access_ID>"))
            {
                DisplayName = "UserDisplayName"
            };

@tg-msft
Copy link
Member

tg-msft commented Jul 28, 2022

Recording (MS INTERNAL ONLY)

@petrsvihlik
Copy link
Contributor Author

@joheredi @xirzec can you pls approve the APIView for JS?

It was approved last Thursday, and we'd like to get it released soon to unblock other teams.

@xirzec
Copy link
Member

xirzec commented Aug 1, 2022

Looks like @bterlson approved, @petrsvihlik let me know if you're still blocked. 😄

@petrsvihlik
Copy link
Contributor Author

@xirzec for some reason the pipeline doesn't accept the approval above and requires an approval in this API view: https://apiview.dev/Assemblies/Review/26aa3f641ebb441cb5a8f19d8291b97a?diffRevisionId=5d31b068c24d48f58296cc015e1183fe&doc=False&diffOnly=False&revisionId=af44898499ea429fad73cc5cd29804ed

can you please approve it too?

@joheredi
Copy link
Member

joheredi commented Aug 2, 2022

I have approved it

@petrsvihlik
Copy link
Contributor Author

all languages released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture board-review Request for an Architectural Board Review
Projects
None yet
Development

No branches or pull requests

6 participants