import "@typespec/rest"; import "@typespec/http"; import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; import "./models/common.models.tsp"; import "./models/custom.text.tsp"; import "./models/entity.linking.tsp"; import "./models/entity.recognition.tsp"; import "./models/healthcare.tsp"; import "./models/key.phrase.extraction.tsp"; import "./models/language.detection.tsp"; import "./models/pii.entity.recognition.tsp"; import "./models/sentiment.analysis.tsp"; import "./models/summarization.tsp"; using TypeSpec.Http; using TypeSpec.Rest; using TypeSpec.Versioning; using Azure.Core; using Azure.Core.Traits; /** The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in https://learn.microsoft.com/azure/cognitive-services/language-service/overview.0 */ @useAuth( | ApiKeyAuth | OAuth2Auth<[ { type: OAuth2FlowType.authorizationCode, authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize", tokenUrl: "https://login.microsoftonline.com/common/oauth2/token", scopes: ["https://cognitiveservices.azure.com/.default"], } ]> ) @service(#{ title: "Microsoft Cognitive Language Service - Text Analysis" }) @server( "{Endpoint}/language", "Single server endpoint", { /** Supported Cognitive Services endpoint (e.g., https://.api.cognitiveservices.azure.com). */ Endpoint: url, } ) @versioned(Versions) namespace Language.Text; /** Analyze Conversations Service Versions */ enum Versions { /** Version 2022-05-01 */ v2022_05_01: "2022-05-01", /** Version 2023-04-01 */ v2023_04_01: "2023-04-01", /** Version 2024-11-01 */ v2024_11_01: "2024-11-01", /** Version 2025-11-01 */ v2025_11_01: "2025-11-01", /** Version 2026-05-01 */ v2026_05_01: "2026-05-01", /** Version 2026-05-15-preview */ v2026_05_15_preview: "2026-05-15-preview", } alias ServiceTraits = NoRepeatableRequests & NoConditionalRequests & NoClientRequestId; alias languageOperations = ResourceOperations; /** Request text analysis over a collection of documents. */ #suppress "@azure-tools/typespec-azure-core/use-standard-operations" @post @route("/:analyze-text") op analyzeText is RpcOperation< AnalyzeTextBody & AnalyzeTextQueryParameters, AnalyzeTextTaskResult, {}, ErrorResponse >; /** Get the status of an analysis job. A job can consist of one or more tasks. After all tasks succeed, the job transitions to the succeeded state and results are available for each task. */ #suppress "@azure-tools/typespec-azure-core/use-standard-operations" #suppress "@azure-tools/typespec-azure-core/use-standard-names" "Existing name" @summary("Get analysis status and results") op analyzeTextJobStatus is languageOperations.ResourceRead< AnalyzeTextJobState, AnalyzeTextJobQueryParameters >; /** Submit a collection of text documents for analysis. Specify one or more unique tasks to be executed as a long-running operation. */ #suppress "@azure-tools/typespec-azure-core/use-standard-operations" @route("/analyze-text/jobs") @pollingOperation(analyzeTextJobStatus) op analyzeTextSubmitJob is Foundations.LongRunningOperation< AnalyzeTextJobsInput, AcceptedResponse, {}, ErrorResponse >; /** Cancel a long-running Text Analysis job. */ #suppress "@azure-tools/typespec-azure-core/use-standard-operations" @summary("Cancel a long-running Text Analysis job.") @pollingOperation(analyzeTextJobStatus) @route("/analyze-text/jobs/{jobId}:cancel") @post op analyzeTextCancelJob is Foundations.LongRunningOperation< { /** The job ID to cancel. */ @path jobId: uuid; }, AcceptedResponse, {}, ErrorResponse >;