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

Add stable version of common model swagger for Azure Communication Services #12799

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"swagger": "2.0",
"info": {
"title": "Communication",
"description": "Communication Services API common types.",
"version": "2021-03-07"
},
"paths": {},
"definitions": {
"CommunicationErrorResponse": {
"description": "The Communication Services error.",
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"description": "The Communication Services error.",
"$ref": "#/definitions/CommunicationError"
}
}
},
"CommunicationError": {
"description": "The Communication Services error.",
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "string",
"description": "The error code."
},
"message": {
"type": "string",
"description": "The error message."
},
"target": {
"type": "string",
"readOnly": true,
"description": "The error target."
},
"details": {
"type": "array",
"items": {
"$ref": "#/definitions/CommunicationError"
},
"readOnly": true,
"description": "Further details about specific errors that led to this error."
},
"innererror": {
"x-ms-client-name": "innerError",
"readOnly": true,
"$ref": "#/definitions/CommunicationError",
"description": "The inner error if any."
}
}
},
"CommunicationCloudEnvironmentModel": {
"description": "The cloud that the identifier belongs to.",
"type": "string",
"enum": [
"public",
"dod",
"gcch"
],
"x-ms-enum": {
"name": "CommunicationCloudEnvironmentModel",
"modelAsString": true
}
},
"CommunicationIdentifierModel": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would CallingApplication be brought back later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, once we support it, we should add it. We removed it for now, as it does not seem to be used in any GA service and internally we have yet to finalize which format would be mapped to applications to avoid breaking changes in the SDK code. Once they are all decided, we can add it back as a non-breaking change

"description": "Identifies a participant in Azure Communication services. A participant is, for example, a phone number or an Azure communication user. This model must be interpreted as a union: Apart from rawId, at most one further property may be set.",
"type": "object",
"properties": {
"rawId": {
amrelroumy-msft marked this conversation as resolved.
Show resolved Hide resolved
"type": "string",
"description": "Raw Id of the identifier. Optional in requests, required in responses."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming rawId would be required in events as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, any outbound from Communication Services would include the rawId in the body, but developers do not need to send them in their requests

},
"communicationUser": {
"$ref": "#/definitions/CommunicationUserIdentifierModel",
"description": "The communication user."
},
"phoneNumber": {
"$ref": "#/definitions/PhoneNumberIdentifierModel",
"description": "The phone number."
},
"microsoftTeamsUser": {
"$ref": "#/definitions/MicrosoftTeamsUserIdentifierModel",
"description": "The Microsoft Teams user."
}
}
},
"CommunicationUserIdentifierModel": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with eliminating explicit "kind" enum and having "optional" full objects, would result customers processing the events as :

if (eventData.CommunicationUser != null)
{
}
else if (eventData.PhoneNumber != null)
{
}
else if (eventData.MicrosoftTeamsUser != null)
{
}
etc.

Not a clean switch case. Also it will be difficult distinguish between an error case(all user representation objects are null) and new user object(which can be detected by default label in a switch case).

So would it be beneficial to include "kind" along with the specific objects?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having kind helps with deserialziation, but for preparing requests, it is redundant information. Also we were thinking other violation could happen so we need to check the properties anyways. Eg, someone could set multiple properties. We can offer serialization/deserialization in our code to help the developers. Eg: Azure/azure-sdk-for-net#18389

Copy link
Member

@RezaJooyandeh RezaJooyandeh Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(all user representation objects are null)

👆🏻 is a valid case, all being null is equivalent to kind: "unknown".

"description": "A user that got created with an Azure Communication Services resource.",
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
amrelroumy-msft marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this "id" be full MRI or will it be the inside "8:acs:<stable_resource_id>_"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the full MRI

"type": "string",
"description": "The Id of the communication user."
}
}
},
"PhoneNumberIdentifierModel": {
"description": "A phone number.",
"type": "object",
"required": [
"value"
],
"properties": {
"value": {
"type": "string",
"description": "The phone number in E.164 format."
}
}
},
"MicrosoftTeamsUserIdentifierModel": {
"description": "A Microsoft Teams user.",
"type": "object",
"required": [
"userId"
],
"properties": {
"userId": {
"type": "string",
"description": "The Id of the Microsoft Teams user. If not anonymous, this is the AAD object Id of the user."
},
"isAnonymous": {
"type": "boolean",
"description": "True if the Microsoft Teams user is anonymous. By default false if missing."
},
"cloud": {
"$ref": "#/definitions/CommunicationCloudEnvironmentModel",
"description": "The cloud that the Microsoft Teams user belongs to. By default 'public' if missing."
}
}
}
},
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow.",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
}
}
3 changes: 3 additions & 0 deletions specification/communication/data-plane/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ These settings apply only when `--tag=package-2021-03-07` is specified on the co
```yaml $(tag) == 'package-2021-03-07'
input-file:
- Microsoft.CommunicationServicesIdentity/stable/2021-03-07/CommunicationIdentity.json
amrelroumy-msft marked this conversation as resolved.
Show resolved Hide resolved
- Microsoft.CommunicationServicesCommon/stable/2021-03-07/common.json
title:
Azure Communication Services
```

### Tag: package-2021-02-22-preview1
Expand Down