1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
|
# Azure Conversations Client for Python
> see https://aka.ms/autorest
### Setup
Install Autorest v3
```ps
npm install -g autorest
```
### Generation
```ps
cd <swagger-folder>
autorest
```
After generation, run the [postprocessing](https://github.com/Azure/autorest.python/blob/autorestv3/docs/customizations.md#postprocessing) script to fix linting issues in the runtime library.
`autorest --postprocess --output-folder=<path-to-root-of-package> --perform-load=false --python`
### Settings
```yaml
namespace: azure.ai.language.conversations
package-name: azure-ai-language-conversations
license-header: MICROSOFT_MIT_NO_VERSION
clear-output-folder: true
no-namespace-folders: true
python: true
openapi-type: data-plane
version-tolerant: true
package-version: 1.1.0
add-credential: true
credential-scopes: https://cognitiveservices.azure.com/.default
black: true
modelerfour:
lenient-model-deduplication: true
```
## Batch Execution
```yaml
batch:
- tag: release_runtime_1_1
- tag: release_authoring_1_1
```
## Runtime
These settings apply only when `--tag=release_runtime_1_1` is specified on the command line.
```yaml $(tag) == 'release_runtime_1_1'
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53240ebc58b3c4e99de723194032064db1d97e63/specification/cognitiveservices/data-plane/Language/stable/2023-04-01/analyzeconversations.json
output-folder: ../azure/ai/language/conversations
title: ConversationAnalysisClient
```
## Authoring
These settings apply only when `--tag=release_authoring_1_1` is specified on the command line.
```yaml $(tag) == 'release_authoring_1_1'
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/53240ebc58b3c4e99de723194032064db1d97e63/specification/cognitiveservices/data-plane/Language/stable/2023-04-01/analyzeconversations-authoring.json
output-folder: ../azure/ai/language/conversations/authoring
title: ConversationAuthoringClient
```
## Customizations
Customizations that should eventually be added to central autorest configuration.
### General customizations
#### Add rest api docs to operations
```yaml
directive:
- from: analyzeconversations-authoring.json
where: $.paths.*.*
transform: |
var operationId = $.operationId.replace(/_/g, "/").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
var apiVersion = $doc.info.version + "/";
$.description = $.description + "\n\nSee https://learn.microsoft.com/rest/api/language/" + apiVersion + operationId + " for more information.";
- where-operation: AnalyzeConversation_SubmitJob
transform: |
var apiVersion = $doc.info.version + "/";
$.description = $.description + "\n\nSee https://learn.microsoft.com/rest/api/language/" + apiVersion + "analyze-conversation/submit-job for more information.";
- where-operation: ConversationAnalysis_AnalyzeConversation
transform: |
var apiVersion = $doc.info.version + "/";
$.description = $.description + "\n\nSee https://learn.microsoft.com/rest/api/language/" + apiVersion + "conversation-analysis-runtime/analyze-conversation for more information.";
# Work around https://github.com/Azure/azure-sdk-for-net/issues/29141
- from: swagger-document
where: $.definitions.AnalyzeConversationResultsKind
transform: >
$["enum"] = [
"conversationalPIIResults",
"conversationalSummarizationResults",
"conversationalSentimentResults"
];
- from: swagger-document
where: $.definitions.AnalyzeConversationConversationPIIResult
transform: >
$["x-ms-discriminator-value"] = "conversationalPIIResults";
- from: swagger-document
where: $.definitions.AnalyzeConversationSummarizationResult
transform: >
$["x-ms-discriminator-value"] = "conversationalSummarizationResults";
- from: swagger-document
where: $.definitions.AnalyzeConversationSentimentResult
transform: >
$["x-ms-discriminator-value"] = "conversationalSentimentResults";
```
```yaml
directive:
# Support automatically generating code for key credentials.
- from: swagger-document
where: $.securityDefinitions
transform: |
$["AzureKey"] = $["apim_key"];
delete $["apim_key"];
- from: swagger-document
where: $.security
transform: |
$ = [
{
"AzureKey": []
}
];
# Fix too long of link in description.
- from: swagger-document
where: $.info
transform: |
$["description"] = "The language service conversations API is a suite of natural language processing (NLP) skills that can be used to analyze structured conversations (textual or spoken). Further documentation can be found in https://learn.microsoft.com/azure/cognitive-services/language-service/overview.";
# Fix Endpoint parameter description and format.
- from: swagger-document
where: $.parameters.Endpoint
transform: |
$["description"] = "Supported Cognitive Services endpoint (e.g., https://<resource-name>.cognitiveservices.azure.com).";
$["format"] = "url";
# Define multilingual parameter as a boolean.
- where-operation: ConversationalAnalysisAuthoring_GetSupportedPrebuiltEntities
transform: |
var multilingualParam = $.parameters.find(param => param.name === "multilingual");
multilingualParam.type = "boolean";
```
### Python customizations
```yaml
directive:
# Always default to UnicodeCodePoint string indices.
- from: swagger-document
where: $.definitions.StringIndexType
transform: |
$["description"] = "Specifies the method used to interpret string offsets. Set to \"UnicodeCodePoint\" for Python strings.";
$["x-ms-client-default"] = "UnicodeCodePoint";
# Only Utf16CodeUnit is supported for these types right now. Once UnicodeCodePoint is supported we can default to that.
# - from: swagger-document
# where: $.definitions.ConversationalAnalysisAuthoringStringIndexType
# transform: |
# $["description"] = "Specifies the method used to interpret string offsets. Set to \"UnicodeCodePoint\" for Python strings.";
# $["x-ms-client-default"] = "UnicodeCodePoint";
# - from: swagger-document
# where: $.parameters.ConversationalAnalysisAuthoringStringIndexTypeQueryParameter
# transform: |
# $["description"] = "Specifies the method used to interpret string offsets. Set to \"UnicodeCodePoint\" for Python strings.";
# $["x-ms-client-default"] = "UnicodeCodePoint";
```
### Runtime API Directives
```yaml $(tag) == 'release_runtime_1_1'
directive:
# Give analyze job LRO a return type
- where-operation: AnalyzeConversation_SubmitJob
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/AnalyzeConversationJobState"
}
};
# Rename Runtime client operation
- rename-operation:
from: ConversationAnalysis_AnalyzeConversation
to: AnalyzeConversation
# Rename Runtime client async operation
- rename-operation:
from: AnalyzeConversation_SubmitJob
to: ConversationAnalysis
# Rename analyze_conversation `body` to `tasks`
- from: swagger-document
where: $["paths"]["/:analyze-conversations"]["post"]
transform: >
$["parameters"][1]["x-ms-client-name"] = "task";
# Rename begin_conversation_analysis `body` to `tasks`
- from: swagger-document
where: $["paths"]["/analyze-conversations/jobs"]["post"]
transform: >
$["parameters"][1]["x-ms-client-name"] = "task";
# Remove async GET operation status
- from: swagger-document
where: $["paths"]
transform: >
delete $["/analyze-conversations/jobs/{jobId}"];
# Remove async cancel operation
- from: swagger-document
where: $["paths"]
transform: >
delete $["/analyze-conversations/jobs/{jobId}:cancel"];
```
### Authoring API Directives
```yaml $(tag) == 'release_authoring_1_1'
# Give LROs return types
directive:
- where-operation: ConversationalAnalysisAuthoring_CancelTrainingJob
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringTrainingJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_DeleteDeployment
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringDeploymentJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_DeleteProject
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringProjectDeletionJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_DeployProject
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringProjectDeployment"
}
};
- where-operation: ConversationalAnalysisAuthoring_Export
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringExportProjectJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_Import
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringImportProjectJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_SwapDeployments
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringDeploymentJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_Train
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringTrainingJobState"
}
};
- where-operation: ConversationalAnalysisAuthoring_LoadSnapshot
transform: >
$["responses"]["200"] = {
"description": "mock schema to get poller response when calling .result()",
"schema": {
"$ref": "#/definitions/ConversationalAnalysisAuthoringLoadSnapshotJobState"
}
};
# Rename `body` param for operations
- where-operation: ConversationalAnalysisAuthoring_DeployProject
transform: >
$.parameters[2]["x-ms-client-name"] = "deployment";
- where-operation: ConversationalAnalysisAuthoring_Import
transform: >
$.parameters[2]["x-ms-client-name"] = "project";
- where-operation: ConversationalAnalysisAuthoring_SwapDeployments
transform: >
$.parameters[1]["x-ms-client-name"] = "deployments";
- where-operation: ConversationalAnalysisAuthoring_Train
transform: >
$.parameters[1]["x-ms-client-name"] = "configuration";
- where-operation: ConversationalAnalysisAuthoring_CreateProject
transform: >
$.parameters[1]["x-ms-client-name"] = "project";
# Rename Authoring client operations
- rename-operation:
from: ConversationalAnalysisAuthoring_ListProjects
to: ListProjects
- rename-operation:
from: ConversationalAnalysisAuthoring_CreateProject
to: CreateProject
- rename-operation:
from: ConversationalAnalysisAuthoring_GetProject
to: GetProject
- rename-operation:
from: ConversationalAnalysisAuthoring_DeleteProject
to: DeleteProject
- rename-operation:
from: ConversationalAnalysisAuthoring_Export
to: ExportProject
- rename-operation:
from: ConversationalAnalysisAuthoring_Import
to: ImportProject
- rename-operation:
from: ConversationalAnalysisAuthoring_Train
to: Train
- rename-operation:
from: ConversationalAnalysisAuthoring_ListDeployments
to: ListDeployments
- rename-operation:
from: ConversationalAnalysisAuthoring_SwapDeployments
to: SwapDeployments
- rename-operation:
from: ConversationalAnalysisAuthoring_GetDeployment
to: GetDeployment
- rename-operation:
from: ConversationalAnalysisAuthoring_DeployProject
to: DeployProject
- rename-operation:
from: ConversationalAnalysisAuthoring_DeleteDeployment
to: DeleteDeployment
- rename-operation:
from: ConversationalAnalysisAuthoring_GetDeploymentStatus
to: GetDeploymentJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_GetSwapDeploymentsStatus
to: GetSwapDeploymentsJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_GetExportStatus
to: GetExportProjectJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_GetImportStatus
to: GetImportProjectJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_ListTrainedModels
to: ListTrainedModels
- rename-operation:
from: ConversationalAnalysisAuthoring_GetTrainedModel
to: GetTrainedModel
- rename-operation:
from: ConversationalAnalysisAuthoring_DeleteTrainedModel
to: DeleteTrainedModel
- rename-operation:
from: ConversationalAnalysisAuthoring_GetModelEvaluationResults
to: ListModelEvaluationResults
- rename-operation:
from: ConversationalAnalysisAuthoring_GetModelEvaluationSummary
to: GetModelEvaluationSummary
- rename-operation:
from: ConversationalAnalysisAuthoring_ListTrainingJobs
to: ListTrainingJobs
- rename-operation:
from: ConversationalAnalysisAuthoring_GetTrainingStatus
to: GetTrainingJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_CancelTrainingJob
to: CancelTrainingJob
- rename-operation:
from: ConversationalAnalysisAuthoring_GetProjectDeletionStatus
to: GetProjectDeletionJobStatus
- rename-operation:
from: ConversationalAnalysisAuthoring_GetSupportedLanguages
to: ListSupportedLanguages
- rename-operation:
from: ConversationalAnalysisAuthoring_GetSupportedPrebuiltEntities
to: ListSupportedPrebuiltEntities
- rename-operation:
from: ConversationalAnalysisAuthoring_ListTrainingConfigVersions
to: ListTrainingConfigVersions
- rename-operation:
from: ConversationalAnalysisAuthoring_LoadSnapshot
to: LoadSnapshot
- rename-operation:
from: ConversationalAnalysisAuthoring_GetLoadSnapshotStatus
to: GetLoadSnapshotJobStatus
```
|