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

Adding Models to Typespec for CLU #24376

Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 17 additions & 8 deletions specification/cognitiveservices/Language.Conversations/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using Azure.Core.Traits;
title: "Microsoft Cognitive Language Service - Analyze Conversations",
version: "2022-05-01",
heaths marked this conversation as resolved.
Show resolved Hide resolved
})
@useAuth(ApiKey)
@useAuth(apim_key | AADToken)
@server(
"{Endpoint}/language",
"Single server endpoint",
Expand All @@ -23,33 +23,42 @@ using Azure.Core.Traits;
Endpoint: string,
}
)
namespace AnalyzeConversation;
namespace Azure.AI.Language.Conversation;

@doc("A subscription key for a Language service resource")
model ApiKey
model apim_key
is ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key">;

@doc("These are the [Azure Active Directory OAuth2](https://docs.microsoft.com/azure/active-directory/develop/v1-overview) Flows. When paired with [Azure role-based access](https://docs.microsoft.com/azure/role-based-access-control/overview) control it can be used to control access to Azure Maps REST APIs. Azure role-based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built-in role or a custom role composed of one or more permissions to Azure Maps REST APIs.\n\nTo implement scenarios, we recommend viewing [authentication concepts](https://aka.ms/amauth). In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.\n\n#### Notes\n* This security definition **requires** the use of the `x-ms-client-id` header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the [Maps management API](https://aka.ms/amauthdetails).\n* \nThe `Authorization URL` is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Azure Active directory configurations. \n* \nThe Azure role-based access control is configured from the [Azure management plane](https://aka.ms/amrbac) via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.\n* \nUsage of the [Azure Maps Web SDK](https://aka.ms/amaadmc) allows for configuration based setup of an application for multiple use cases.\n* Currently, Azure Active Directory [v1.0 or v2.0](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison) supports Work, School, and Guests but does not support Personal accounts.")
model AADToken
is OAuth2Auth<[
{
type: OAuth2FlowType.implicit;
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize";
scopes: ["https://cognitiveservices.azure.com/.default"];
}
]>;

@doc("Enumeration of supported Conversation tasks.")
enum AnalyzeConversationTaskKind {
"Conversation",
Conversation,
}

@doc("Enumeration of supported conversational task results.")
enum AnalyzeConversationTaskResultsKind {
"ConversationResult",
ConversationResult,
}

@discriminator("kind")
@doc("The base class of a conversation input task.")
model AnalyzeConversationTask {
@doc("discriminator kind")
@doc("The base class of a conversation input task.")
kind: AnalyzeConversationTaskKind;
}

@doc("The base class of a conversation input task result.")
@discriminator("kind")
model AnalyzeConversationTaskResult {
@doc("discriminator kind")
@doc("The base class of a conversation input task result.")
kind: AnalyzeConversationTaskResultsKind;
}

Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,63 @@
],
"security": [
{
"ApiKey": []
"apim_key": []
},
{
"AADToken": [
"https://cognitiveservices.azure.com/.default"
]
}
],
"securityDefinitions": {
"ApiKey": {
"apim_key": {
"type": "apiKey",
"description": "A subscription key for a Language service resource",
"in": "header",
"name": "Ocp-Apim-Subscription-Key"
},
"AADToken": {
"type": "oauth2",
"description": "These are the [Azure Active Directory OAuth2](https://docs.microsoft.com/azure/active-directory/develop/v1-overview) Flows. When paired with [Azure role-based access](https://docs.microsoft.com/azure/role-based-access-control/overview) control it can be used to control access to Azure Maps REST APIs. Azure role-based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built-in role or a custom role composed of one or more permissions to Azure Maps REST APIs.\n\nTo implement scenarios, we recommend viewing [authentication concepts](https://aka.ms/amauth). In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.\n\n#### Notes\n* This security definition **requires** the use of the `x-ms-client-id` header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the [Maps management API](https://aka.ms/amauthdetails).\n* \nThe `Authorization URL` is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Azure Active directory configurations. \n* \nThe Azure role-based access control is configured from the [Azure management plane](https://aka.ms/amrbac) via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.\n* \nUsage of the [Azure Maps Web SDK](https://aka.ms/amaadmc) allows for configuration based setup of an application for multiple use cases.\n* Currently, Azure Active Directory [v1.0 or v2.0](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison) supports Work, School, and Guests but does not support Personal accounts.",
"flow": "implicit",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"scopes": {
"https://cognitiveservices.azure.com/.default": ""
}
}
},
"tags": [],
"paths": {},
"definitions": {
"AADToken": {
heaths marked this conversation as resolved.
Show resolved Hide resolved
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"oauth2"
],
"description": "OAuth2 authentication"
},
"flows": {
"type": "array",
"items": {},
"x-typespec-name": "[(anonymous model)]",
"description": "Supported OAuth2 flows"
}
},
"description": "These are the [Azure Active Directory OAuth2](https://docs.microsoft.com/azure/active-directory/develop/v1-overview) Flows. When paired with [Azure role-based access](https://docs.microsoft.com/azure/role-based-access-control/overview) control it can be used to control access to Azure Maps REST APIs. Azure role-based access controls are used to designate access to one or more Azure Maps resource account or sub-resources. Any user, group, or service principal can be granted access via a built-in role or a custom role composed of one or more permissions to Azure Maps REST APIs.\n\nTo implement scenarios, we recommend viewing [authentication concepts](https://aka.ms/amauth). In summary, this security definition provides a solution for modeling application(s) via objects capable of access control on specific APIs and scopes.\n\n#### Notes\n* This security definition **requires** the use of the `x-ms-client-id` header to indicate which Azure Maps resource the application is requesting access to. This can be acquired from the [Maps management API](https://aka.ms/amauthdetails).\n* \nThe `Authorization URL` is specific to the Azure public cloud instance. Sovereign clouds have unique Authorization URLs and Azure Active directory configurations. \n* \nThe Azure role-based access control is configured from the [Azure management plane](https://aka.ms/amrbac) via Azure portal, PowerShell, CLI, Azure SDKs, or REST APIs.\n* \nUsage of the [Azure Maps Web SDK](https://aka.ms/amaadmc) allows for configuration based setup of an application for multiple use cases.\n* Currently, Azure Active Directory [v1.0 or v2.0](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison) supports Work, School, and Guests but does not support Personal accounts.",
"required": [
"type",
"flows"
]
},
"AnalyzeConversationTask": {
"type": "object",
"properties": {
"kind": {
"$ref": "#/definitions/AnalyzeConversationTaskKind",
"description": "discriminator kind"
"description": "The base class of a conversation input task."
}
},
"description": "The base class of a conversation input task.",
Expand All @@ -78,7 +115,7 @@
"properties": {
"kind": {
"$ref": "#/definitions/AnalyzeConversationTaskResultsKind",
"description": "discriminator kind"
"description": "The base class of a conversation input task result."
}
},
"description": "The base class of a conversation input task result.",
Expand All @@ -98,7 +135,7 @@
"modelAsString": true
}
},
"ApiKey": {
"apim_key": {
"type": "object",
"properties": {
"type": {
Expand Down