From 42e2912093385d6ff8cdc351e9c0ddc437a2e815 Mon Sep 17 00:00:00 2001 From: Ding Date: Fri, 7 Jun 2024 14:23:53 -0700 Subject: [PATCH 01/10] Update folder name for canonical swagger (#968) ISSUE: since the canonical swagger file version is "canonical", based on current logic, the swagger file folder name is "stable", which should be "canonical". --------- Co-authored-by: Ding --- ...ate_canonical_swagger_folder_name-2024-6-6-11-44-3.md | 7 +++++++ .../typespec-autorest-canonical/reference/emitter.md | 2 +- eng/feeds/arm-canonical/tspconfig.yaml | 2 +- packages/typespec-autorest-canonical/README.md | 2 +- packages/typespec-autorest-canonical/src/emitter.ts | 9 +-------- packages/typespec-autorest-canonical/src/lib.ts | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 .chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md diff --git a/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md b/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md new file mode 100644 index 0000000000..14101dc92c --- /dev/null +++ b/.chronus/changes/update_canonical_swagger_folder_name-2024-6-6-11-44-3.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-autorest-canonical" +--- + +update the canonical swagger file folder name diff --git a/docs/emitters/typespec-autorest-canonical/reference/emitter.md b/docs/emitters/typespec-autorest-canonical/reference/emitter.md index 4613b5348f..820c8a8995 100644 --- a/docs/emitters/typespec-autorest-canonical/reference/emitter.md +++ b/docs/emitters/typespec-autorest-canonical/reference/emitter.md @@ -33,7 +33,7 @@ Output file will interpolate the following values: - service-name: Name of the service if multiple - azure-resource-provider-folder: Value of the azure-resource-provider-folder option -Default: `{azure-resource-provider-folder}/{service-name}/{version}/openapi.json` +Default: `{azure-resource-provider-folder}/{service-name}/canonical/openapi.json` Example: Single service diff --git a/eng/feeds/arm-canonical/tspconfig.yaml b/eng/feeds/arm-canonical/tspconfig.yaml index 3e0f896eda..e75f83fbd5 100644 --- a/eng/feeds/arm-canonical/tspconfig.yaml +++ b/eng/feeds/arm-canonical/tspconfig.yaml @@ -11,7 +11,7 @@ options: '@azure-tools/typespec-autorest-canonical': emitter-output-dir: "{project-root}/.." azure-resource-provider-folder: "resource-manager" - output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json" + output-file: "{azure-resource-provider-folder}/{service-name}/canonical/openapi.json" linter: extends: - "@azure-tools/typespec-azure-rulesets/resource-manager" diff --git a/packages/typespec-autorest-canonical/README.md b/packages/typespec-autorest-canonical/README.md index b11edfc352..1eacd104bf 100644 --- a/packages/typespec-autorest-canonical/README.md +++ b/packages/typespec-autorest-canonical/README.md @@ -37,7 +37,7 @@ Output file will interpolate the following values: - service-name: Name of the service if multiple - azure-resource-provider-folder: Value of the azure-resource-provider-folder option -Default: `{azure-resource-provider-folder}/{service-name}/{version}/openapi.json` +Default: `{azure-resource-provider-folder}/{service-name}/canonical/openapi.json` Example: Single service diff --git a/packages/typespec-autorest-canonical/src/emitter.ts b/packages/typespec-autorest-canonical/src/emitter.ts index 0b36e004f5..e4919b12b6 100644 --- a/packages/typespec-autorest-canonical/src/emitter.ts +++ b/packages/typespec-autorest-canonical/src/emitter.ts @@ -134,8 +134,7 @@ async function emitAllServices( function resolveOutputFile( service: Service, multipleServices: boolean, - options: ResolvedAutorestCanonicalEmitterOptions, - version?: string + options: ResolvedAutorestCanonicalEmitterOptions ): string { const azureResourceProviderFolder = options.azureResourceProviderFolder; const interpolated = interpolatePath(options.outputFile, { @@ -144,12 +143,6 @@ function resolveOutputFile( multipleServices || azureResourceProviderFolder ? getNamespaceFullName(service.type) : undefined, - "version-status": azureResourceProviderFolder - ? version?.includes("preview") - ? "preview" - : "stable" - : undefined, - version, }); return resolvePath(options.outputDir, interpolated); diff --git a/packages/typespec-autorest-canonical/src/lib.ts b/packages/typespec-autorest-canonical/src/lib.ts index 92dc95e549..0122ea8e62 100644 --- a/packages/typespec-autorest-canonical/src/lib.ts +++ b/packages/typespec-autorest-canonical/src/lib.ts @@ -8,7 +8,7 @@ export interface AutorestCanonicalEmitterOptions { * - version: Version of the service if multiple * - azure-resource-provider-folder: Value of the azure-resource-provider-folder option * - * @default `{azure-resource-provider-folder}/{service-name}/{version}/openapi.json` + * @default `{azure-resource-provider-folder}/{service-name}/canonical/openapi.json` * * * @example Single service no versioning @@ -68,7 +68,7 @@ const EmitterOptionsSchema: JSONSchemaType = { " - service-name: Name of the service if multiple", " - azure-resource-provider-folder: Value of the azure-resource-provider-folder option", "", - "Default: `{azure-resource-provider-folder}/{service-name}/{version}/openapi.json`", + "Default: `{azure-resource-provider-folder}/{service-name}/canonical/openapi.json`", "", "", "Example: Single service", From f63d6d741ef07158f3348df0198bf8f013cd178b Mon Sep 17 00:00:00 2001 From: Mark Cowlishaw Date: Mon, 10 Jun 2024 19:23:04 -0700 Subject: [PATCH 02/10] Add support for ARM lro options in typespec-autorest (#955) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Timothee Guerin --- .../changes/arm-lro-opt-2024-5-5-15-31-47.md | 7 + .../changes/arm-lro-opt-2024-5-5-15-33-29.md | 7 + .../changes/arm-lro-opt-2024-5-5-19-32-9.md | 7 + .../changes/arm-lro-opt-2024-5-5-2-57-50.md | 9 + .../typespec-autorest/reference/emitter.md | 6 + .../azure-core/reference/decorators.md | 18 ++ docs/libraries/azure-core/reference/index.mdx | 1 + .../reference/data-types.md | 3 +- .../data-plane/api-path-parameter/main.tsp | 12 +- .../data-plane/custom-error-type/main.tsp | 6 +- .../data-plane/trait-versioning/main.tsp | 15 +- .../specs/data-plane/widget-manager/main.tsp | 21 +- .../typespec-autorest/2022-08-31/openapi.json | 81 ++++++- .../openapi3/openapi.2022-08-31.yaml | 70 +++--- .../typespec-autorest/2022-08-31/openapi.json | 66 ++++++ .../openapi3/openapi.2022-08-31.yaml | 64 ++++-- .../typespec-autorest/2022-08-31/openapi.json | 83 ++++++- .../typespec-autorest/2023-02-07/openapi.json | 83 ++++++- .../openapi3/openapi.2022-08-31.yaml | 72 +++--- .../openapi3/openapi.2023-02-07.yaml | 72 +++--- .../typespec-autorest/2022-08-31/openapi.json | 95 +++++++- .../openapi3/openapi.2022-08-31.yaml | 78 ++++--- .../typespec-autorest/openapi.json | 20 ++ .../typespec-autorest/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + .../typespec-autorest/openapi.json | 4 + .../2023-08-01-preview/openapi.json | 4 + .../2023-11-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 8 + .../2021-10-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + .../2021-10-01-preview/openapi.json | 4 + packages/typespec-autorest/README.md | 6 + .../schema/autorest-openapi-schema.tsp | 2 + packages/typespec-autorest/src/emit.ts | 1 + packages/typespec-autorest/src/lib.ts | 14 ++ packages/typespec-autorest/src/openapi.ts | 67 ++++++ .../src/openapi2-document.ts | 15 ++ packages/typespec-autorest/test/lro.test.ts | 159 ++++++++++++- .../typespec-autorest/test/options.test.ts | 93 ++++++++ packages/typespec-azure-core/README.md | 19 ++ .../typespec-azure-core/lib/decorators.tsp | 18 ++ .../typespec-azure-core/src/decorators.ts | 215 +++++++++++++++++- packages/typespec-azure-core/src/lib.ts | 8 + .../typespec-azure-core/src/lro-helpers.ts | 9 +- .../test/decorators.test.ts | 75 ++++++ .../samples/azure-core.tsp | 6 +- .../lib/operations.tsp | 36 +-- .../lib/responses.tsp | 11 +- .../test/lro-metadata.test.ts | 4 +- 53 files changed, 1474 insertions(+), 232 deletions(-) create mode 100644 .chronus/changes/arm-lro-opt-2024-5-5-15-31-47.md create mode 100644 .chronus/changes/arm-lro-opt-2024-5-5-15-33-29.md create mode 100644 .chronus/changes/arm-lro-opt-2024-5-5-19-32-9.md create mode 100644 .chronus/changes/arm-lro-opt-2024-5-5-2-57-50.md diff --git a/.chronus/changes/arm-lro-opt-2024-5-5-15-31-47.md b/.chronus/changes/arm-lro-opt-2024-5-5-15-31-47.md new file mode 100644 index 0000000000..eebafe6bc1 --- /dev/null +++ b/.chronus/changes/arm-lro-opt-2024-5-5-15-31-47.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-azure-core" +--- + +Add override decorator @useFinalStateVia for lro resolution when multiple resolution pathways exist \ No newline at end of file diff --git a/.chronus/changes/arm-lro-opt-2024-5-5-15-33-29.md b/.chronus/changes/arm-lro-opt-2024-5-5-15-33-29.md new file mode 100644 index 0000000000..e56a573539 --- /dev/null +++ b/.chronus/changes/arm-lro-opt-2024-5-5-15-33-29.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Remove OpenAPI dependencies from ARM LRO templates and test LRO overrides \ No newline at end of file diff --git a/.chronus/changes/arm-lro-opt-2024-5-5-19-32-9.md b/.chronus/changes/arm-lro-opt-2024-5-5-19-32-9.md new file mode 100644 index 0000000000..5a9d225023 --- /dev/null +++ b/.chronus/changes/arm-lro-opt-2024-5-5-19-32-9.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@azure-tools/typespec-autorest" +--- + +Add suppress-lro-options emitter option to control emission of x-ms-long-running-operation-options \ No newline at end of file diff --git a/.chronus/changes/arm-lro-opt-2024-5-5-2-57-50.md b/.chronus/changes/arm-lro-opt-2024-5-5-2-57-50.md new file mode 100644 index 0000000000..16b8e22136 --- /dev/null +++ b/.chronus/changes/arm-lro-opt-2024-5-5-2-57-50.md @@ -0,0 +1,9 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: feature +packages: + - "@azure-tools/typespec-autorest" + +--- + +- Add support for displaying lro options in typespec-autorest based on lro metadata diff --git a/docs/emitters/typespec-autorest/reference/emitter.md b/docs/emitters/typespec-autorest/reference/emitter.md index 13979134cd..4bc24450c4 100644 --- a/docs/emitters/typespec-autorest/reference/emitter.md +++ b/docs/emitters/typespec-autorest/reference/emitter.md @@ -119,3 +119,9 @@ This extension is meant for debugging and should not be depended on. **Type:** `boolean` Create read-only property schema for lro status + +### `emit-lro-options` + +**Type:** `"none" | "final-state-only" | "all"` + +Determine whether and how to emit x-ms-long-running-operation-options for lro resolution diff --git a/docs/libraries/azure-core/reference/decorators.md b/docs/libraries/azure-core/reference/decorators.md index fbefed9ebc..3734168336 100644 --- a/docs/libraries/azure-core/reference/decorators.md +++ b/docs/libraries/azure-core/reference/decorators.md @@ -309,6 +309,24 @@ Used to define how to call custom polling operations for long-running operations | --------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | targetParameter | `ModelProperty \| string` | A reference to the polling operation parameter this parameter
provides a value for, or the name of that parameter. The default value is the name of
the decorated parameter or property. | +### `@useFinalStateVia` {#@Azure.Core.useFinalStateVia} + +Overrides the final state value for an operation + +```typespec +@Azure.Core.useFinalStateVia(finalState: valueof "original-uri" | "operation-location" | "location" | "azure-async-operation") +``` + +#### Target + +`Operation` + +#### Parameters + +| Name | Type | Description | +| ---------- | ----------------------------------------------------------------------------------------- | ----------------------------- | +| finalState | `valueof "original-uri" \| "operation-location" \| "location" \| "azure-async-operation"` | The desired final state value | + ## Azure.Core.Foundations ### `@omitKeyProperties` {#@Azure.Core.Foundations.omitKeyProperties} diff --git a/docs/libraries/azure-core/reference/index.mdx b/docs/libraries/azure-core/reference/index.mdx index d6aeb6abd4..5ea11012a4 100644 --- a/docs/libraries/azure-core/reference/index.mdx +++ b/docs/libraries/azure-core/reference/index.mdx @@ -54,6 +54,7 @@ npm install --save-peer @azure-tools/typespec-azure-core - [`@pollingLocation`](./decorators.md#@Azure.Core.pollingLocation) - [`@pollingOperation`](./decorators.md#@Azure.Core.pollingOperation) - [`@pollingOperationParameter`](./decorators.md#@Azure.Core.pollingOperationParameter) +- [`@useFinalStateVia`](./decorators.md#@Azure.Core.useFinalStateVia) ### Interfaces diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 69cc707f99..ab39c24898 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -65,7 +65,7 @@ model Azure.ResourceManager.ArmAcceptedResponse The standard header for asynchronous operation polling ```typespec -model Azure.ResourceManager.ArmAsyncOperationHeader +model Azure.ResourceManager.ArmAsyncOperationHeader ``` #### Template Parameters @@ -74,6 +74,7 @@ model Azure.ResourceManager.ArmAsyncOperationHeader | ------------- | ------------------------------------------------- | | StatusMonitor | The status monitor type for lro polling | | UrlValue | The value type of the Azure-AsyncOperation header | +| FinalResult | The logical final result of the operation | #### Properties diff --git a/packages/samples/specs/data-plane/api-path-parameter/main.tsp b/packages/samples/specs/data-plane/api-path-parameter/main.tsp index 07b8aa4c7a..c3d2ad15d5 100644 --- a/packages/samples/specs/data-plane/api-path-parameter/main.tsp +++ b/packages/samples/specs/data-plane/api-path-parameter/main.tsp @@ -75,7 +75,10 @@ alias Operations = Azure.Core.ResourceOperations; interface Widgets { // Operation Status @doc("Gets status of a Widget operation.") + @sharedRoute getWidgetOperationStatus is Operations.GetResourceOperationStatus; + @sharedRoute + getWidgetDeleteOperationStatus is Operations.GetResourceOperationStatus; // Widget Operations @doc("Creates or updates a Widget asynchronously") @@ -86,7 +89,7 @@ interface Widgets { getWidget is Operations.ResourceRead; @doc("Delete a Widget asynchronously.") - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getWidgetDeleteOperationStatus) deleteWidget is Operations.LongRunningResourceDelete; @doc("List Widget resources") @@ -98,7 +101,10 @@ interface Widgets { interface Manufacturers { @doc("Gets status of a Manufacturer operation.") - getManufacturerOperationStatus is Operations.GetResourceOperationStatus; + getManufacturerDeleteOperationStatus is Operations.GetResourceOperationStatus< + Manufacturer, + never + >; @doc("Creates or replaces a Manufacturer") createOrReplaceManufacturer is Operations.ResourceCreateOrReplace; @@ -107,7 +113,7 @@ interface Manufacturers { getManufacturer is Operations.ResourceRead; @doc("Delete a Manufacturer asynchronously.") - @pollingOperation(Manufacturers.getManufacturerOperationStatus) + @pollingOperation(Manufacturers.getManufacturerDeleteOperationStatus) deleteManufacturer is Operations.LongRunningResourceDelete; @doc("List Manufacturer resources") diff --git a/packages/samples/specs/data-plane/custom-error-type/main.tsp b/packages/samples/specs/data-plane/custom-error-type/main.tsp index df59f09165..7b7c262f87 100644 --- a/packages/samples/specs/data-plane/custom-error-type/main.tsp +++ b/packages/samples/specs/data-plane/custom-error-type/main.tsp @@ -59,7 +59,11 @@ alias Operations = Azure.Core.ResourceOperations; + /** Gets the status of a Widget delete operation */ + @sharedRoute + getWidgetDeleteOperationStatus is Operations.GetResourceOperationStatus; // Widget Operations @doc("Creates or updates a Widget asynchronously") @@ -70,7 +74,7 @@ interface Widgets { getWidget is Operations.ResourceRead; @doc("Delete a Widget asynchronously.") - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getWidgetDeleteOperationStatus) deleteWidget is Operations.LongRunningResourceDelete; @doc("List Widget resources") diff --git a/packages/samples/specs/data-plane/trait-versioning/main.tsp b/packages/samples/specs/data-plane/trait-versioning/main.tsp index d08af0a567..ac10a1f34c 100644 --- a/packages/samples/specs/data-plane/trait-versioning/main.tsp +++ b/packages/samples/specs/data-plane/trait-versioning/main.tsp @@ -69,8 +69,12 @@ alias Operations = Azure.Core.ResourceOperations; interface Widgets { // Operation Status + @sharedRoute @doc("Gets status of a Widget operation.") getWidgetOperationStatus is Operations.GetResourceOperationStatus; + @doc("Gets status of a Widget delete operation.") + @sharedRoute + getWidgetDeleteOperationStatus is Operations.GetResourceOperationStatus; // Widget Operations @doc("Creates or updates a Widget asynchronously") @@ -81,7 +85,7 @@ interface Widgets { getWidget is Operations.ResourceRead; @doc("Delete a Widget asynchronously.") - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getWidgetDeleteOperationStatus) deleteWidget is Operations.LongRunningResourceDelete; @doc("List Widget resources") @@ -92,8 +96,11 @@ interface Widgets { } interface Manufacturers { - @doc("Gets status of a Manufacturer operation.") - getManufacturerOperationStatus is Operations.GetResourceOperationStatus; + @doc("Gets status of a Manufacturer delete operation.") + getManufacturerDeleteOperationStatus is Operations.GetResourceOperationStatus< + Manufacturer, + never + >; @doc("Creates or replaces a Manufacturer") createOrReplaceManufacturer is Operations.ResourceCreateOrReplace; @@ -102,7 +109,7 @@ interface Manufacturers { getManufacturer is Operations.ResourceRead; @doc("Delete a Manufacturer asynchronously.") - @pollingOperation(Manufacturers.getManufacturerOperationStatus) + @pollingOperation(Manufacturers.getManufacturerDeleteOperationStatus) deleteManufacturer is Operations.LongRunningResourceDelete; @doc("List Manufacturer resources") diff --git a/packages/samples/specs/data-plane/widget-manager/main.tsp b/packages/samples/specs/data-plane/widget-manager/main.tsp index e39be4c2bd..83119910f9 100644 --- a/packages/samples/specs/data-plane/widget-manager/main.tsp +++ b/packages/samples/specs/data-plane/widget-manager/main.tsp @@ -173,7 +173,11 @@ alias Operations = Azure.Core.ResourceOperations; interface Widgets { // Operation Status @doc("Gets status of a Widget operation.") + @sharedRoute getWidgetOperationStatus is Operations.GetResourceOperationStatus; + @doc("Gets status of a Widget delete operation.") + @sharedRoute + getWidgetDeleteOperationStatus is Operations.GetResourceOperationStatus; // Widget Operations @doc("Creates or updates a Widget asynchronously") @@ -184,7 +188,7 @@ interface Widgets { getWidget is Operations.ResourceRead; @doc("Delete a Widget asynchronously.") - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getWidgetDeleteOperationStatus) deleteWidget is Operations.LongRunningResourceDelete; @doc("List Widget resources") @@ -207,7 +211,7 @@ interface Widgets { getRepairStatus is Foundations.GetOperationStatus; @doc("Schedule a widget for repairs.") - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getRepairStatus) scheduleRepairs is Operations.LongRunningResourceAction< Widget, WidgetRepairRequest, @@ -217,7 +221,7 @@ interface Widgets { interface WidgetParts { @doc("Gets status of a WidgetPart operation.") - getWidgetPartOperationStatus is Operations.GetResourceOperationStatus; + getWidgetPartReorderOperationStatus is Operations.GetResourceOperationStatus; @doc("Creates a WidgetPart") createWidgetPart is Operations.ResourceCreateWithServiceProvidedName; @@ -232,7 +236,7 @@ interface WidgetParts { listWidgetParts is Operations.ResourceList; @doc("Reorder all parts for the widget.") - @pollingOperation(WidgetParts.getWidgetPartOperationStatus) + @pollingOperation(WidgetParts.getWidgetPartReorderOperationStatus) reorderParts is Operations.LongRunningResourceCollectionAction< WidgetPart, WidgetPartReorderRequest, @@ -241,8 +245,11 @@ interface WidgetParts { } interface Manufacturers { - @doc("Gets status of a Manufacturer operation.") - getManufacturerOperationStatus is Operations.GetResourceOperationStatus; + @doc("Gets status of a Manufacturer delete operation.") + getManufacturerDeleteOperationStatus is Operations.GetResourceOperationStatus< + Manufacturer, + never + >; @doc("Creates or replaces a Manufacturer") createOrReplaceManufacturer is Operations.ResourceCreateOrReplace; @@ -251,7 +258,7 @@ interface Manufacturers { getManufacturer is Operations.ResourceRead; @doc("Delete a Manufacturer asynchronously.") - @pollingOperation(Manufacturers.getManufacturerOperationStatus) + @pollingOperation(Manufacturers.getManufacturerDeleteOperationStatus) deleteManufacturer is Operations.LongRunningResourceDelete; @doc("List Manufacturer resources") diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json index d0d45aca02..efa0056d84 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -380,12 +380,15 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, "/api/{api-version}/manufacturers/{manufacturerId}/operations/{operationId}": { "get": { - "operationId": "Manufacturers_GetManufacturerOperationStatus", + "operationId": "Manufacturers_GetManufacturerDeleteOperationStatus", "description": "Gets status of a Manufacturer operation.", "parameters": [ { @@ -424,10 +427,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/Manufacturer", - "description": "The result of the operation." } }, "required": [ @@ -773,6 +772,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true }, "delete": { @@ -886,6 +888,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -958,6 +963,72 @@ } } }, + "x-ms-paths": { + "/api/{api-version}/widgets/{widgetName}/operations/{operationId}?_overload=getWidgetDeleteOperationStatus": { + "get": { + "operationId": "Widgets_GetWidgetDeleteOperationStatus", + "description": "Resource operation status operation template.", + "parameters": [ + { + "$ref": "#/parameters/ApiVersionPathParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + } + }, "definitions": { "Azure.Core.Foundations.Error": { "type": "object", diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml index b2f168ce4e..4be8a90a71 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml @@ -237,7 +237,7 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /api/{api-version}/manufacturers/{manufacturerId}/operations/{operationId}: get: - operationId: Manufacturers_getManufacturerOperationStatus + operationId: Manufacturers_getManufacturerDeleteOperationStatus description: Gets status of a Manufacturer operation. parameters: - $ref: '#/components/parameters/ApiVersionPathParameter' @@ -275,10 +275,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Manufacturer' - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. @@ -578,8 +574,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /api/{api-version}/widgets/{widgetName}/operations/{operationId}: get: - operationId: Widgets_getWidgetOperationStatus - description: Gets status of a Widget operation. + operationId: Widgets_getWidgetOperationStatus_Widgets_getWidgetDeleteOperationStatus + description: Gets status of a Widget operation. Resource operation status operation template. parameters: - $ref: '#/components/parameters/ApiVersionPathParameter' - name: widgetName @@ -600,27 +596,45 @@ paths: content: application/json: schema: - type: object - required: - - id - - status - properties: - id: - type: string - description: The unique ID of the operation. - status: - allOf: - - $ref: '#/components/schemas/OperationState' - description: The status of the operation - error: - allOf: - - $ref: '#/components/schemas/Azure.Core.Foundations.Error' - description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Widget' - description: The result of the operation. - description: Provides status details for long running operations. + anyOf: + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/Widget' + description: The result of the operation. + description: Provides status details for long running operations. + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + description: Provides status details for long running operations. default: description: An unexpected error response. headers: diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 2fed197afe..d5c3b5df7f 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -275,6 +275,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true }, "delete": { @@ -382,6 +385,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -448,6 +454,66 @@ } } }, + "x-ms-paths": { + "/widgets/{widgetName}/operations/{operationId}?_overload=getWidgetDeleteOperationStatus": { + "get": { + "operationId": "Widgets_GetWidgetDeleteOperationStatus", + "description": "Gets the status of a Widget delete operation", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/WidgetServiceErrorResponse" + } + } + } + } + } + }, "definitions": { "Azure.Core.Foundations.Error": { "type": "object", diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml index 662608e3c6..fcf9160edb 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml @@ -229,8 +229,8 @@ paths: $ref: '#/components/schemas/WidgetServiceErrorResponse' /widgets/{widgetName}/operations/{operationId}: get: - operationId: Widgets_getWidgetOperationStatus - description: Gets status of a Widget operation. + operationId: Widgets_getWidgetOperationStatus_Widgets_getWidgetDeleteOperationStatus + description: Gets status of a Widget operation. Gets the status of a Widget delete operation parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: widgetName @@ -251,27 +251,45 @@ paths: content: application/json: schema: - type: object - required: - - id - - status - properties: - id: - type: string - description: The unique ID of the operation. - status: - allOf: - - $ref: '#/components/schemas/OperationState' - description: The status of the operation - error: - allOf: - - $ref: '#/components/schemas/Azure.Core.Foundations.Error' - description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Widget' - description: The result of the operation. - description: Provides status details for long running operations. + anyOf: + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/Widget' + description: The result of the operation. + description: Provides status details for long running operations. + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + description: Provides status details for long running operations. default: description: An unexpected error response. content: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 224c3e5204..238c64ce80 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -332,13 +332,16 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, "/manufacturers/{manufacturerId}/operations/{operationId}": { "get": { - "operationId": "Manufacturers_GetManufacturerOperationStatus", - "description": "Gets status of a Manufacturer operation.", + "operationId": "Manufacturers_GetManufacturerDeleteOperationStatus", + "description": "Gets status of a Manufacturer delete operation.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -376,10 +379,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/Manufacturer", - "description": "The result of the operation." } }, "required": [ @@ -689,6 +688,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true }, "delete": { @@ -790,6 +792,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -862,6 +867,72 @@ } } }, + "x-ms-paths": { + "/widgets/{widgetName}/operations/{operationId}?_overload=getWidgetDeleteOperationStatus": { + "get": { + "operationId": "Widgets_GetWidgetDeleteOperationStatus", + "description": "Gets status of a Widget delete operation.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + } + }, "definitions": { "Azure.Core.Foundations.Error": { "type": "object", diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json index 2480975904..3c994233e5 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json @@ -380,13 +380,16 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, "/manufacturers/{manufacturerId}/operations/{operationId}": { "get": { - "operationId": "Manufacturers_GetManufacturerOperationStatus", - "description": "Gets status of a Manufacturer operation.", + "operationId": "Manufacturers_GetManufacturerDeleteOperationStatus", + "description": "Gets status of a Manufacturer delete operation.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -424,10 +427,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/Manufacturer", - "description": "The result of the operation." } }, "required": [ @@ -773,6 +772,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true }, "delete": { @@ -886,6 +888,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -958,6 +963,72 @@ } } }, + "x-ms-paths": { + "/widgets/{widgetName}/operations/{operationId}?_overload=getWidgetDeleteOperationStatus": { + "get": { + "operationId": "Widgets_GetWidgetDeleteOperationStatus", + "description": "Gets status of a Widget delete operation.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + } + }, "definitions": { "Azure.Core.Foundations.Error": { "type": "object", diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml index b5e41e4703..489042be2c 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml @@ -210,8 +210,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /manufacturers/{manufacturerId}/operations/{operationId}: get: - operationId: Manufacturers_getManufacturerOperationStatus - description: Gets status of a Manufacturer operation. + operationId: Manufacturers_getManufacturerDeleteOperationStatus + description: Gets status of a Manufacturer delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: manufacturerId @@ -248,10 +248,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Manufacturer' - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. @@ -524,8 +520,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /widgets/{widgetName}/operations/{operationId}: get: - operationId: Widgets_getWidgetOperationStatus - description: Gets status of a Widget operation. + operationId: Widgets_getWidgetOperationStatus_Widgets_getWidgetDeleteOperationStatus + description: Gets status of a Widget operation. Gets status of a Widget delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: widgetName @@ -546,27 +542,45 @@ paths: content: application/json: schema: - type: object - required: - - id - - status - properties: - id: - type: string - description: The unique ID of the operation. - status: - allOf: - - $ref: '#/components/schemas/OperationState' - description: The status of the operation - error: - allOf: - - $ref: '#/components/schemas/Azure.Core.Foundations.Error' - description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Widget' - description: The result of the operation. - description: Provides status details for long running operations. + anyOf: + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/Widget' + description: The result of the operation. + description: Provides status details for long running operations. + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + description: Provides status details for long running operations. default: description: An unexpected error response. headers: diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml index 09b469a1f2..804261e13c 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml @@ -237,8 +237,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /manufacturers/{manufacturerId}/operations/{operationId}: get: - operationId: Manufacturers_getManufacturerOperationStatus - description: Gets status of a Manufacturer operation. + operationId: Manufacturers_getManufacturerDeleteOperationStatus + description: Gets status of a Manufacturer delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: manufacturerId @@ -275,10 +275,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Manufacturer' - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. @@ -578,8 +574,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /widgets/{widgetName}/operations/{operationId}: get: - operationId: Widgets_getWidgetOperationStatus - description: Gets status of a Widget operation. + operationId: Widgets_getWidgetOperationStatus_Widgets_getWidgetDeleteOperationStatus + description: Gets status of a Widget operation. Gets status of a Widget delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: widgetName @@ -600,27 +596,45 @@ paths: content: application/json: schema: - type: object - required: - - id - - status - properties: - id: - type: string - description: The unique ID of the operation. - status: - allOf: - - $ref: '#/components/schemas/OperationState' - description: The status of the operation - error: - allOf: - - $ref: '#/components/schemas/Azure.Core.Foundations.Error' - description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Widget' - description: The result of the operation. - description: Provides status details for long running operations. + anyOf: + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/Widget' + description: The result of the operation. + description: Provides status details for long running operations. + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + description: Provides status details for long running operations. default: description: An unexpected error response. headers: diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index bff35fe74b..49b7c56657 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -380,13 +380,16 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, "/manufacturers/{manufacturerId}/operations/{operationId}": { "get": { - "operationId": "Manufacturers_GetManufacturerOperationStatus", - "description": "Gets status of a Manufacturer operation.", + "operationId": "Manufacturers_GetManufacturerDeleteOperationStatus", + "description": "Gets status of a Manufacturer delete operation.", "parameters": [ { "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" @@ -424,10 +427,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/Manufacturer", - "description": "The result of the operation." } }, "required": [ @@ -773,6 +772,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true }, "delete": { @@ -886,6 +888,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -1006,6 +1011,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -1605,7 +1613,7 @@ }, "/widgets/{widgetName}/parts/{widgetPartName}/operations/{operationId}": { "get": { - "operationId": "WidgetParts_GetWidgetPartOperationStatus", + "operationId": "WidgetParts_GetWidgetPartReorderOperationStatus", "description": "Gets status of a WidgetPart operation.", "parameters": [ { @@ -1651,10 +1659,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "$ref": "#/definitions/WidgetPart", - "description": "The result of the operation." } }, "required": [ @@ -1786,6 +1790,9 @@ } } }, + "x-ms-long-running-operation-options": { + "final-state-via": "operation-location" + }, "x-ms-long-running-operation": true } }, @@ -1854,6 +1861,72 @@ } } }, + "x-ms-paths": { + "/widgets/{widgetName}/operations/{operationId}?_overload=getWidgetDeleteOperationStatus": { + "get": { + "operationId": "Widgets_GetWidgetDeleteOperationStatus", + "description": "Gets status of a Widget delete operation.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The widget name.", + "required": true, + "type": "string" + }, + { + "name": "operationId", + "in": "path", + "description": "The unique ID of the operation.", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "type": "object", + "description": "Provides status details for long running operations.", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the operation." + }, + "status": { + "$ref": "#/definitions/Azure.Core.Foundations.OperationState", + "description": "The status of the operation" + }, + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "Error object that describes the error when status is \"Failed\"." + } + }, + "required": [ + "id", + "status" + ] + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + } + }, "definitions": { "Azure.Core.Foundations.Error": { "type": "object", diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index e3dac09e94..37f1c4fad9 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -237,8 +237,8 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /manufacturers/{manufacturerId}/operations/{operationId}: get: - operationId: Manufacturers_getManufacturerOperationStatus - description: Gets status of a Manufacturer operation. + operationId: Manufacturers_getManufacturerDeleteOperationStatus + description: Gets status of a Manufacturer delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: manufacturerId @@ -275,10 +275,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Manufacturer' - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. @@ -759,8 +755,8 @@ paths: $ref: '#/components/schemas/WidgetAnalyticsCreateOrUpdate' /widgets/{widgetName}/operations/{operationId}: get: - operationId: Widgets_getWidgetOperationStatus - description: Gets status of a Widget operation. + operationId: Widgets_getWidgetOperationStatus_Widgets_getWidgetDeleteOperationStatus + description: Gets status of a Widget operation. Gets status of a Widget delete operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' - name: widgetName @@ -781,27 +777,45 @@ paths: content: application/json: schema: - type: object - required: - - id - - status - properties: - id: - type: string - description: The unique ID of the operation. - status: - allOf: - - $ref: '#/components/schemas/OperationState' - description: The status of the operation - error: - allOf: - - $ref: '#/components/schemas/Azure.Core.Foundations.Error' - description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/Widget' - description: The result of the operation. - description: Provides status details for long running operations. + anyOf: + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/Widget' + description: The result of the operation. + description: Provides status details for long running operations. + - type: object + required: + - id + - status + properties: + id: + type: string + description: The unique ID of the operation. + status: + allOf: + - $ref: '#/components/schemas/OperationState' + description: The status of the operation + error: + allOf: + - $ref: '#/components/schemas/Azure.Core.Foundations.Error' + description: Error object that describes the error when status is "Failed". + description: Provides status details for long running operations. default: description: An unexpected error response. headers: @@ -1018,7 +1032,7 @@ paths: $ref: '#/components/schemas/Azure.Core.Foundations.ErrorResponse' /widgets/{widgetName}/parts/{widgetPartName}/operations/{operationId}: get: - operationId: WidgetParts_getWidgetPartOperationStatus + operationId: WidgetParts_getWidgetPartReorderOperationStatus description: Gets status of a WidgetPart operation. parameters: - $ref: '#/components/parameters/Azure.Core.Foundations.ApiVersionParameter' @@ -1062,10 +1076,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - allOf: - - $ref: '#/components/schemas/WidgetPart' - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. diff --git a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json index e64a5f5311..c51ac0ef33 100644 --- a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json @@ -177,6 +177,10 @@ "$ref": "#/definitions/Microsoft.InterfacesTest.TestExtensionResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", @@ -436,6 +440,10 @@ "$ref": "#/definitions/Microsoft.InterfacesTest.TestTenantResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", @@ -778,6 +786,10 @@ "$ref": "#/definitions/AllPropertiesResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", @@ -1253,6 +1265,10 @@ "$ref": "#/definitions/Microsoft.InterfacesTest.TestTrackedResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", @@ -1529,6 +1545,10 @@ "$ref": "#/definitions/Microsoft.InterfacesTest.TestTrackedChild" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json index f413392fac..26f450a967 100644 --- a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json @@ -237,6 +237,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 6e0d4c499d..8f2c907e51 100644 --- a/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -237,6 +237,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json index 70e4581c32..55d9acba80 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json @@ -237,6 +237,10 @@ "$ref": "#/definitions/WidgetResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json index 720e17dcba..260e62648b 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json @@ -242,6 +242,10 @@ "$ref": "#/definitions/TestTrackedResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json index 0703111702..dd52faa934 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json @@ -242,6 +242,10 @@ "$ref": "#/definitions/TestTrackedResource" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 2ee82524a3..b1a17b9ae5 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -163,6 +163,10 @@ "$ref": "#/definitions/RoleAssignment" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 0382c5b3f1..5b1ee9e4c1 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -212,6 +212,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 38d01ad902..3d4924b7bf 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -240,6 +240,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", @@ -538,6 +542,10 @@ "$ref": "#/definitions/Dependent" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 0a7ddbb8f4..7615e63f83 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -187,6 +187,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index b53b27f57d..a882b24dea 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -154,6 +154,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 161c075401..eae05cf8bc 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -237,6 +237,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index a10528b874..2a67c3d2b7 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -251,6 +251,10 @@ "$ref": "#/definitions/Employee" }, "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, "Retry-After": { "type": "integer", "format": "int32", diff --git a/packages/typespec-autorest/README.md b/packages/typespec-autorest/README.md index c9425dbb81..d0e5b6e3d1 100644 --- a/packages/typespec-autorest/README.md +++ b/packages/typespec-autorest/README.md @@ -124,6 +124,12 @@ This extension is meant for debugging and should not be depended on. Create read-only property schema for lro status +#### `emit-lro-options` + +**Type:** `"none" | "final-state-only" | "all"` + +Determine whether and how to emit x-ms-long-running-operation-options for lro resolution + ## Decorators ### Autorest diff --git a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp index d0d7a5adf8..c0cac240ec 100644 --- a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp +++ b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp @@ -156,6 +156,8 @@ How to determine the final state of the operation. Possible Values: | "original-uri" | "operation-location" | "final-state-schema"; + + `final-state-schema`?: string; } /** Describes the 'x-ms-examples' extension. */ diff --git a/packages/typespec-autorest/src/emit.ts b/packages/typespec-autorest/src/emit.ts index 565d6dcab9..abeecf1f7a 100644 --- a/packages/typespec-autorest/src/emit.ts +++ b/packages/typespec-autorest/src/emit.ts @@ -90,6 +90,7 @@ export function resolveAutorestOptions( includeXTypeSpecName: resolvedOptions["include-x-typespec-name"], armTypesDir, useReadOnlyStatusSchema: resolvedOptions["use-read-only-status-schema"], + emitLroOptions: resolvedOptions["emit-lro-options"], }; } diff --git a/packages/typespec-autorest/src/lib.ts b/packages/typespec-autorest/src/lib.ts index 855434046a..11d002f7fd 100644 --- a/packages/typespec-autorest/src/lib.ts +++ b/packages/typespec-autorest/src/lib.ts @@ -84,6 +84,12 @@ export interface AutorestEmitterOptions { * @default false */ "use-read-only-status-schema"?: boolean; + + /** + * Determines whether and how to emit the x-ms-long-running-operation-options + * @default "final-state-only" + */ + "emit-lro-options"?: "none" | "final-state-only" | "all"; } const EmitterOptionsSchema: JSONSchemaType = { @@ -179,6 +185,14 @@ const EmitterOptionsSchema: JSONSchemaType = { default: false, description: "Create read-only property schema for lro status", }, + "emit-lro-options": { + type: "string", + enum: ["none", "final-state-only", "all"], + nullable: true, + default: "final-state-only", + description: + "Determine whether and how to emit x-ms-long-running-operation-options for lro resolution", + }, }, required: [], }; diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index 8c46f7e7f8..df257b3d38 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -1,4 +1,6 @@ import { + FinalStateValue, + LroMetadata, PagedResultMetadata, UnionEnum, extractLroStates, @@ -144,6 +146,7 @@ import { OpenAPI2StatusCode, PrimitiveItems, Refable, + XMSLongRunningFinalState, } from "./openapi2-document.js"; import type { AutorestEmitterResult, LoadedExample } from "./types.js"; import { AutorestEmitterContext, getClientName, resolveOperationId } from "./utils.js"; @@ -185,6 +188,13 @@ export interface AutorestDocumentEmitterOptions { * @default "omit" */ readonly versionEnumStrategy?: "omit" | "include"; + + /** + * Determines whether and how to emit x-ms-long-running-operation-options + * to describe resolution of asynchronous operations + * @default "final-state-only" + */ + readonly emitLroOptions?: "none" | "final-state-only" | "all"; } /** @@ -486,6 +496,45 @@ export async function getOpenAPIForService( return path.replace(/\/?\?.*/, ""); } + function getFinalStateVia(metadata: LroMetadata): XMSLongRunningFinalState | undefined { + switch (metadata.finalStateVia) { + case FinalStateValue.azureAsyncOperation: + return "azure-async-operation"; + case FinalStateValue.location: + return "location"; + case FinalStateValue.operationLocation: + return "operation-location"; + case FinalStateValue.originalUri: + return "original-uri"; + default: + return undefined; + } + } + + function getFinalStateSchema(metadata: LroMetadata): { "final-state-schema": Ref } | undefined { + if ( + metadata.finalResult !== undefined && + metadata.finalResult !== "void" && + metadata.finalResult.name.length > 0 + ) { + const model: Model = metadata.finalResult; + const schemaOrRef = resolveExternalRef(metadata.finalResult); + + if (schemaOrRef !== undefined) { + const ref = new Ref(); + ref.value = schemaOrRef.$ref; + return { "final-state-schema": ref }; + } + const pending = pendingSchemas.getOrAdd(metadata.finalResult, Visibility.Read, () => ({ + type: model, + visibility: Visibility.Read, + ref: refs.getOrAdd(model, Visibility.Read, () => new Ref()), + })); + return { "final-state-schema": pending.ref }; + } + return undefined; + } + function emitOperation(operation: HttpOperation) { let { path: fullPath, operation: op, verb, parameters } = operation; let pathsObject: Record = root.paths; @@ -548,6 +597,24 @@ export async function getOpenAPIForService( // which does have LRO metadata. if (lroMetadata !== undefined && operation.verb !== "get") { currentEndpoint["x-ms-long-running-operation"] = true; + if (options.emitLroOptions !== "none") { + const finalState = getFinalStateVia(lroMetadata); + if (finalState !== undefined) { + const finalSchema = getFinalStateSchema(lroMetadata); + let lroOptions = { + "final-state-via": finalState, + }; + + if (finalSchema !== undefined && options.emitLroOptions === "all") { + lroOptions = { + "final-state-via": finalState, + ...finalSchema, + }; + } + + currentEndpoint["x-ms-long-running-operation-options"] = lroOptions; + } + } } // Extract paged metadata from Azure.Core.Page diff --git a/packages/typespec-autorest/src/openapi2-document.ts b/packages/typespec-autorest/src/openapi2-document.ts index b6d041394e..1afef8fb0b 100644 --- a/packages/typespec-autorest/src/openapi2-document.ts +++ b/packages/typespec-autorest/src/openapi2-document.ts @@ -451,6 +451,21 @@ export type OpenAPI2Operation = Extensions & { "x-ms-examples"?: Record>; "x-ms-long-running-operation"?: boolean; + + "x-ms-long-running-operation-options"?: XMSLongRunningOperationOptions; +}; + +export type XMSLongRunningFinalState = + | "azure-async-operation" + | "location" + | "original-uri" + | "operation-location" + | "final-state-schema"; + +export type XMSLongRunningOperationOptions = { + "final-state-via": XMSLongRunningFinalState; + + "final-state-schema"?: string; }; export type OpenAPI2StatusCode = string | "default" | "1XX" | "2XX" | "3XX" | "4XX" | "5XX"; diff --git a/packages/typespec-autorest/test/lro.test.ts b/packages/typespec-autorest/test/lro.test.ts index f6c54919f8..f2c74c57f0 100644 --- a/packages/typespec-autorest/test/lro.test.ts +++ b/packages/typespec-autorest/test/lro.test.ts @@ -1,3 +1,4 @@ +import { paramMessage } from "@typespec/compiler"; import { deepStrictEqual } from "assert"; import { describe, it } from "vitest"; import { openApiFor } from "./test-host.js"; @@ -55,13 +56,22 @@ describe("typespec-autorest: Long-running Operations", () => { @pollingOperation(getWidgetOperationStatus) op createOrUpdateWidget is Operations.LongRunningResourceCreateOrUpdate; - ` + `, + undefined, + { "emit-lro-options": "all" } ); deepStrictEqual( openapi.paths["/widgets/{widgetName}"].patch["x-ms-long-running-operation"], true ); + deepStrictEqual( + openapi.paths["/widgets/{widgetName}"].patch["x-ms-long-running-operation-options"], + { + "final-state-via": "operation-location", + "final-state-schema": "#/definitions/Widget", + } + ); deepStrictEqual( openapi.paths["/widgets/{widgetName}/operations/{operationId}"].get[ "x-ms-long-running-operation" @@ -69,4 +79,151 @@ describe("typespec-autorest: Long-running Operations", () => { undefined ); }); + + const armCode = paramMessage` + @armProviderNamespace + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Test; + + interface Operations extends Azure.ResourceManager.Operations {} + + @doc("The state of the resource") + enum ResourceState { + Succeeded, + Canceled, + Failed + } + + @doc("The widget properties") + model WidgetProperties { + @doc("I am a simple Resource Identifier") + simpleArmId: Azure.Core.armResourceIdentifier; + + @doc("The provisioning State") + provisioningState: ResourceState; + } + + @doc("Foo resource") + model Widget is TrackedResource { + @doc("Widget name") + @key("widgetName") + @segment("widgets") + @path + name: string; + } + @armResourceOperations(Widget) + interface Widgets { + get is ArmResourceRead; + ${"putOp"} + update is ArmResourcePatchAsync; + delete is ArmResourceDeleteWithoutOkAsync; + restart is ArmResourceActionAsync; + munge is ArmResourceActionAsync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; + } + `; + it("includes x-ms-long-running-operation-options for ARM operations", async () => { + const openapi = await openApiFor( + armCode.apply(armCode, [ + { putOp: "createOrUpdate is ArmResourceCreateOrReplaceAsync;" }, + ]), + undefined, + { "emit-lro-options": "all" } + ); + + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "azure-async-operation", + "final-state-schema": "#/definitions/Widget", + }); + + deepStrictEqual(openapi.paths[itemPath].patch["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].patch["x-ms-long-running-operation-options"], { + "final-state-via": "location", + "final-state-schema": "#/definitions/Widget", + }); + + deepStrictEqual(openapi.paths[itemPath].delete["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].delete["x-ms-long-running-operation-options"], { + "final-state-via": "location", + }); + const restartPath = `${itemPath}/restart`; + deepStrictEqual(openapi.paths[restartPath].post["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[restartPath].post["x-ms-long-running-operation-options"], { + "final-state-via": "location", + }); + const mungePath = `${itemPath}/munge`; + deepStrictEqual(openapi.paths[mungePath].post["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[mungePath].post["x-ms-long-running-operation-options"], { + "final-state-via": "location", + "final-state-schema": "#/definitions/Widget", + }); + }); + it("Uses final-state-via: location when location is provided for ARM PUT", async () => { + const openapi = await openApiFor( + armCode.apply(armCode, [ + { + putOp: + "createOrUpdate is ArmResourceCreateOrReplaceAsync & Azure.Core.Foundations.RetryAfterHeader>;", + }, + ]), + undefined, + { "emit-lro-options": "all" } + ); + + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "location", + "final-state-schema": "#/definitions/Widget", + }); + }); + it("Uses final-state-via: original-uri when no lro headers are provided for ARM PUT", async () => { + const openapi = await openApiFor( + armCode.apply(armCode, [ + { + putOp: + "createOrUpdate is ArmResourceCreateOrReplaceAsync;", + }, + ]), + undefined, + { "emit-lro-options": "all" } + ); + + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "original-uri", + "final-state-schema": "#/definitions/Widget", + }); + }); + + it("Allows azure-async-operation override without headers for ARM PUT", async () => { + const openapi = await openApiFor( + armCode.apply(armCode, [ + { + putOp: `#suppress "@azure-tools/typespec-azure-core/invalid-final-state" "test" + @useFinalStateVia("azure-async-operation") + createOrUpdate is ArmResourceCreateOrReplaceAsync; + `, + }, + ]), + undefined, + { "emit-lro-options": "all" } + ); + + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(openapi.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "azure-async-operation", + "final-state-schema": "#/definitions/Widget", + }); + }); }); diff --git a/packages/typespec-autorest/test/options.test.ts b/packages/typespec-autorest/test/options.test.ts index 8e9d23bb14..365aacb655 100644 --- a/packages/typespec-autorest/test/options.test.ts +++ b/packages/typespec-autorest/test/options.test.ts @@ -292,4 +292,97 @@ op test(): void; strictEqual(prop["x-typespec-name"], `string[]`); }); }); + + describe("'suppress-lro-options' option", () => { + const lroCode = ` + @armProviderNamespace + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Test; + + interface Operations extends Azure.ResourceManager.Operations {} + + @doc("The state of the resource") + enum ResourceState { + Succeeded, + Canceled, + Failed + } + + @doc("The widget properties") + model WidgetProperties { + @doc("I am a simple Resource Identifier") + simpleArmId: Azure.Core.armResourceIdentifier; + + @doc("The provisioning State") + provisioningState: ResourceState; + } + + @doc("Foo resource") + model Widget is TrackedResource { + @doc("Widget name") + @key("widgetName") + @segment("widgets") + @path + name: string; + } + @armResourceOperations(Widget) + interface Widgets { + get is ArmResourceRead; + @Azure.Core.useFinalStateVia("azure-async-operation") + createOrUpdate is ArmResourceCreateOrReplaceAsync; + update is ArmResourcePatchSync; + delete is ArmResourceDeleteSync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; + } + `; + + it("emits all x-ms-long-running-operation-options", async () => { + const output = await openapiWithOptions(lroCode, { "emit-lro-options": "all" }); + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + ok(output.paths[itemPath]); + ok(output.paths[itemPath].put); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "azure-async-operation", + "final-state-schema": "#/definitions/Widget", + }); + }); + + it("emits final-state-via by default", async () => { + const output = await openapiWithOptions(lroCode, {}); + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + ok(output.paths[itemPath]); + ok(output.paths[itemPath].put); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "azure-async-operation", + }); + }); + + it("emits final-state-via when configured", async () => { + const output = await openapiWithOptions(lroCode, { "emit-lro-options": "final-state-only" }); + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + ok(output.paths[itemPath]); + ok(output.paths[itemPath].put); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation-options"], { + "final-state-via": "azure-async-operation", + }); + }); + + it("suppress x-ms-long-running operation options when configured", async () => { + const output = await openapiWithOptions(lroCode, { "emit-lro-options": "none" }); + const itemPath = + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Test/widgets/{widgetName}"; + ok(output.paths[itemPath]); + ok(output.paths[itemPath].put); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation"], true); + deepStrictEqual(output.paths[itemPath].put["x-ms-long-running-operation-options"], undefined); + }); + }); }); diff --git a/packages/typespec-azure-core/README.md b/packages/typespec-azure-core/README.md index 2ba23bff3e..bf19105d4b 100644 --- a/packages/typespec-azure-core/README.md +++ b/packages/typespec-azure-core/README.md @@ -87,6 +87,7 @@ Available ruleSets: - [`@pollingLocation`](#@pollinglocation) - [`@pollingOperation`](#@pollingoperation) - [`@pollingOperationParameter`](#@pollingoperationparameter) +- [`@useFinalStateVia`](#@usefinalstatevia) #### `@finalLocation` @@ -389,6 +390,24 @@ Used to define how to call custom polling operations for long-running operations | --------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | targetParameter | `ModelProperty \| string` | A reference to the polling operation parameter this parameter
provides a value for, or the name of that parameter. The default value is the name of
the decorated parameter or property. | +#### `@useFinalStateVia` + +Overrides the final state value for an operation + +```typespec +@Azure.Core.useFinalStateVia(finalState: valueof "original-uri" | "operation-location" | "location" | "azure-async-operation") +``` + +##### Target + +`Operation` + +##### Parameters + +| Name | Type | Description | +| ---------- | ----------------------------------------------------------------------------------------- | ----------------------------- | +| finalState | `valueof "original-uri" \| "operation-location" \| "location" \| "azure-async-operation"` | The desired final state value | + ### Azure.Core.Foundations - [`@omitKeyProperties`](#@omitkeyproperties) diff --git a/packages/typespec-azure-core/lib/decorators.tsp b/packages/typespec-azure-core/lib/decorators.tsp index f6718e69ee..61a84cdda8 100644 --- a/packages/typespec-azure-core/lib/decorators.tsp +++ b/packages/typespec-azure-core/lib/decorators.tsp @@ -118,6 +118,15 @@ namespace Azure.Core { */ extern dec finalOperation(entity: Operation, linkedOperation: Operation, parameters?: {}); + /** + * Overrides the final state value for an operation + * @param finalState The desired final state value + */ + extern dec useFinalStateVia( + entity: Operation, + finalState: valueof "original-uri" | "operation-location" | "location" | "azure-async-operation" + ); + /** * Identifies that an operation is used to retrieve the next page for paged operations. * @param linkedOperation The linked Operation @@ -197,4 +206,13 @@ namespace Azure.Core.Foundations.Private { target: Scalar, options: ArmResourceIdentifierConfigOptions ); + + /** + * Sets the priority order of default final-state-via options for an operation + * @param states: list of final-state-via options in priority order + */ + extern dec defaultFinalStateVia( + target: TypeSpec.Reflection.Operation, + states: valueof ("operation-location" | "location" | "azure-async-operation")[] + ); } diff --git a/packages/typespec-azure-core/src/decorators.ts b/packages/typespec-azure-core/src/decorators.ts index f65a709591..01633fc728 100644 --- a/packages/typespec-azure-core/src/decorators.ts +++ b/packages/typespec-azure-core/src/decorators.ts @@ -31,9 +31,14 @@ import { UnionVariant, walkPropertiesInherited, } from "@typespec/compiler"; -import { getHttpOperation, getRoutePath } from "@typespec/http"; +import { + getHttpOperation, + getRoutePath, + HttpOperation, + HttpOperationResponse, +} from "@typespec/http"; import { getResourceTypeKey, getSegment, isAutoRoute } from "@typespec/rest"; -import { OperationLink } from "./lro-helpers.js"; +import { FinalStateValue, OperationLink } from "./lro-helpers.js"; import { extractStatusMonitorInfo, getLroOperationInfo, @@ -743,6 +748,7 @@ function extractPollingLocationInfo( pollingModel?: Model | IntrinsicType; finalResult?: Model | IntrinsicType; target: ModelProperty; + useForFinalState?: boolean; } = { target: target }; const pollingModel = options.properties.get(pollingModelKey)?.type; if (pollingModel && pollingModel.kind === "Model") pollingInfo.pollingModel = pollingModel; @@ -765,6 +771,7 @@ function extractStatusMonitorLocationInfo( pollingModel?: Model | IntrinsicType; finalResult?: Model | IntrinsicType; target: ModelProperty; + useForFInalState?: boolean; } ): StatusMonitorPollingLocationInfo | undefined { const kind = options.properties.get(optionsKindKey); @@ -845,6 +852,173 @@ export function getFinalLocationValue( return program.stateMap(finalLocationResultsKey).get(entity); } +const finalStateOverrideKey = createStateSymbol("finalStateOverride"); +/** + * overrides the final state for an lro + * @param context The execution context for the decorator + * @param entity The decorated operation + * @param finalState The desired value for final-state-via + */ +export function $useFinalStateVia( + context: DecoratorContext, + entity: Operation, + finalState: string +) { + const { program } = context; + let finalStateVia: FinalStateValue; + switch (finalState?.toLowerCase()) { + case "original-uri": + finalStateVia = FinalStateValue.originalUri; + break; + case "operation-location": + finalStateVia = FinalStateValue.operationLocation; + break; + case "location": + finalStateVia = FinalStateValue.location; + break; + case "azure-async-operation": + finalStateVia = FinalStateValue.azureAsyncOperation; + break; + default: + reportDiagnostic(program, { + code: "invalid-final-state", + target: entity, + messageId: "badValue", + format: { finalStateValue: finalState }, + }); + return; + } + + const operation = ignoreDiagnostics(getHttpOperation(program, entity)); + const storedValue = validateFinalState(program, operation, finalStateVia); + if (storedValue !== undefined || operation.verb === "put") { + program.stateMap(finalStateOverrideKey).set(entity, finalStateVia); + } + if ( + storedValue === undefined && + [ + FinalStateValue.operationLocation, + FinalStateValue.location, + FinalStateValue.azureAsyncOperation, + ].includes(finalStateVia) + ) { + reportDiagnostic(program, { + code: "invalid-final-state", + target: entity, + messageId: "noHeader", + format: { finalStateValue: finalStateVia }, + }); + } +} + +type LroHeader = "azure-asyncoperation" | "location" | "operation-location"; + +function getLroHeaderName(finalState: FinalStateValue): LroHeader | undefined { + switch (finalState) { + case FinalStateValue.azureAsyncOperation: + return "azure-asyncoperation"; + case FinalStateValue.location: + return "location"; + case FinalStateValue.operationLocation: + return "operation-location"; + default: + return undefined; + } +} + +function getLroHeader(propertyName: string): LroHeader | undefined { + const name = propertyName.toLowerCase(); + switch (name) { + case "azure-asyncoperation": + case "location": + case "operation-location": + return name; + default: + return undefined; + } +} + +function getLroHeaders(response: HttpOperationResponse): Set | undefined { + const result = new Set(); + for (const content of response.responses) { + if (content.headers) { + for (const candidate of Object.keys(content.headers)) { + const headerName = getLroHeader(candidate); + if (headerName !== undefined) { + result.add(headerName); + } + } + } + } + + return result; +} + +function validateFinalState( + program: Program, + operation: HttpOperation, + finalState: FinalStateValue +): FinalStateValue | undefined { + if (finalState === FinalStateValue.originalUri) { + if (operation.verb !== "put") { + reportDiagnostic(program, { + code: "invalid-final-state", + target: operation.operation, + messageId: "notPut", + }); + return undefined; + } + + return FinalStateValue.originalUri; + } + + const header = getLroHeaderName(finalState); + if (header === undefined) { + reportDiagnostic(program, { + code: "invalid-final-state", + target: operation.operation, + messageId: "badValue", + format: { finalStateValue: finalState }, + }); + return undefined; + } + + for (const response of operation.responses) { + const lroHeaders = getLroHeaders(response); + if (lroHeaders?.has(header)) { + return finalState; + } + } + + return undefined; +} + +function validateFinalStates( + program: Program, + operation: Operation, + finalStates: FinalStateValue[] +): FinalStateValue | undefined { + const httpOp = ignoreDiagnostics(getHttpOperation(program, operation)); + for (const state of finalStates) { + if (validateFinalState(program, httpOp, state)) return state; + } + + return undefined; +} + +/** + * Get the overridden final state value for this operation, if any + * @param program The program to process + * @param operation The operation to check for an override value + * @returns The FInalStateValue if it exists, otherwise undefined + */ +export function getFinalStateOverride( + program: Program, + operation: Operation +): FinalStateValue | undefined { + return program.stateMap(finalStateOverrideKey).get(operation); +} + export function $omitKeyProperties(context: DecoratorContext, entity: Model) { // Delete any key properties from the model for (const [key, prop] of entity.properties) { @@ -1294,6 +1468,40 @@ export function getArmResourceIdentifierConfig( return program.stateMap(armResourceIdentifierConfigKey).get(entity); } +export function $defaultFinalStateVia( + context: DecoratorContext, + target: Operation, + states: LroHeader[] +) { + const { program } = context; + const finalStateValues: FinalStateValue[] = []; + for (const finalState of states) { + switch (finalState?.toLowerCase()) { + case "operation-location": + finalStateValues.push(FinalStateValue.operationLocation); + break; + case "location": + finalStateValues.push(FinalStateValue.location); + break; + case "azure-async-operation": + finalStateValues.push(FinalStateValue.azureAsyncOperation); + break; + default: + reportDiagnostic(program, { + code: "invalid-final-state", + target: target, + messageId: "badValue", + format: { finalStateValue: finalState }, + }); + return; + } + } + const storedValue = validateFinalStates(program, target, finalStateValues); + if (storedValue !== undefined) { + program.stateMap(finalStateOverrideKey).set(target, storedValue); + } +} + setTypeSpecNamespace("Foundations", $omitKeyProperties, $requestParameter, $responseProperty); setTypeSpecNamespace( "Foundations.Private", @@ -1303,5 +1511,6 @@ setTypeSpecNamespace( $needsRoute, $ensureVerb, $embeddingVector, - $armResourceIdentifierConfig + $armResourceIdentifierConfig, + $defaultFinalStateVia ); diff --git a/packages/typespec-azure-core/src/lib.ts b/packages/typespec-azure-core/src/lib.ts index 18743de4c2..a3e41a17dd 100644 --- a/packages/typespec-azure-core/src/lib.ts +++ b/packages/typespec-azure-core/src/lib.ts @@ -27,6 +27,14 @@ export const $lib = createTypeSpecLibrary({ default: paramMessage`StatusMonitor has more than one ${"resultType"} property marked with '${"decorator"}'. Ensure that only one property in the model is marked with this decorator.`, }, }, + "invalid-final-state": { + severity: "warning", + messages: { + badValue: paramMessage`Specified final state value '${"finalStateValue"}' is not valid. It must be one of ("operation-location", "original-uri", "location", "azure-async-operation")`, + notPut: "The final state value 'original-uri' can only be used in http PUT operations", + noHeader: paramMessage`There was no header corresponding to the desired final-state-via value '${"finalStateValue"}'.`, + }, + }, "bad-record-type": { severity: "warning", messages: { diff --git a/packages/typespec-azure-core/src/lro-helpers.ts b/packages/typespec-azure-core/src/lro-helpers.ts index e3f5ccbd2c..d4d1761143 100644 --- a/packages/typespec-azure-core/src/lro-helpers.ts +++ b/packages/typespec-azure-core/src/lro-helpers.ts @@ -37,6 +37,7 @@ import { extractLroStates, FinalOperationKey, getFinalLocationValue, + getFinalStateOverride, getLroResult, getOperationLink, getOperationLinks, @@ -572,7 +573,9 @@ function getFinalStateVia( let model: Model | IntrinsicType | undefined = context.originalModel?.name !== undefined ? context.originalModel : undefined; let finalState: FinalStateValue = FinalStateValue.originalUri; + const finalStateOverride = getFinalStateOverride(program, operation); const resOp = getLogicalResourceOperation(program, operation, model); + if (operationAction !== undefined || resOp?.operation === "delete") { finalState = FinalStateValue.operationLocation; model = context.pollingStep?.responseModel ?? context.originalModel; @@ -603,7 +606,7 @@ function getFinalStateVia( } else { finalState = getStatusFromLinkOrReference(program, operation, context.finalStep.target); } - return [finalState, model]; + return [finalStateOverride || finalState, model]; } if ( @@ -613,7 +616,7 @@ function getFinalStateVia( resOp.resourceType !== undefined ) { model = resOp.resourceType; - return [FinalStateValue.originalUri, model]; + return [finalStateOverride || FinalStateValue.originalUri, model]; } // handle actions and delete operations @@ -643,7 +646,7 @@ function getFinalStateVia( } } - return [finalState, model]; + return [finalStateOverride || finalState, model]; } function getLroStatusFromHeaderProperty( diff --git a/packages/typespec-azure-core/test/decorators.test.ts b/packages/typespec-azure-core/test/decorators.test.ts index ee481dd10b..d35bb67b45 100644 --- a/packages/typespec-azure-core/test/decorators.test.ts +++ b/packages/typespec-azure-core/test/decorators.test.ts @@ -8,11 +8,13 @@ import assert, { deepStrictEqual, ok, strictEqual } from "assert"; import { beforeEach, describe, it } from "vitest"; import { OperationLinkMetadata, + getFinalStateOverride, getLongRunningStates, getOperationLinks, getPagedResult, isFixed, } from "../src/decorators.js"; +import { FinalStateValue } from "../src/lro-helpers.js"; import { createAzureCoreTestRunner } from "./test-host.js"; describe("typespec-azure-core: decorators", () => { @@ -729,7 +731,80 @@ describe("typespec-azure-core: decorators", () => { expectDiagnosticEmpty(diagnostics); }); }); + describe("@useFinalStateVia", () => { + it("correctly overrides PUT lro final-state-via", async () => { + const code = ` + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @pollingOperation(bar) + @useFinalStateVia("operation-location") + @test @put op foo(): {@header("Operation-Location") loc: string}; + + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @route("/polling") + @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"}; + `; + const [{ foo }, diagnostics] = await runner.compileAndDiagnose(code); + expectDiagnosticEmpty(diagnostics); + const op = foo as Operation; + + assert.ok(op); + assert.deepStrictEqual(op.kind, "Operation"); + const finalState = getFinalStateOverride(runner.program, op); + assert.deepStrictEqual(finalState, FinalStateValue.operationLocation); + }); + it("emits diagnostic for invalid PUT override", async () => { + const code = ` + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @pollingOperation(bar) + @useFinalStateVia("operation-location") + @test @put op foo(): {loc: string}; + + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @route("/polling") + @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"}; + `; + const diagnostics = await runner.diagnose(code); + expectDiagnostics(diagnostics, { + code: "@azure-tools/typespec-azure-core/invalid-final-state", + message: + "There was no header corresponding to the desired final-state-via value 'operation-location'.", + }); + }); + it("emits error for missing header", async () => { + const code = ` + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @pollingOperation(bar) + @useFinalStateVia("location") + @post op foo(): {}; + + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @route("/polling") + @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"}; + `; + const diagnostics = await runner.diagnose(code); + expectDiagnostics(diagnostics, { + code: "@azure-tools/typespec-azure-core/invalid-final-state", + message: `There was no header corresponding to the desired final-state-via value 'location'.`, + }); + }); + it("emits error for original-uri on non-PUT request", async () => { + const code = ` + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @pollingOperation(bar) + @useFinalStateVia("original-uri") + @post op foo(): {}; + #suppress "@azure-tools/typespec-azure-core/use-standard-operations" "This is test code." + @route("/polling") + @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"}; + `; + const diagnostics = await runner.diagnose(code); + expectDiagnostics(diagnostics, { + code: "@azure-tools/typespec-azure-core/invalid-final-state", + message: "The final state value 'original-uri' can only be used in http PUT operations", + }); + }); + }); describe("@pollingOperation", () => { it("emit error if response of operation is a scalar", async () => { const code = ` diff --git a/packages/typespec-azure-playground-website/samples/azure-core.tsp b/packages/typespec-azure-playground-website/samples/azure-core.tsp index ed597517a2..c0a19622c6 100644 --- a/packages/typespec-azure-playground-website/samples/azure-core.tsp +++ b/packages/typespec-azure-playground-website/samples/azure-core.tsp @@ -193,7 +193,11 @@ alias Operations = Azure.Core.ResourceOperations; interface Widgets { // Operation Status /** Gets status of a Widget operation. */ + @sharedRoute getWidgetOperationStatus is Operations.GetResourceOperationStatus; + /** Gets status of a Widget delete operation. */ + @sharedRoute + getWidgetDeleteOperationStatus is Operations.GetResourceOperationStatus; // Widget Operations /** Creates or updates a Widget asynchronously */ @@ -204,7 +208,7 @@ interface Widgets { getWidget is Operations.ResourceRead; /** Delete a Widget asynchronously. */ - @pollingOperation(Widgets.getWidgetOperationStatus) + @pollingOperation(Widgets.getWidgetDeleteOperationStatus) deleteWidget is Operations.LongRunningResourceDelete; /** List Widget resources */ diff --git a/packages/typespec-azure-resource-manager/lib/operations.tsp b/packages/typespec-azure-resource-manager/lib/operations.tsp index 546febe1e0..d5211d4358 100644 --- a/packages/typespec-azure-resource-manager/lib/operations.tsp +++ b/packages/typespec-azure-resource-manager/lib/operations.tsp @@ -1,6 +1,5 @@ using TypeSpec.Http; using TypeSpec.Rest; -using TypeSpec.OpenAPI; using Azure.ResourceManager.Foundations; namespace Azure.ResourceManager; @@ -144,20 +143,15 @@ op ArmResourceCheckExistence< */ @autoRoute @doc("Create a {name}", Resource) -@extension("x-ms-long-running-operation", true) -@extension( - "x-ms-long-running-operation-options", - { - `final-state-via`: "azure-async-operation", - } -) @armResourceCreateOrUpdate(Resource) @Private.enforceConstraint(Resource, Foundations.Resource) +@Azure.Core.Foundations.Private.defaultFinalStateVia(#["location", "azure-async-operation"]) @put op ArmResourceCreateOrUpdateAsync< Resource extends Foundations.Resource, BaseParameters = DefaultBaseParameters, - LroHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader, + LroHeaders extends TypeSpec.Reflection.Model = ArmAsyncOperationHeader & + Azure.Core.Foundations.RetryAfterHeader, Parameters extends {} = {}, Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedResponse< Resource, @@ -237,7 +231,8 @@ op ArmResourceCreateOrReplaceSync< op ArmResourceCreateOrReplaceAsync< Resource extends Foundations.Resource, BaseParameters = DefaultBaseParameters, - LroHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader, + LroHeaders extends TypeSpec.Reflection.Model = ArmAsyncOperationHeader & + Azure.Core.Foundations.RetryAfterHeader, Parameters extends {} = {}, Response extends {} = ArmResourceUpdatedResponse | ArmResourceCreatedResponse< Resource, @@ -320,13 +315,6 @@ op ArmResourcePatchAsync< */ @autoRoute @doc("Update a {name}", Resource) -@extension("x-ms-long-running-operation", true) -@extension( - "x-ms-long-running-operation-options", - { - `final-state-via`: "location", - } -) @armResourceUpdate(Resource) @Private.enforceConstraint(Resource, Foundations.Resource) @patch @@ -424,13 +412,6 @@ op ArmCustomPatchSync< */ @autoRoute @doc("Delete a {name}", Resource) -@extension("x-ms-long-running-operation", true) -@extension( - "x-ms-long-running-operation-options", - { - `final-state-via`: "location", - } -) @armResourceDelete(Resource) @Private.enforceConstraint(Resource, Foundations.Resource) @delete @@ -514,13 +495,6 @@ op ArmResourceDeleteSync< * @template Error Optional. The error response, if non-standard. */ @autoRoute -@extension("x-ms-long-running-operation", true) -@extension( - "x-ms-long-running-operation-options", - { - `final-state-via`: "location", - } -) @armResourceAction(Resource) @Private.enforceConstraint(Resource, Foundations.Resource) @post diff --git a/packages/typespec-azure-resource-manager/lib/responses.tsp b/packages/typespec-azure-resource-manager/lib/responses.tsp index 7a3a6306e6..64084e3c17 100644 --- a/packages/typespec-azure-resource-manager/lib/responses.tsp +++ b/packages/typespec-azure-resource-manager/lib/responses.tsp @@ -131,15 +131,18 @@ model ArmOperationStatus< /** * The standard header for asynchronous operation polling * @template StatusMonitor The status monitor type for lro polling - * @template UrlValue The value type of the Azure-AsyncOperation header + * @template UrlValue The value type of the Azure-AsyncOperation header + * @template FinalResult The logical final result of the operation */ model ArmAsyncOperationHeader< StatusMonitor extends {} = ArmOperationStatus, - UrlValue extends string = string + UrlValue extends string = string, + FinalResult extends {} = never > { /** A link to the status monitor */ @header("Azure-AsyncOperation") - @Azure.Core.pollingLocation(Azure.Core.StatusMonitorPollingOptions) + @Azure.Core.pollingLocation(Azure.Core.StatusMonitorPollingOptions) + @Azure.Core.finalLocation(FinalResult) azureAsyncOperation?: UrlValue; } @@ -150,7 +153,7 @@ model ArmAsyncOperationHeader< * @template UrlValue The value type for the location header */ model ArmLroLocationHeader< - LroPollingOptions extends Azure.Core.PollingOptions = Azure.Core.StatusMonitorPollingOptions, + LroPollingOptions extends Azure.Core.PollingOptions = Azure.Core.StatusMonitorPollingOptions, FinalResult extends {} | void = void, UrlValue extends string = string > { diff --git a/packages/typespec-azure-resource-manager/test/lro-metadata.test.ts b/packages/typespec-azure-resource-manager/test/lro-metadata.test.ts index 27780cdda0..67192c79eb 100644 --- a/packages/typespec-azure-resource-manager/test/lro-metadata.test.ts +++ b/packages/typespec-azure-resource-manager/test/lro-metadata.test.ts @@ -77,7 +77,7 @@ describe("typespec-azure-resource-manager: ARM LRO Tests", () => { deepStrictEqual((metadata.finalResult as Model)?.name, "Widget"); deepStrictEqual((metadata.finalEnvelopeResult as Model)?.name, "Widget"); deepStrictEqual(metadata.finalResultPath, undefined); - deepStrictEqual(metadata.finalStateVia, "original-uri"); + deepStrictEqual(metadata.finalStateVia, "azure-async-operation"); }); it("Returns correct metadata for Async CreateOrUpdate with final location", async () => { @@ -362,7 +362,7 @@ describe("typespec-azure-resource-manager: ARM LRO Tests", () => { deepStrictEqual((metadata.finalResult as Model)?.name, "Widget"); deepStrictEqual((metadata.finalEnvelopeResult as Model)?.name, "Widget"); deepStrictEqual(metadata.finalResultPath, undefined); - deepStrictEqual(metadata.finalStateVia, "original-uri"); + deepStrictEqual(metadata.finalStateVia, "azure-async-operation"); }); it("Returns correct metadata for Async CreateOrUpdate with final location, with union type ProvisioningState", async () => { From 78df70b31bbc472f42dae1ac9d7fc9fd09a32852 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:23:12 +0000 Subject: [PATCH 03/10] Bump core from `0a7869f` to `22372f9` (#982) Bumps [core](https://github.com/microsoft/typespec) from `0a7869f` to `22372f9`.
Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 0a7869f84f..22372f907b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 0a7869f84f21af8a7b41ac16474161e03cc27a0b +Subproject commit 22372f907b8a8b3644b2274d14b8d8c50a87f81c From 8580d18e648fb546d5b9494e10ca0de25dd3947e Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 11 Jun 2024 14:38:07 -0700 Subject: [PATCH 04/10] Adding an overload parameter on ResourceNameParameter to allow `name` to be set to string union type (#929) ``` /** Widget resource */ model Widget is ProxyResource { ...ResourceNameParameter; } /** different type of widget used on resource path */ union WidgetNameType { string, /** small widget */ Small: "Small", /** large widget */ Large: "Large", ``` which will produce: ``` { "name": "widgetName", "in": "path", "description": "The name of the Widget", "required": true, "type": "string", "enum": [ "Small", "Large" ], "x-ms-enum": { "name": "WidgetNameType", "modelAsString": true, "values": [ { "name": "Small", "value": "Small", "description": "small widget" }, { "name": "Large", "value": "Large", "description": "large widget" } ] } } ], ``` --- ...eToResourceNameParam-2024-4-28-12-18-25.md | 7 ++ .../reference/data-types.md | 23 ++-- .../test/arm/resources.test.ts | 102 ++++++++++++++++++ .../lib/models.tsp | 9 +- .../test/resource.test.ts | 64 +++++++++++ 5 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 .chronus/changes/azhang_addNameTypeToResourceNameParam-2024-4-28-12-18-25.md diff --git a/.chronus/changes/azhang_addNameTypeToResourceNameParam-2024-4-28-12-18-25.md b/.chronus/changes/azhang_addNameTypeToResourceNameParam-2024-4-28-12-18-25.md new file mode 100644 index 0000000000..ecca809aaf --- /dev/null +++ b/.chronus/changes/azhang_addNameTypeToResourceNameParam-2024-4-28-12-18-25.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Adding an overload parameter to ResourceNameParameter that allows `name` type to be set to string union type. diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index ab39c24898..2f4b1bfb6d 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -979,24 +979,27 @@ Spread this model into ARM resource models to specify resource name parameter fo is specified, the resource name will be properly camel cased and pluralized for `@key` and `@segment` automatically. You can also apply explicit override with `KeyName` and `SegmentName` template parameters. +For additional decorators such as + ```typespec -model Azure.ResourceManager.ResourceNameParameter +model Azure.ResourceManager.ResourceNameParameter ``` #### Template Parameters -| Name | Description | -| ----------- | ----------------------------------------------------------------- | -| Resource | The ARM resource this name parameter is applying to. | -| KeyName | Override default key name of the resource. | -| SegmentName | Override default segment name of the resource. | -| NamePattern | The RegEx pattern of the name. Default is `^[a-zA-Z0-9-]{3,24}$`. | +| Name | Description | +| ----------- | -------------------------------------------------------------------------------------------------------- | +| Resource | The ARM resource this name parameter is applying to. | +| KeyName | Override default key name of the resource. | +| SegmentName | Override default segment name of the resource. | +| NamePattern | The RegEx pattern of the name. Default is `^[a-zA-Z0-9-]{3,24}$`. | +| Type | The type of the name property. Default type is string. However you can pass an union with string values. | #### Properties -| Name | Type | Description | -| ---- | -------- | ----------- | -| name | `string` | | +| Name | Type | Description | +| ---- | ------ | ----------- | +| name | `Type` | | ### `ResourceParentParameters` {#Azure.ResourceManager.ResourceParentParameters} diff --git a/packages/typespec-autorest/test/arm/resources.test.ts b/packages/typespec-autorest/test/arm/resources.test.ts index 23f762d76d..e71ade9be9 100644 --- a/packages/typespec-autorest/test/arm/resources.test.ts +++ b/packages/typespec-autorest/test/arm/resources.test.ts @@ -205,3 +205,105 @@ it("emits correct paths for ArmResourceHead operation", async () => { }, }); }); + +it("emits correct fixed union name parameter for resource", async () => { + const openApi = await openApiFor(` + @armProviderNamespace + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Contoso; + + @doc("Widget resource") + model Widget is ProxyResource { + ...ResourceNameParameter; + } + + @doc("The properties of a widget") + model WidgetProperties { + size: int32; + } + + /** different type of widget used on resource path */ + union WidgetNameType { + string, + /** small widget */ + Small: "Small", + /** large widget */ + Large: "Large" + } + + interface Widgets extends Operations { + get is ArmResourceRead; + } +`); + const getOperation = + openApi.paths[ + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/widgets/{widgetName}" + ].get; + ok(getOperation); + deepEqual(getOperation.parameters[3], { + description: "The name of the Widget", + enum: ["Small", "Large"], + "x-ms-enum": { + modelAsString: true, + name: "WidgetNameType", + values: [ + { + name: "Small", + value: "Small", + description: "small widget", + }, + { + name: "Large", + value: "Large", + description: "large widget", + }, + ], + }, + in: "path", + name: "widgetName", + required: true, + type: "string", + }); +}); + +it("emits a scalar string with decorator parameter for resource", async () => { + const openApi = await openApiFor(` + @armProviderNamespace + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Contoso; + + @doc("Widget resource") + model Widget is ProxyResource { + ...ResourceNameParameter; + } + + @doc("The properties of a widget") + model WidgetProperties { + size: int32; + } + + @minLength(1) + @maxLength(10) + @pattern("xxxxxx") + scalar WidgetNameType extends string; + + interface Widgets extends Operations { + get is ArmResourceRead; + } +`); + const getOperation = + openApi.paths[ + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Contoso/widgets/{widgetName}" + ].get; + ok(getOperation); + deepEqual(getOperation.parameters[3], { + description: "The name of the Widget", + in: "path", + maxLength: 10, + minLength: 1, + name: "widgetName", + pattern: "^[a-zA-Z0-9-]{3,24}$", + required: true, + type: "string", + }); +}); diff --git a/packages/typespec-azure-resource-manager/lib/models.tsp b/packages/typespec-azure-resource-manager/lib/models.tsp index 5b8e266048..a5bb6d4e5e 100644 --- a/packages/typespec-azure-resource-manager/lib/models.tsp +++ b/packages/typespec-azure-resource-manager/lib/models.tsp @@ -11,22 +11,27 @@ namespace Azure.ResourceManager; * Spread this model into ARM resource models to specify resource name parameter for its operations. If `Resource` parameter * is specified, the resource name will be properly camel cased and pluralized for `@key` and `@segment` * automatically. You can also apply explicit override with `KeyName` and `SegmentName` template parameters. + * + * For additional decorators such as @minLength, you can use either augment decorator on `[Resource].name` or passing in a scalar string type with decorators. + * * @template Resource The ARM resource this name parameter is applying to. * @template KeyName Override default key name of the resource. * @template SegmentName Override default segment name of the resource. * @template NamePattern The RegEx pattern of the name. Default is `^[a-zA-Z0-9-]{3,24}$`. + * @template Type The type of the name property. Default type is string. However you can pass an union with string values. */ model ResourceNameParameter< Resource extends Foundations.Resource, KeyName extends valueof string = "", SegmentName extends valueof string = "", - NamePattern extends valueof string = "^[a-zA-Z0-9-]{3,24}$" + NamePattern extends valueof string = "^[a-zA-Z0-9-]{3,24}$", + Type extends string = string > { @doc("The name of the {name}", Resource) @pattern(NamePattern) @defaultResourceKeySegmentName(Resource, KeyName, SegmentName) @path - name: string; + name: Type; } //#region Standard Resource Operation Interfaces diff --git a/packages/typespec-azure-resource-manager/test/resource.test.ts b/packages/typespec-azure-resource-manager/test/resource.test.ts index b8d672948f..8d634817b5 100644 --- a/packages/typespec-azure-resource-manager/test/resource.test.ts +++ b/packages/typespec-azure-resource-manager/test/resource.test.ts @@ -652,4 +652,68 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { strictEqual(resources.length, 1); ok(resources[0].typespecType.properties.has("extendedLocation")); }); + + it("emits correct fixed union name parameter for resource", async () => { + const { program, diagnostics } = await checkFor(` + @armProviderNamespace + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Contoso; + + @doc("Widget resource") + model Widget is ProxyResource { + ...ResourceNameParameter; + } + + @doc("The properties of a widget") + model WidgetProperties { + size: int32; + } + + /** different type of widget used on resource path */ + union WidgetNameType { + string, + /** small widget */ + Small: "Small", + /** large widget */ + Large: "Large" + } + `); + const resources = getArmResources(program); + expectDiagnosticEmpty(diagnostics); + strictEqual(resources.length, 1); + ok(resources[0].typespecType.properties.has("name")); + const nameProperty = resources[0].typespecType.properties.get("name"); + strictEqual(nameProperty?.type.kind, "Union"); + strictEqual(nameProperty?.type.name, "WidgetNameType"); + }); + + it("emits a scalar string with decorator parameter for resource", async () => { + const { program, diagnostics } = await checkFor(` + @armProviderNamespace + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + namespace Microsoft.Contoso; + + @doc("Widget resource") + model Widget is ProxyResource { + ...ResourceNameParameter; + } + + @doc("The properties of a widget") + model WidgetProperties { + size: int32; + } + + @minLength(1) + @maxLength(10) + @pattern("xxxxxx") + scalar WidgetNameType extends string; + `); + const resources = getArmResources(program); + expectDiagnosticEmpty(diagnostics); + strictEqual(resources.length, 1); + ok(resources[0].typespecType.properties.has("name")); + const nameProperty = resources[0].typespecType.properties.get("name"); + strictEqual(nameProperty?.type.kind, "Scalar"); + strictEqual(nameProperty?.type.name, "WidgetNameType"); + }); }); From 8c982cf9cb59caef7abaa8ef07ccdccd6e851062 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:43:15 +0000 Subject: [PATCH 05/10] Bump core from `22372f9` to `dd61517` (#985) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [core](https://github.com/microsoft/typespec) from `22372f9` to `dd61517`.
Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Timothee Guerin Co-authored-by: Timothee Guerin --- core | 2 +- .../azure-core/reference/data-types.md | 12 +++--- .../azure-core/reference/interfaces.md | 4 +- .../reference/data-types.md | 26 ++++++------ .../schema/autorest-openapi-schema.tsp | 10 ++--- packages/typespec-azure-core/lib/models.tsp | 6 +-- .../lib/common-types/types.tsp | 40 +++++++++---------- pnpm-lock.yaml | 22 +++++----- 8 files changed, 63 insertions(+), 59 deletions(-) diff --git a/core b/core index 22372f907b..ac93dfa318 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 22372f907b8a8b3644b2274d14b8d8c50a87f81c +Subproject commit ac93dfa318bb02217b99d0aa3b0898c725d88c0a diff --git a/docs/libraries/azure-core/reference/data-types.md b/docs/libraries/azure-core/reference/data-types.md index 91cc9c87b1..e01fc47e41 100644 --- a/docs/libraries/azure-core/reference/data-types.md +++ b/docs/libraries/azure-core/reference/data-types.md @@ -348,12 +348,12 @@ model Azure.Core.ResourceOperationStatus #### Properties -| Name | Type | Description | -| ------- | ------------------------------------------------------------------------- | -------------------------------------------------------------- | -| id | `string` | The unique ID of the operation. | -| status | [`OperationState`](./data-types.md#Azure.Core.Foundations.OperationState) | The status of the operation | -| error? | `StatusError` | Error object that describes the error when status is "Failed". | -| result? | `StatusResult` | The result of the operation. | +| Name | Type | Description | +| ------- | ------------------------------------------------------------------------- | ----------- | +| id | `string` | | +| status | [`OperationState`](./data-types.md#Azure.Core.Foundations.OperationState) | | +| error? | `StatusError` | | +| result? | `StatusResult` | | ### `ResponseProperty` {#Azure.Core.ResponseProperty} diff --git a/docs/libraries/azure-core/reference/interfaces.md b/docs/libraries/azure-core/reference/interfaces.md index 7ed271e946..f3a8f10fb0 100644 --- a/docs/libraries/azure-core/reference/interfaces.md +++ b/docs/libraries/azure-core/reference/interfaces.md @@ -263,7 +263,7 @@ op Azure.Core.ResourceOperations.LongRunningResourceCollectionAction(apiVersion: Resource operation status operation template. ```typespec -op Azure.Core.ResourceOperations.GetResourceOperationStatus(apiVersion: string, operationId: string): Azure.Core.ResourceOperationStatus | ErrorResponse +op Azure.Core.ResourceOperations.GetResourceOperationStatus(apiVersion: string): Azure.Core.ResourceOperationStatus | ErrorResponse ``` ##### Template Parameters @@ -280,7 +280,7 @@ op Azure.Core.ResourceOperations.GetResourceOperationStatus(apiVersion: string, Operation signature to retrieve a resource operation status. ```typespec -op Azure.Core.GetResourceOperationStatus(apiVersion: string, operationId: string): Azure.Core.ResourceOperationStatus | Azure.Core.Foundations.ErrorResponse +op Azure.Core.GetResourceOperationStatus(apiVersion: string): Azure.Core.ResourceOperationStatus | Azure.Core.Foundations.ErrorResponse ``` #### Template Parameters diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 2f4b1bfb6d..4b8edd2901 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -352,10 +352,10 @@ model Azure.ResourceManager.ArmResourceUpdatedResponse #### Properties -| Name | Type | Description | -| ---------- | ---------- | --------------------------------------------------- | -| statusCode | `200` | The status code. | -| body | `Resource` | The body type of the operation request or response. | +| Name | Type | Description | +| ---------- | ---------- | ---------------- | +| statusCode | `200` | The status code. | +| body | `Resource` | | ### `ArmResponse` {#Azure.ResourceManager.ArmResponse} @@ -968,10 +968,10 @@ model Azure.ResourceManager.ResourceListResult #### Properties -| Name | Type | Description | -| --------- | -------------------------------- | ---------------------------------- | -| value | `Array` | The {name} items on this page | -| nextLink? | `TypeSpec.Rest.ResourceLocation` | The link to the next page of items | +| Name | Type | Description | +| --------- | -------------------------------- | ----------- | +| value | `Array` | | +| nextLink? | `TypeSpec.Rest.ResourceLocation` | | ### `ResourceNameParameter` {#Azure.ResourceManager.ResourceNameParameter} @@ -1404,7 +1404,7 @@ model Azure.ResourceManager.Foundations.ExtensionScope | ----------- | -------------------------------- | ---------------------------------------------------------------------- | | apiVersion | `string` | The API version to use for this operation. | | resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | -| provider | `"Microsoft.ThisWillBeReplaced"` | The provider namespace for the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | ### `LocationBaseParameters` {#Azure.ResourceManager.Foundations.LocationBaseParameters} @@ -1443,7 +1443,7 @@ model Azure.ResourceManager.Foundations.LocationScope | apiVersion | `string` | The API version to use for this operation. | | subscriptionId | `string` | The ID of the target subscription. | | location | `string` | The location name. | -| provider | `"Microsoft.ThisWillBeReplaced"` | The provider namespace for the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | ### `ManagedServiceIdentity` {#Azure.ResourceManager.Foundations.ManagedServiceIdentity} @@ -1654,7 +1654,7 @@ model Azure.ResourceManager.Foundations.ResourceGroupScope | location | `string` | The location name. | | resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | | resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | -| provider | `"Microsoft.ThisWillBeReplaced"` | The provider namespace for the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | ### `ResourceUpdateModel` {#Azure.ResourceManager.Foundations.ResourceUpdateModel} @@ -1751,7 +1751,7 @@ model Azure.ResourceManager.Foundations.SubscriptionScope | -------------- | -------------------------------- | ------------------------------------------ | | apiVersion | `string` | The API version to use for this operation. | | subscriptionId | `string` | The ID of the target subscription. | -| provider | `"Microsoft.ThisWillBeReplaced"` | The provider namespace for the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | ### `SystemAssignedServiceIdentity` {#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity} @@ -1841,7 +1841,7 @@ model Azure.ResourceManager.Foundations.TenantScope | Name | Type | Description | | ---------- | -------------------------------- | ------------------------------------------ | | apiVersion | `string` | The API version to use for this operation. | -| provider | `"Microsoft.ThisWillBeReplaced"` | The provider namespace for the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | ### `TrackedResource` {#Azure.ResourceManager.Foundations.TrackedResource} diff --git a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp index c0cac240ec..5d90f426bc 100644 --- a/packages/typespec-autorest/schema/autorest-openapi-schema.tsp +++ b/packages/typespec-autorest/schema/autorest-openapi-schema.tsp @@ -145,11 +145,11 @@ model XmsPageable { @doc("Indicates whether the operation is long running (asynchronous). `true` value indicates that it is a long running operation.") model XmsLongRunningOperationOptions { @doc(""" -How to determine the final state of the operation. Possible Values: -- `azure-async-operation` - poll until terminal state, the final response will be available at the uri pointed to by the header `Azure-AsyncOperation` -- `location` - poll until terminal state, the final response will be available at the uri pointed to by the header `Location` -- `operation-location` - poll until terminal state, the final response will be available at the uri pointed to by the header `Operation-Location` -""") + How to determine the final state of the operation. Possible Values: + - `azure-async-operation` - poll until terminal state, the final response will be available at the uri pointed to by the header `Azure-AsyncOperation` + - `location` - poll until terminal state, the final response will be available at the uri pointed to by the header `Location` + - `operation-location` - poll until terminal state, the final response will be available at the uri pointed to by the header `Operation-Location` + """) `final-state-via`: | "azure-async-operation" | "location" diff --git a/packages/typespec-azure-core/lib/models.tsp b/packages/typespec-azure-core/lib/models.tsp index 4dae8dfa1d..7661e3dc07 100644 --- a/packages/typespec-azure-core/lib/models.tsp +++ b/packages/typespec-azure-core/lib/models.tsp @@ -157,9 +157,9 @@ model ConditionalRequestHeaders { } @doc(""" -Provides the 'ETag' field to enable conditional (cached) requests. This model can be spread -into responses and item models to convey the ETag when it cannot simply conveyed in a header. -""") + Provides the 'ETag' field to enable conditional (cached) requests. This model can be spread + into responses and item models to convey the ETag when it cannot simply conveyed in a header. + """) model EtagProperty { @visibility("read") @doc("The entity tag for this resource.") diff --git a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp index fa9ef37b0d..cc1815421c 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp @@ -131,8 +131,8 @@ enum SkuTier { @armCommonDefinition("OperationListResult", Azure.ResourceManager.CommonTypes.Versions.v4) @armCommonDefinition("OperationListResult", Azure.ResourceManager.CommonTypes.Versions.v5) @doc(""" -A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. -""") + A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + """) model OperationListResult is Azure.Core.Page; /** @@ -144,14 +144,14 @@ model OperationListResult is Azure.Core.Page; @doc("Details of a REST API operation, returned from the Resource Provider Operations API") model Operation { @doc(""" - The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" - """) + The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + """) @visibility("read") name?: string; @doc(""" - Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. - """) + Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + """) @visibility("read") isDataAction?: boolean; @@ -159,14 +159,14 @@ model Operation { display?: OperationDisplay; @doc(""" - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" - """) + The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + """) @visibility("read") origin?: Origin; @doc(""" - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """) + Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """) actionType?: ActionType; } @@ -179,18 +179,18 @@ model Operation { @doc("Localized display information for and operation.") model OperationDisplay { @doc(""" - The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". - """) + The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + """) provider?: string; @doc(""" - The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". - """) + The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + """) resource?: string; @doc(""" - The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - """) + The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + """) operation?: string; @doc("The short, localized friendly description of the operation; suitable for tool tips and detailed views.") @@ -250,8 +250,8 @@ model OperationIdParameter { * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ @doc(""" -Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. -""") + Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """) union ActionType { @doc("Actions are for internal-only APIs.") Internal: "Internal", @@ -263,8 +263,8 @@ union ActionType { * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ @doc(""" -The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" -""") + The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + """) union Origin { @doc("Indicates the operation is initiated by a user.") user: "user", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2038c332a8..7860bf3e64 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -199,8 +199,8 @@ importers: core/packages/bundle-uploader: dependencies: '@azure/identity': - specifier: ~4.2.0 - version: 4.2.0 + specifier: ~4.2.1 + version: 4.2.1 '@azure/storage-blob': specifier: ~12.18.0 version: 12.18.0 @@ -2496,8 +2496,8 @@ packages: '@azure/abort-controller': 2.1.2 tslib: 2.6.2 - /@azure/identity@4.2.0: - resolution: {integrity: sha512-ve3aYv79qXOJ8wRxQ5jO0eIz2DZ4o0TyME4m4vlGV5YyePddVZ+pFMzusAMODNAflYAAv1cBIhKnd4xytmXyig==} + /@azure/identity@4.2.1: + resolution: {integrity: sha512-U8hsyC9YPcEIzoaObJlRDvp7KiF0MGS7xcWbyJSVvXRkC/HXo1f0oYeBYmEvVgRfacw7GHf6D6yAoh9JHz6A5Q==} engines: {node: '>=18.0.0'} dependencies: '@azure/abort-controller': 1.1.0 @@ -2508,7 +2508,7 @@ packages: '@azure/core-util': 1.9.0 '@azure/logger': 1.1.2 '@azure/msal-browser': 3.14.0 - '@azure/msal-node': 2.8.1 + '@azure/msal-node': 2.9.2 events: 3.3.0 jws: 4.0.0 open: 8.4.2 @@ -2533,11 +2533,15 @@ packages: resolution: {integrity: sha512-Zk6DPDz7e1wPgLoLgAp0349Yay9RvcjPM5We/ehuenDNsz/t9QEFI7tRoHpp/e47I4p20XE3FiDlhKwAo3utDA==} engines: {node: '>=0.8.0'} - /@azure/msal-node@2.8.1: - resolution: {integrity: sha512-VcZZM+5VvCWRBTOF7SxMKaxrz+EXjntx2u5AQe7QE06e6FuPJElGBrImgNgCh5QmFaNCfVFO+3qNR7UoFD/Gfw==} + /@azure/msal-common@14.12.0: + resolution: {integrity: sha512-IDDXmzfdwmDkv4SSmMEyAniJf6fDu3FJ7ncOjlxkDuT85uSnLEhZi3fGZpoR7T4XZpOMx9teM9GXBgrfJgyeBw==} + engines: {node: '>=0.8.0'} + + /@azure/msal-node@2.9.2: + resolution: {integrity: sha512-8tvi6Cos3m+0KmRbPjgkySXi+UQU/QiuVRFnrxIwt5xZlEEFa69O04RTaNESGgImyBBlYbo2mfE8/U8Bbdk1WQ==} engines: {node: '>=16'} dependencies: - '@azure/msal-common': 14.10.0 + '@azure/msal-common': 14.12.0 jsonwebtoken: 9.0.2 uuid: 8.3.2 @@ -10754,7 +10758,7 @@ packages: engines: {node: '>= 16'} hasBin: true dependencies: - '@azure/identity': 4.2.0 + '@azure/identity': 4.2.1 azure-devops-node-api: 12.5.0 chalk: 2.4.2 cheerio: 1.0.0-rc.12 From fe90e201b7ad8bda7f98e786debfae37c025ee98 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Tue, 11 Jun 2024 19:41:48 -0700 Subject: [PATCH 06/10] ARM Library reorganization (#945) - Created fully versioned Azure.ResourceManager.CommonTypes subnamespace - Moving all common type definitions/parameters into corresponding tsp files for later easy swagger generation - Adding back compat layers so all existing entities moved from Foundations continue to work (via `alias`) - Added default logic to add `@useDependency` to CommonType reference via `@armProviderNamespace` and `@armCommonTypeVersion` decorators to prevent breaking change. --------- Co-authored-by: Timothee Guerin --- .../azhang_ArmReorg-2024-4-31-18-40-39.md | 7 + .../reference/data-types.md | 1460 ++++++++++------- .../reference/decorators.md | 6 +- .../reference/index.mdx | 95 +- .../reference/interfaces.md | 112 +- .../arm-library/ref-library/int-templates.tsp | 1 + .../arm-library/ref-library/op-templates.tsp | 1 + .../operations/operation-status/main.tsp | 2 +- .../common-properties/main.tsp | 68 + .../encryption/main.tsp | 16 +- .../managed-identity/main.tsp | 62 + .../2023-03-01-preview/openapi.json | 554 +++++++ .../{ => 2023-03-01-preview}/openapi.json | 56 +- .../2023-03-01-preview/openapi.json | 483 ++++++ .../typespec-autorest/test/arm/arm.test.ts | 4 + .../test/decorators.test.ts | 2 + .../typespec-azure-resource-manager/README.md | 6 +- .../lib/arm.tsp | 9 +- .../lib/backcompat.tsp | 27 + .../lib/common-types/common-types.tsp | 12 +- .../commontypes.private.decorators.tsp | 43 + .../customer-managed-keys-ref.tsp | 27 + .../common-types/customer-managed-keys.tsp | 83 +- .../common-types/extended-location-ref.tsp | 1 + .../lib/common-types/extended-location.tsp | 31 +- .../lib/common-types/internal.tsp | 24 + .../lib/common-types/managed-identity-ref.tsp | 79 + .../lib/common-types/managed-identity.tsp | 137 +- .../lib/common-types/private-links-ref.tsp | 159 ++ .../lib/common-types/private-links.tsp | 156 +- .../lib/common-types/types-ref.tsp | 414 +++++ .../lib/common-types/types.tsp | 514 +++--- .../lib/decorators.tsp | 2 +- .../lib/{ => foundations}/arm.foundations.tsp | 44 +- .../lib/foundations/backcompat.tsp | 39 + .../deprecation.tsp} | 11 + .../lib/models.tsp | 18 + .../lib/parameters.tsp | 81 +- .../lib/private.decorators.tsp | 38 - .../lib/responses.tsp | 14 +- .../src/common-types.ts | 68 +- .../src/commontypes.private.decorators.ts | 135 ++ .../src/lib.ts | 6 + .../src/namespace.ts | 51 + .../src/private.decorators.ts | 126 -- .../src/rules/arm-common-types-version.ts | 12 +- .../src/rules/core-operations.ts | 2 +- .../arm-common-types-registration.test.ts | 26 +- .../test/enforce-constraint.test.ts | 14 +- .../test/rules/arm-resource-interface.test.ts | 2 + .../test/rules/core-operations.test.ts | 6 + .../test/rules/operation-usage.test.ts | 2 + .../test/rules/patch-operations.test.ts | 4 + .../test/rules/retry-after.test.ts | 27 +- 54 files changed, 3850 insertions(+), 1529 deletions(-) create mode 100644 .chronus/changes/azhang_ArmReorg-2024-4-31-18-40-39.md create mode 100644 packages/samples/specs/resource-manager/resource-common-properties/common-properties/main.tsp create mode 100644 packages/samples/specs/resource-manager/resource-common-properties/managed-identity/main.tsp create mode 100644 packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json rename packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/{ => 2023-03-01-preview}/openapi.json (76%) create mode 100644 packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json create mode 100644 packages/typespec-azure-resource-manager/lib/backcompat.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/commontypes.private.decorators.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys-ref.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/extended-location-ref.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/internal.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/managed-identity-ref.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/private-links-ref.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/common-types/types-ref.tsp rename packages/typespec-azure-resource-manager/lib/{ => foundations}/arm.foundations.tsp (93%) create mode 100644 packages/typespec-azure-resource-manager/lib/foundations/backcompat.tsp rename packages/typespec-azure-resource-manager/lib/{common-types/backcompat.tsp => foundations/deprecation.tsp} (59%) create mode 100644 packages/typespec-azure-resource-manager/src/commontypes.private.decorators.ts diff --git a/.chronus/changes/azhang_ArmReorg-2024-4-31-18-40-39.md b/.chronus/changes/azhang_ArmReorg-2024-4-31-18-40-39.md new file mode 100644 index 0000000000..958652c9f0 --- /dev/null +++ b/.chronus/changes/azhang_ArmReorg-2024-4-31-18-40-39.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Reorganize ARM library internal models into fully version controlled `Azure.ResourceManager.CommontTypes` namespace. \ No newline at end of file diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 4b8edd2901..178430fad5 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -8,20 +8,6 @@ toc_max_heading_level: 3 ## Azure.ResourceManager -### `ApiVersionParameter` {#Azure.ResourceManager.ApiVersionParameter} - -The default api-version parameter type. - -```typespec -model Azure.ResourceManager.ApiVersionParameter -``` - -#### Properties - -| Name | Type | Description | -| ---------- | -------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | - ### `ArmAcceptedLroResponse` {#Azure.ResourceManager.ArmAcceptedLroResponse} ```typespec @@ -201,9 +187,9 @@ model Azure.ResourceManager.ArmLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ------------------ | -| location | `string` | The location name. | +| Name | Type | Description | +| -------- | -------- | ----------------------------- | +| location | `string` | The name of the Azure region. | ### `ArmLroLocationHeader` {#Azure.ResourceManager.ArmLroLocationHeader} @@ -273,7 +259,7 @@ model Azure.ResourceManager.ArmOperationStatus | startTime? | `utcDateTime` | Operation start time | | endTime? | `utcDateTime` | Operation complete time | | percentComplete? | `float64` | The progress made toward completing the operation | -| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.Foundations.ErrorDetail) | Errors that occurred if the operation ended with Canceled or Failed status | +| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorDetail) | Errors that occurred if the operation ended with Canceled or Failed status | ### `ArmResourceCreatedResponse` {#Azure.ResourceManager.ArmResourceCreatedResponse} @@ -378,23 +364,6 @@ model Azure.ResourceManager.ArmResponse | statusCode | `200` | The status code. | | body | `ResponseBody` | | -### `CustomerManagedKeyEncryption` {#Azure.ResourceManager.CustomerManagedKeyEncryption} - -Customer-managed key encryption properties for the resource. - -```typespec -model Azure.ResourceManager.CustomerManagedKeyEncryption -``` - -#### Properties - -| Name | Type | Description | -| ------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| keyEncryptionKeyIdentity? | [`KeyEncryptionKeyIdentity`](./data-types.md#Azure.ResourceManager.KeyEncryptionKeyIdentity) | The type of identity to use. Values can be systemAssignedIdentity, userAssignedIdentity, or delegatedResourceIdentity. | -| userAssignedIdentityResourceId? | `Core.armResourceIdentifier` | User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. | -| federatedClientId? | `Core.uuid` | application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540 | -| delegatedIdentityClientId? | `Core.uuid` | delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only. | - ### `DefaultProvisioningStateProperty` {#Azure.ResourceManager.DefaultProvisioningStateProperty} Standard resource provisioning state model. If you do not have any custom provisioning state, @@ -419,12 +388,13 @@ model FooProperties { | ------------------ | ---------------------------------------------------------------------------------------------- | --------------------------------------- | | provisioningState? | [`ResourceProvisioningState`](./data-types.md#Azure.ResourceManager.ResourceProvisioningState) | The provisioning state of the resource. | -### `Encryption` {#Azure.ResourceManager.Encryption} +### `EncryptionProperty` {#Azure.ResourceManager.EncryptionProperty} Model used only to spread in the `encryption` envelope property for a resource. +All encryption configuration for a resource. ```typespec -model Azure.ResourceManager.Encryption +model Azure.ResourceManager.EncryptionProperty ``` #### Examples @@ -437,25 +407,9 @@ model Foo is TrackedResource { #### Properties -| Name | Type | Description | -| ---------- | ------------------------------------------------------------------------------------------ | -------------------------------------------- | -| encryption | [`EncryptionConfiguration`](./data-types.md#Azure.ResourceManager.EncryptionConfiguration) | All encryption configuration for a resource. | - -### `EncryptionConfiguration` {#Azure.ResourceManager.EncryptionConfiguration} - -All encryption configuration for a resource. - -```typespec -model Azure.ResourceManager.EncryptionConfiguration -``` - -#### Properties - -| Name | Type | Description | -| ----------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| infrastructureEncryption? | [`InfrastructureEncryption`](./data-types.md#Azure.ResourceManager.InfrastructureEncryption) | Indicates if infrastructure encryption is enabled or disabled. | -| customerManagedKeyEncryption? | [`CustomerManagedKeyEncryption`](./data-types.md#Azure.ResourceManager.CustomerManagedKeyEncryption) | All customer-managed key encryption properties for the resource. | -| keyEncryptionKeyUrl? | `string` | key encryption key Url, versioned or unversioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. | +| Name | Type | Description | +| ---------- | ---------------------------------------------------------------------------- | -------------------------------------------- | +| encryption | [`Encryption`](./data-types.md#Azure.ResourceManager.CommonTypes.Encryption) | All encryption configuration for a resource. | ### `EntityTagProperty` {#Azure.ResourceManager.EntityTagProperty} @@ -480,20 +434,6 @@ model Foo is TrackedResource { | ----- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | eTag? | `string` | If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. | -### `ErrorResponse` {#Azure.ResourceManager.ErrorResponse} - -The standard Azure Resource Manager error response - -```typespec -model Azure.ResourceManager.ErrorResponse -``` - -#### Properties - -| Name | Type | Description | -| ------ | ------------------------------------------------------------------------------ | ----------------- | -| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.Foundations.ErrorDetail) | The error object. | - ### `ExtendedLocationProperty` {#Azure.ResourceManager.ExtendedLocationProperty} Model representing the standard `extendedLocation` envelope property for a resource. @@ -516,7 +456,7 @@ model Employee is TrackedResource { | Name | Type | Description | | ----------------- | ---------------------------------------------------------------------------------------- | ----------- | -| extendedLocation? | [`ExtendedLocation`](./data-types.md#Azure.ResourceManager.Foundations.ExtendedLocation) | | +| extendedLocation? | [`ExtendedLocation`](./data-types.md#Azure.ResourceManager.CommonTypes.ExtendedLocation) | | ### `ExtensionResource` {#Azure.ResourceManager.ExtensionResource} @@ -573,20 +513,6 @@ model Azure.ResourceManager.LocationParameter | -------- | -------- | ------------------ | | location | `string` | The location name. | -### `LocationResourceParameter` {#Azure.ResourceManager.LocationResourceParameter} - -The default location parameter type. - -```typespec -model Azure.ResourceManager.LocationResourceParameter -``` - -#### Properties - -| Name | Type | Description | -| -------- | -------- | ------------------ | -| location | `string` | The location name. | - ### `ManagedByProperty` {#Azure.ResourceManager.ManagedByProperty} Model representing the standard `managedBy` envelope property for a resource. @@ -633,7 +559,7 @@ model Foo is TrackedResource { | Name | Type | Description | | --------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | -| identity? | [`ManagedServiceIdentity`](./data-types.md#Azure.ResourceManager.Foundations.ManagedServiceIdentity) | The managed service identities assigned to this resource. | +| identity? | [`ManagedServiceIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.ManagedServiceIdentity) | The managed service identities assigned to this resource. | ### `ManagedSystemAssignedIdentityProperty` {#Azure.ResourceManager.ManagedSystemAssignedIdentityProperty} @@ -658,7 +584,7 @@ model Foo is TrackedResource { | Name | Type | Description | | --------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------- | -| identity? | [`SystemAssignedServiceIdentity`](./data-types.md#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity) | The managed service identities assigned to this resource. | +| identity? | [`SystemAssignedServiceIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentity) | The managed service identities assigned to this resource. | ### `ParentKeysOf` {#Azure.ResourceManager.ParentKeysOf} @@ -678,163 +604,6 @@ model Azure.ResourceManager.ParentKeysOf None -### `PrivateEndpoint` {#Azure.ResourceManager.PrivateEndpoint} - -The private endpoint resource - -```typespec -model Azure.ResourceManager.PrivateEndpoint -``` - -#### Properties - -| Name | Type | Description | -| ---- | ---------------------------- | -------------------------------------------- | -| id? | `Core.armResourceIdentifier` | The resource identifier for private endpoint | - -### `PrivateEndpointConnection` {#Azure.ResourceManager.PrivateEndpointConnection} - -The private endpoint connection resource - -```typespec -model Azure.ResourceManager.PrivateEndpointConnection -``` - -#### Properties - -| Name | Type | Description | -| ----------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | -| properties? | [`PrivateEndpointConnectionProperties`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionProperties) | The private endpoint connection properties | - -### `PrivateEndpointConnectionParameter` {#Azure.ResourceManager.PrivateEndpointConnectionParameter} - -The name of the private endpoint connection associated with the Azure resource. - -```typespec -model Azure.ResourceManager.PrivateEndpointConnectionParameter -``` - -#### Template Parameters - -| Name | Description | -| ------- | ----------------------------------------------------------------------------------------------- | -| Segment | The resource type name for private endpoint connections (default is privateEndpointConnections) | - -#### Properties - -| Name | Type | Description | -| ---- | -------- | ------------------------------------------------------------------------------- | -| name | `string` | The name of the private endpoint connection associated with the Azure resource. | - -### `PrivateEndpointConnectionProperties` {#Azure.ResourceManager.PrivateEndpointConnectionProperties} - -Properties of he private endpoint connection resource - -```typespec -model Azure.ResourceManager.PrivateEndpointConnectionProperties -``` - -#### Properties - -| Name | Type | Description | -| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| groupIds? | `string[]` | The group identifiers for the private endpoint resource | -| privateEndpoint? | [`PrivateEndpoint`](./data-types.md#Azure.ResourceManager.PrivateEndpoint) | The private endpoint resource | -| privateLinkServiceConnectionState | [`PrivateLinkServiceConnectionState`](./data-types.md#Azure.ResourceManager.PrivateLinkServiceConnectionState) | A collection of information about the state of the connection between service consumer and provider. | -| provisioningState? | [`PrivateEndpointConnectionProvisioningState`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionProvisioningState) | The provisioning state of the private endpoint connection resource. | - -### `PrivateEndpointConnectionResourceListResult` {#Azure.ResourceManager.PrivateEndpointConnectionResourceListResult} - -List of private endpoint connections associated with the specified resource. - -```typespec -model Azure.ResourceManager.PrivateEndpointConnectionResourceListResult -``` - -#### Properties - -| Name | Type | Description | -| ------ | --------------------------------------------- | ------------------------------------- | -| value? | `ResourceManager.PrivateEndpointConnection[]` | Array of private endpoint connections | - -### `PrivateLinkResource` {#Azure.ResourceManager.PrivateLinkResource} - -```typespec -model Azure.ResourceManager.PrivateLinkResource -``` - -#### Properties - -| Name | Type | Description | -| ----------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------- | -| properties? | [`PrivateLinkResourceProperties`](./data-types.md#Azure.ResourceManager.PrivateLinkResourceProperties) | Properties of the private link resource. | - -### `PrivateLinkResourceListResult` {#Azure.ResourceManager.PrivateLinkResourceListResult} - -A list of private link resources. - -```typespec -model Azure.ResourceManager.PrivateLinkResourceListResult -``` - -#### Properties - -| Name | Type | Description | -| ------ | --------------------------------------- | ------------------------------- | -| value? | `ResourceManager.PrivateLinkResource[]` | Array of private link resources | - -### `PrivateLinkResourceParameter` {#Azure.ResourceManager.PrivateLinkResourceParameter} - -The name of the private link associated with the Azure resource. - -```typespec -model Azure.ResourceManager.PrivateLinkResourceParameter -``` - -#### Template Parameters - -| Name | Description | -| ------- | -------------------------------------------------------------------------- | -| Segment | The resource type name for private links (default is privateLinkResources) | - -#### Properties - -| Name | Type | Description | -| ---- | -------- | ---------------------------------------------------------------- | -| name | `string` | The name of the private link associated with the Azure resource. | - -### `PrivateLinkResourceProperties` {#Azure.ResourceManager.PrivateLinkResourceProperties} - -Properties of a private link resource. - -```typespec -model Azure.ResourceManager.PrivateLinkResourceProperties -``` - -#### Properties - -| Name | Type | Description | -| ------------------ | ---------- | ----------------------------------------------------- | -| groupId? | `string` | The private link resource group id. | -| requiredMembers? | `string[]` | The private link resource required member names. | -| requiredZoneNames? | `string[]` | The private link resource private link DNS zone name. | - -### `PrivateLinkServiceConnectionState` {#Azure.ResourceManager.PrivateLinkServiceConnectionState} - -A collection of information about the state of the connection between service consumer and provider. - -```typespec -model Azure.ResourceManager.PrivateLinkServiceConnectionState -``` - -#### Properties - -| Name | Type | Description | -| ---------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | -| status? | [`PrivateEndpointServiceConnectionStatus`](./data-types.md#Azure.ResourceManager.PrivateEndpointServiceConnectionStatus) | Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. | -| description? | `string` | The reason for approval/rejection of the connection. | -| actionsRequired? | `string` | A message indicating if changes on the service provider require any updates on the consumer. | - ### `ProviderNamespace` {#Azure.ResourceManager.ProviderNamespace} Model describing the provider namespace. @@ -888,23 +657,9 @@ model Azure.ResourceManager.ResourceGroupLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ------------------ | -| location | `string` | The location name. | - -### `ResourceGroupParameter` {#Azure.ResourceManager.ResourceGroupParameter} - -The default resource group parameter type. - -```typespec -model Azure.ResourceManager.ResourceGroupParameter -``` - -#### Properties - -| Name | Type | Description | -| ----------------- | -------- | ------------------------------------------------------------- | -| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | +| Name | Type | Description | +| -------- | -------- | ----------------------------- | +| location | `string` | The name of the Azure region. | ### `ResourceInstanceParameters` {#Azure.ResourceManager.ResourceInstanceParameters} @@ -1045,7 +800,7 @@ model Foo is TrackedResource { | Name | Type | Description | | ----- | ---------------------------------------------------------------- | ----------------------------- | -| plan? | [`Plan`](./data-types.md#Azure.ResourceManager.Foundations.Plan) | Details of the resource plan. | +| plan? | [`Plan`](./data-types.md#Azure.ResourceManager.CommonTypes.Plan) | Details of the resource plan. | ### `ResourceSkuProperty` {#Azure.ResourceManager.ResourceSkuProperty} @@ -1069,7 +824,7 @@ model Foo is TrackedResource { | Name | Type | Description | | ---- | -------------------------------------------------------------- | ------------------------------------------------------- | -| sku? | [`Sku`](./data-types.md#Azure.ResourceManager.Foundations.Sku) | The SKU (Stock Keeping Unit) assigned to this resource. | +| sku? | [`Sku`](./data-types.md#Azure.ResourceManager.CommonTypes.Sku) | The SKU (Stock Keeping Unit) assigned to this resource. | ### `ResourceUriParameter` {#Azure.ResourceManager.ResourceUriParameter} @@ -1085,20 +840,6 @@ model Azure.ResourceManager.ResourceUriParameter | ----------- | -------- | ---------------------------------------------------------------------- | | resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | -### `SubscriptionIdParameter` {#Azure.ResourceManager.SubscriptionIdParameter} - -The default subscriptionId parameter type. - -```typespec -model Azure.ResourceManager.SubscriptionIdParameter -``` - -#### Properties - -| Name | Type | Description | -| -------------- | -------- | ---------------------------------- | -| subscriptionId | `string` | The ID of the target subscription. | - ### `SubscriptionLocationResource` {#Azure.ResourceManager.SubscriptionLocationResource} The location resource for subscription-based locations. This can be used as a parent @@ -1110,9 +851,9 @@ model Azure.ResourceManager.SubscriptionLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ------------------ | -| location | `string` | The location name. | +| Name | Type | Description | +| -------- | -------- | ----------------------------- | +| location | `string` | The name of the Azure region. | ### `TenantLocationResource` {#Azure.ResourceManager.TenantLocationResource} @@ -1125,9 +866,9 @@ model Azure.ResourceManager.TenantLocationResource #### Properties -| Name | Type | Description | -| -------- | -------- | ------------------ | -| location | `string` | The location name. | +| Name | Type | Description | +| -------- | -------- | ----------------------------- | +| location | `string` | The name of the Azure region. | ### `TrackedResource` {#Azure.ResourceManager.TrackedResource} @@ -1159,38 +900,6 @@ Supported versions of Azure.ResourceManager building blocks. enum Azure.ResourceManager.Versions ``` -### `InfrastructureEncryption` {#Azure.ResourceManager.InfrastructureEncryption} - -(Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled. - -```typespec -union Azure.ResourceManager.InfrastructureEncryption -``` - -### `KeyEncryptionKeyIdentity` {#Azure.ResourceManager.KeyEncryptionKeyIdentity} - -The type of identity to use. - -```typespec -union Azure.ResourceManager.KeyEncryptionKeyIdentity -``` - -### `PrivateEndpointConnectionProvisioningState` {#Azure.ResourceManager.PrivateEndpointConnectionProvisioningState} - -The provisioning state of the connection - -```typespec -union Azure.ResourceManager.PrivateEndpointConnectionProvisioningState -``` - -### `PrivateEndpointServiceConnectionStatus` {#Azure.ResourceManager.PrivateEndpointServiceConnectionStatus} - -The private endpoint connection status - -```typespec -union Azure.ResourceManager.PrivateEndpointServiceConnectionStatus -``` - ### `ResourceProvisioningState` {#Azure.ResourceManager.ResourceProvisioningState} Standard terminal provisioning state of resource type. You can include in your @@ -1214,52 +923,40 @@ union FooProvisioningState { ## Azure.ResourceManager.CommonTypes -### `Versions` {#Azure.ResourceManager.CommonTypes.Versions} - -The Azure Resource Manager common-types versions. - -```typespec -enum Azure.ResourceManager.CommonTypes.Versions -``` - -## Azure.ResourceManager.Foundations - -### `ArmTagsProperty` {#Azure.ResourceManager.Foundations.ArmTagsProperty} - -Standard type definition for Azure Resource Manager Tags property. +### `ApiVersionParameter` {#Azure.ResourceManager.CommonTypes.ApiVersionParameter} -It is included in the TrackedResource template definition. +The default api-version parameter type. ```typespec -model Azure.ResourceManager.Foundations.ArmTagsProperty +model Azure.ResourceManager.CommonTypes.ApiVersionParameter ``` #### Properties -| Name | Type | Description | -| ----- | ---------------- | -------------- | -| tags? | `Record` | Resource tags. | +| Name | Type | Description | +| ---------- | -------- | ------------------------------------------ | +| apiVersion | `string` | The API version to use for this operation. | -### `AzureEntityResource` {#Azure.ResourceManager.Foundations.AzureEntityResource} +### `AzureEntityResource` {#Azure.ResourceManager.CommonTypes.AzureEntityResource} The resource model definition for an Azure Resource Manager resource with an etag. ```typespec -model Azure.ResourceManager.Foundations.AzureEntityResource +model Azure.ResourceManager.CommonTypes.AzureEntityResource ``` #### Properties -| Name | Type | Description | -| ---- | -------- | -------------- | -| etag | `string` | Resource Etag. | +| Name | Type | Description | +| ----- | -------- | -------------- | +| etag? | `string` | Resource Etag. | -### `CheckNameAvailabilityRequest` {#Azure.ResourceManager.Foundations.CheckNameAvailabilityRequest} +### `CheckNameAvailabilityRequest` {#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest} The check availability request body. ```typespec -model Azure.ResourceManager.Foundations.CheckNameAvailabilityRequest +model Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest ``` #### Properties @@ -1269,12 +966,12 @@ model Azure.ResourceManager.Foundations.CheckNameAvailabilityRequest | name? | `string` | The name of the resource for which availability needs to be checked. | | type? | `string` | The resource type. | -### `CheckNameAvailabilityResponse` {#Azure.ResourceManager.Foundations.CheckNameAvailabilityResponse} +### `CheckNameAvailabilityResponse` {#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse} The check availability result. ```typespec -model Azure.ResourceManager.Foundations.CheckNameAvailabilityResponse +model Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse ``` #### Properties @@ -1282,54 +979,75 @@ model Azure.ResourceManager.Foundations.CheckNameAvailabilityResponse | Name | Type | Description | | -------------- | -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | nameAvailable? | `boolean` | Indicates if the resource name is available. | -| reason? | [`CheckNameAvailabilityReason`](./data-types.md#Azure.ResourceManager.Foundations.CheckNameAvailabilityReason) | The reason why the given name is not available. | +| reason? | [`CheckNameAvailabilityReason`](./data-types.md#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason) | The reason why the given name is not available. | | message? | `string` | Detailed reason why the given name is not available. | -### `DefaultBaseParameters` {#Azure.ResourceManager.Foundations.DefaultBaseParameters} +### `CustomerManagedKeyEncryption` {#Azure.ResourceManager.CommonTypes.CustomerManagedKeyEncryption} -Base parameters for a resource. +Customer-managed key encryption properties for the resource. ```typespec -model Azure.ResourceManager.Foundations.DefaultBaseParameters +model Azure.ResourceManager.CommonTypes.CustomerManagedKeyEncryption ``` -#### Template Parameters - -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | - #### Properties -| Name | Type | Description | -| ----------------- | -------- | ---------------------------------------------------------------------- | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| location | `string` | The location name. | -| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | -| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | +| Name | Type | Description | +| ------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| keyEncryptionKeyIdentity? | [`KeyEncryptionKeyIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentity) | All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. | +| keyEncryptionKeyUrl? | `string` | key encryption key Url, versioned or non-versioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. | -### `ErrorAdditionalInfo` {#Azure.ResourceManager.Foundations.ErrorAdditionalInfo} +### `Encryption` {#Azure.ResourceManager.CommonTypes.Encryption} -The resource management error additional info. +(Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled. ```typespec -model Azure.ResourceManager.Foundations.ErrorAdditionalInfo +model Azure.ResourceManager.CommonTypes.Encryption ``` #### Properties -| Name | Type | Description | -| ----- | -------- | ------------------------- | +| Name | Type | Description | +| ----------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | +| infrastructureEncryption? | [`InfrastructureEncryption`](./data-types.md#Azure.ResourceManager.CommonTypes.InfrastructureEncryption) | Values are enabled and disabled. | +| customerManagedKeyEncryption? | [`CustomerManagedKeyEncryption`](./data-types.md#Azure.ResourceManager.CommonTypes.CustomerManagedKeyEncryption) | All Customer-managed key encryption properties for the resource. | + +### `EncryptionProperties` {#Azure.ResourceManager.CommonTypes.EncryptionProperties} + +Configuration of key for data encryption + +```typespec +model Azure.ResourceManager.CommonTypes.EncryptionProperties +``` + +#### Properties + +| Name | Type | Description | +| ------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| status? | [`EncryptionStatus`](./data-types.md#Azure.ResourceManager.CommonTypes.EncryptionStatus) | Indicates whether or not the encryption is enabled for container registry. | +| keyVaultProperties? | [`KeyVaultProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.KeyVaultProperties) | Key vault properties. | + +### `ErrorAdditionalInfo` {#Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo} + +The resource management error additional info. + +```typespec +model Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo +``` + +#### Properties + +| Name | Type | Description | +| ----- | -------- | ------------------------- | | type? | `string` | The additional info type. | | info? | `{}` | The additional info. | -### `ErrorDetail` {#Azure.ResourceManager.Foundations.ErrorDetail} +### `ErrorDetail` {#Azure.ResourceManager.CommonTypes.ErrorDetail} The error detail. ```typespec -model Azure.ResourceManager.Foundations.ErrorDetail +model Azure.ResourceManager.CommonTypes.ErrorDetail ``` #### Properties @@ -1339,15 +1057,29 @@ model Azure.ResourceManager.Foundations.ErrorDetail | code? | `string` | The error code. | | message? | `string` | The error message. | | target? | `string` | The error target. | -| details? | `ResourceManager.Foundations.ErrorDetail[]` | The error details. | -| additionalInfo? | `ResourceManager.Foundations.ErrorAdditionalInfo[]` | The error additional info. | +| details? | `ResourceManager.CommonTypes.ErrorDetail[]` | The error details. | +| additionalInfo? | `ResourceManager.CommonTypes.ErrorAdditionalInfo[]` | The error additional info. | + +### `ErrorResponse` {#Azure.ResourceManager.CommonTypes.ErrorResponse} + +Common error response for all Azure Resource Manager APIs to return error details for failed operations. + +```typespec +model Azure.ResourceManager.CommonTypes.ErrorResponse +``` -### `ExtendedLocation` {#Azure.ResourceManager.Foundations.ExtendedLocation} +#### Properties + +| Name | Type | Description | +| ------ | ------------------------------------------------------------------------------ | ----------------- | +| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorDetail) | The error object. | + +### `ExtendedLocation` {#Azure.ResourceManager.CommonTypes.ExtendedLocation} The complex type of the extended location. ```typespec -model Azure.ResourceManager.Foundations.ExtendedLocation +model Azure.ResourceManager.CommonTypes.ExtendedLocation ``` #### Properties @@ -1355,119 +1087,176 @@ model Azure.ResourceManager.Foundations.ExtendedLocation | Name | Type | Description | | ---- | ------------------------------------------------------------------------------------------------ | ---------------------------------- | | name | `string` | The name of the extended location. | -| type | [`ExtendedLocationType`](./data-types.md#Azure.ResourceManager.Foundations.ExtendedLocationType) | The type of the extended location. | +| type | [`ExtendedLocationType`](./data-types.md#Azure.ResourceManager.CommonTypes.ExtendedLocationType) | The type of the extended location. | -### `ExtensionBaseParameters` {#Azure.ResourceManager.Foundations.ExtensionBaseParameters} +### `ExtensionResource` {#Azure.ResourceManager.CommonTypes.ExtensionResource} -The static parameters for an extension resource +The base extension resource. ```typespec -model Azure.ResourceManager.Foundations.ExtensionBaseParameters +model Azure.ResourceManager.CommonTypes.ExtensionResource ``` #### Properties -| Name | Type | Description | -| ----------- | -------- | ---------------------------------------------------------------------- | -| apiVersion | `string` | The API version to use for this operation. | -| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | +None -### `ExtensionResource` {#Azure.ResourceManager.Foundations.ExtensionResource} +### `Identity` {#Azure.ResourceManager.CommonTypes.Identity} -The base extension resource. +Identity for the resource. ```typespec -model Azure.ResourceManager.Foundations.ExtensionResource +model Azure.ResourceManager.CommonTypes.Identity ``` #### Properties -None +| Name | Type | Description | +| ------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | +| principalId? | `Core.uuid` | The principal ID of resource identity. The value must be an UUID. | +| tenantId? | `Core.uuid` | The tenant ID of resource. The value must be an UUID. | +| type? | [`ResourceIdentityType`](./data-types.md#Azure.ResourceManager.CommonTypes.ResourceIdentityType) | The identity type. | -### `ExtensionScope` {#Azure.ResourceManager.Foundations.ExtensionScope} +### `IfMatchHeader` {#Azure.ResourceManager.CommonTypes.IfMatchHeader} -Parameter model for listing an extension resource +The default ARM If-Match header type. ```typespec -model Azure.ResourceManager.Foundations.ExtensionScope +model Azure.ResourceManager.CommonTypes.IfMatchHeader ``` -#### Template Parameters +#### Properties -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | +| Name | Type | Description | +| ------- | -------- | ----------------------------------------------------- | +| ifMatch | `string` | The If-Match header that makes a request conditional. | + +### `IfNoneMatchHeader` {#Azure.ResourceManager.CommonTypes.IfNoneMatchHeader} + +The default ARM If-Match header type. + +```typespec +model Azure.ResourceManager.CommonTypes.IfNoneMatchHeader +``` #### Properties -| Name | Type | Description | -| ----------- | -------------------------------- | ---------------------------------------------------------------------- | -| apiVersion | `string` | The API version to use for this operation. | -| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | -| provider | `"Microsoft.ThisWillBeReplaced"` | | +| Name | Type | Description | +| ----------- | -------- | ---------------------------------------------------------- | +| ifNoneMatch | `string` | The If-None-Match header that makes a request conditional. | -### `LocationBaseParameters` {#Azure.ResourceManager.Foundations.LocationBaseParameters} +### `KeyEncryptionKeyIdentity` {#Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentity} -The static parameters for a location-based resource +All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. ```typespec -model Azure.ResourceManager.Foundations.LocationBaseParameters +model Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentity ``` #### Properties -| Name | Type | Description | -| -------------- | -------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| location | `string` | The location name. | +| Name | Type | Description | +| ------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| identityType? | [`KeyEncryptionKeyIdentityType`](./data-types.md#Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentityType) | The type of identity to use. Values can be systemAssignedIdentity, userAssignedIdentity, or delegatedResourceIdentity. | +| userAssignedIdentityResourceId? | `Core.armResourceIdentifier` | User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. | +| federatedClientId? | `Core.uuid` | application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540 | +| delegatedIdentityClientId? | `Core.uuid` | delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only. | -### `LocationScope` {#Azure.ResourceManager.Foundations.LocationScope} +### `KeyVaultProperties` {#Azure.ResourceManager.CommonTypes.KeyVaultProperties} -Parameter model for listing a resource at the location scope +```typespec +model Azure.ResourceManager.CommonTypes.KeyVaultProperties +``` + +#### Properties + +| Name | Type | Description | +| -------------- | -------- | --------------------------------------------------------------------- | +| keyIdentifier? | `string` | Key vault uri to access the encryption key. | +| identity? | `string` | The client ID of the identity which will be used to access key vault. | + +### `LocationData` {#Azure.ResourceManager.CommonTypes.LocationData} + +Metadata pertaining to the geographic location of the resource. ```typespec -model Azure.ResourceManager.Foundations.LocationScope +model Azure.ResourceManager.CommonTypes.LocationData ``` -#### Template Parameters +#### Properties -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | +| Name | Type | Description | +| ---------------- | -------- | --------------------------------------------------------------- | +| name | `string` | A canonical name for the geographic or physical location. | +| city? | `string` | The city or locality where the resource is located. | +| district? | `string` | The district, state, or province where the resource is located. | +| countryOrRegion? | `string` | The country or region where the resource is located | + +### `LocationParameter` {#Azure.ResourceManager.CommonTypes.LocationParameter} + +The default location parameter type. + +```typespec +model Azure.ResourceManager.CommonTypes.LocationParameter +``` + +#### Properties + +| Name | Type | Description | +| -------- | -------- | ------------------------- | +| location | `string` | The name of Azure region. | + +### `LocationResourceParameter` {#Azure.ResourceManager.CommonTypes.LocationResourceParameter} + +The default location parameter type. + +```typespec +model Azure.ResourceManager.CommonTypes.LocationResourceParameter +``` + +#### Properties + +| Name | Type | Description | +| -------- | -------- | ----------------------------- | +| location | `string` | The name of the Azure region. | + +### `ManagedServiceIdentity` {#Azure.ResourceManager.CommonTypes.ManagedServiceIdentity} + +Managed service identity (system assigned and/or user assigned identities) + +```typespec +model Azure.ResourceManager.CommonTypes.ManagedServiceIdentity +``` #### Properties -| Name | Type | Description | -| -------------- | -------------------------------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| location | `string` | The location name. | -| provider | `"Microsoft.ThisWillBeReplaced"` | | +| Name | Type | Description | +| ----------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| principalId? | `Core.uuid` | The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| tenantId? | `Core.uuid` | The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| type | [`ManagedServiceIdentityType`](./data-types.md#Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType) | The type of managed identity assigned to this resource. | +| userAssignedIdentities? | `Record \| null` | The identities assigned to this resource by the user. | -### `ManagedServiceIdentity` {#Azure.ResourceManager.Foundations.ManagedServiceIdentity} +### `ManagementGroupNameParameter` {#Azure.ResourceManager.CommonTypes.ManagementGroupNameParameter} -The properties of the managed service identities assigned to this resource. +The default ManagementGroupName parameter type. ```typespec -model Azure.ResourceManager.Foundations.ManagedServiceIdentity +model Azure.ResourceManager.CommonTypes.ManagementGroupNameParameter ``` #### Properties -| Name | Type | Description | -| ----------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | -| tenantId? | `string` | The Active Directory tenant id of the principal. | -| principalId? | `string` | The active directory identifier of this principal. | -| type | [`ManagedServiceIdentityType`](./data-types.md#Azure.ResourceManager.Foundations.ManagedServiceIdentityType) | The type of managed identity assigned to this resource. | -| userAssignedIdentities? | `Record` | The identities assigned to this resource by the user. | +| Name | Type | Description | +| ------------------- | -------- | --------------------------------------------------------------- | +| managementGroupName | `string` | The name of the management group. The name is case insensitive. | -### `Operation` {#Azure.ResourceManager.Foundations.Operation} +### `Operation` {#Azure.ResourceManager.CommonTypes.Operation} Details of a REST API operation, returned from the Resource Provider Operations API ```typespec -model Azure.ResourceManager.Foundations.Operation +model Azure.ResourceManager.CommonTypes.Operation ``` #### Properties @@ -1476,16 +1265,16 @@ model Azure.ResourceManager.Foundations.Operation | ------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name? | `string` | The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" | | isDataAction? | `boolean` | Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. | -| display? | [`OperationDisplay`](./data-types.md#Azure.ResourceManager.Foundations.OperationDisplay) | Localized display information for this particular operation. | -| origin? | [`Origin`](./data-types.md#Azure.ResourceManager.Foundations.Origin) | The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" | -| actionType? | [`ActionType`](./data-types.md#Azure.ResourceManager.Foundations.ActionType) | Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. | +| display? | [`OperationDisplay`](./data-types.md#Azure.ResourceManager.CommonTypes.OperationDisplay) | Localized display information for this particular operation. | +| origin? | [`Origin`](./data-types.md#Azure.ResourceManager.CommonTypes.Origin) | The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" | +| actionType? | [`ActionType`](./data-types.md#Azure.ResourceManager.CommonTypes.ActionType) | Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. | -### `OperationDisplay` {#Azure.ResourceManager.Foundations.OperationDisplay} +### `OperationDisplay` {#Azure.ResourceManager.CommonTypes.OperationDisplay} Localized display information for and operation. ```typespec -model Azure.ResourceManager.Foundations.OperationDisplay +model Azure.ResourceManager.CommonTypes.OperationDisplay ``` #### Properties @@ -1497,12 +1286,12 @@ model Azure.ResourceManager.Foundations.OperationDisplay | operation? | `string` | The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". | | description? | `string` | The short, localized friendly description of the operation; suitable for tool tips and detailed views. | -### `OperationIdParameter` {#Azure.ResourceManager.Foundations.OperationIdParameter} +### `OperationIdParameter` {#Azure.ResourceManager.CommonTypes.OperationIdParameter} The default operationId parameter type. ```typespec -model Azure.ResourceManager.Foundations.OperationIdParameter +model Azure.ResourceManager.CommonTypes.OperationIdParameter ``` #### Properties @@ -1511,27 +1300,27 @@ model Azure.ResourceManager.Foundations.OperationIdParameter | ----------- | -------- | ------------------------------------- | | operationId | `string` | The ID of an ongoing async operation. | -### `OperationListResult` {#Azure.ResourceManager.Foundations.OperationListResult} +### `OperationListResult` {#Azure.ResourceManager.CommonTypes.OperationListResult} A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. ```typespec -model Azure.ResourceManager.Foundations.OperationListResult +model Azure.ResourceManager.CommonTypes.OperationListResult ``` #### Properties | Name | Type | Description | | --------- | ----------------------------------------- | ---------------------------------- | -| value | `ResourceManager.Foundations.Operation[]` | The Operation items on this page | +| value | `ResourceManager.CommonTypes.Operation[]` | The Operation items on this page | | nextLink? | `TypeSpec.Rest.ResourceLocation` | The link to the next page of items | -### `OperationStatusResult` {#Azure.ResourceManager.Foundations.OperationStatusResult} +### `OperationStatusResult` {#Azure.ResourceManager.CommonTypes.OperationStatusResult} The current status of an async operation. ```typespec -model Azure.ResourceManager.Foundations.OperationStatusResult +model Azure.ResourceManager.CommonTypes.OperationStatusResult ``` #### Properties @@ -1544,15 +1333,15 @@ model Azure.ResourceManager.Foundations.OperationStatusResult | percentComplete? | `float64` | Percent of the operation that is complete. | | startTime? | `utcDateTime` | The start time of the operation. | | endTime? | `utcDateTime` | The end time of the operation. | -| operations | `ResourceManager.Foundations.OperationStatusResult[]` | The operations list. | -| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.Foundations.ErrorDetail) | If present, details of the operation error. | +| operations? | `ResourceManager.CommonTypes.OperationStatusResult[]` | The operations list. | +| error? | [`ErrorDetail`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorDetail) | If present, details of the operation error. | -### `Plan` {#Azure.ResourceManager.Foundations.Plan} +### `Plan` {#Azure.ResourceManager.CommonTypes.Plan} -Details of the resource plan. +Plan for the resource. ```typespec -model Azure.ResourceManager.Foundations.Plan +model Azure.ResourceManager.CommonTypes.Plan ``` #### Properties @@ -1565,396 +1354,803 @@ model Azure.ResourceManager.Foundations.Plan | promotionCode? | `string` | A publisher provided promotion code as provisioned in Data Market for the said product/artifact. | | version? | `string` | The version of the desired product/artifact. | -### `ProxyResource` {#Azure.ResourceManager.Foundations.ProxyResource} +### `PrivateEndpoint` {#Azure.ResourceManager.CommonTypes.PrivateEndpoint} -The base proxy resource. +The Private Endpoint resource. ```typespec -model Azure.ResourceManager.Foundations.ProxyResource +model Azure.ResourceManager.CommonTypes.PrivateEndpoint ``` #### Properties -None +| Name | Type | Description | +| ---- | ---------------------------- | -------------------------------------------- | +| id? | `Core.armResourceIdentifier` | The resource identifier for private endpoint | -### `ProxyResourceUpdateModel` {#Azure.ResourceManager.Foundations.ProxyResourceUpdateModel} +### `PrivateEndpointConnection` {#Azure.ResourceManager.CommonTypes.PrivateEndpointConnection} -The type used for update operations of the resource. +The private endpoint connection resource ```typespec -model Azure.ResourceManager.Foundations.ProxyResourceUpdateModel +model Azure.ResourceManager.CommonTypes.PrivateEndpointConnection ``` -#### Template Parameters - -| Name | Description | -| ---------- | --------------------------- | -| Resource | The type of the resource. | -| Properties | The type of the properties. | - #### Properties -| Name | Type | Description | -| ----------- | --------------------------------------------------------------------------------- | ----------- | -| properties? | `ResourceManager.Foundations.ResourceUpdateModelProperties` | | +| Name | Type | Description | +| ----------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | +| properties? | [`PrivateEndpointConnectionProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties) | The private endpoint connection properties | -### `Resource` {#Azure.ResourceManager.Foundations.Resource} +### `PrivateEndpointConnectionListResult` {#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionListResult} -Base model that defines common properties for all Azure Resource Manager resources. +List of private endpoint connections associated with the specified resource. ```typespec -model Azure.ResourceManager.Foundations.Resource +model Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionListResult ``` #### Properties -| Name | Type | Description | -| ----------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| id? | `string` | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} | -| name? | `string` | The name of the resource | -| type? | `string` | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" | -| systemData? | [`SystemData`](./data-types.md#Azure.ResourceManager.Foundations.SystemData) | Azure Resource Manager metadata containing createdBy and modifiedBy information. | +| Name | Type | Description | +| ------ | --------------------------------------------------------- | -------------------------------------- | +| value? | `ResourceManager.CommonTypes.PrivateEndpointConnection[]` | Array of private endpoint connections. | -### `ResourceGroupBaseParameters` {#Azure.ResourceManager.Foundations.ResourceGroupBaseParameters} +### `PrivateEndpointConnectionParameter` {#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionParameter} -The static parameters for a resource-group based resource +The name of the private endpoint connection associated with the Azure resource. ```typespec -model Azure.ResourceManager.Foundations.ResourceGroupBaseParameters +model Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionParameter ``` +#### Template Parameters + +| Name | Description | +| ------- | ----------------------------------------------------------------------------------------------- | +| Segment | The resource type name for private endpoint connections (default is privateEndpointConnections) | + #### Properties -| Name | Type | Description | -| ----------------- | -------- | ------------------------------------------------------------- | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | +| Name | Type | Description | +| ---- | -------- | ------------------------------------------------------------------------------- | +| name | `string` | The name of the private endpoint connection associated with the Azure resource. | -### `ResourceGroupScope` {#Azure.ResourceManager.Foundations.ResourceGroupScope} +### `PrivateEndpointConnectionProperties` {#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties} -Parameter model for listing a resource at the resource group scope +Properties of the private endpoint connection. ```typespec -model Azure.ResourceManager.Foundations.ResourceGroupScope +model Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties ``` -#### Template Parameters - -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | - #### Properties -| Name | Type | Description | -| ----------------- | -------------------------------- | ---------------------------------------------------------------------- | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| location | `string` | The location name. | -| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | -| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | -| provider | `"Microsoft.ThisWillBeReplaced"` | | +| Name | Type | Description | +| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| groupIds? | `string[]` | The group ids for the private endpoint resource. | +| privateEndpoint? | [`PrivateEndpoint`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpoint) | The private endpoint resource. | +| privateLinkServiceConnectionState | [`PrivateLinkServiceConnectionState`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState) | A collection of information about the state of the connection between service consumer and provider. | +| provisioningState? | [`PrivateEndpointConnectionProvisioningState`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState) | The provisioning state of the private endpoint connection resource. | -### `ResourceUpdateModel` {#Azure.ResourceManager.Foundations.ResourceUpdateModel} +### `PrivateLinkResource` {#Azure.ResourceManager.CommonTypes.PrivateLinkResource} -Defines a model type used to create named resource update models -e.g. `model MyResourceUpdate is ResourceUpdate {}` +A private link resource. ```typespec -model Azure.ResourceManager.Foundations.ResourceUpdateModel +model Azure.ResourceManager.CommonTypes.PrivateLinkResource ``` -#### Template Parameters +#### Properties -| Name | Description | -| ---------- | --------------------------- | -| Resource | The type of the resource. | -| Properties | The type of the properties. | +| Name | Type | Description | +| ----------- | ------------------------------------------------------------------------------------------------------------------ | -------------------- | +| properties? | [`PrivateLinkResourceProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties) | Resource properties. | + +### `PrivateLinkResourceListResult` {#Azure.ResourceManager.CommonTypes.PrivateLinkResourceListResult} + +A list of private link resources. + +```typespec +model Azure.ResourceManager.CommonTypes.PrivateLinkResourceListResult +``` #### Properties -| Name | Type | Description | -| ----------- | --------------------------------------------------------------------------------- | ----------- | -| properties? | `ResourceManager.Foundations.ResourceUpdateModelProperties` | | +| Name | Type | Description | +| ------ | --------------------------------------------------- | ------------------------------- | +| value? | `ResourceManager.CommonTypes.PrivateLinkResource[]` | Array of private link resources | -### `ResourceUpdateModelProperties` {#Azure.ResourceManager.Foundations.ResourceUpdateModelProperties} +### `PrivateLinkResourceParameter` {#Azure.ResourceManager.CommonTypes.PrivateLinkResourceParameter} -Defines a properties type used to create named resource update models. -This type is not used directly, it is referenced by ResourceUpdateModel. +The name of the private link associated with the Azure resource. ```typespec -model Azure.ResourceManager.Foundations.ResourceUpdateModelProperties +model Azure.ResourceManager.CommonTypes.PrivateLinkResourceParameter ``` #### Template Parameters -| Name | Description | -| ---------- | --------------------------- | -| Resource | The type of the resource. | -| Properties | The type of the properties. | +| Name | Description | +| ------- | -------------------------------------------------------------------------- | +| Segment | The resource type name for private links (default is privateLinkResources) | #### Properties -None +| Name | Type | Description | +| ---- | -------- | ---------------------------------------------------------------- | +| name | `string` | The name of the private link associated with the Azure resource. | -### `Sku` {#Azure.ResourceManager.Foundations.Sku} +### `PrivateLinkResourceProperties` {#Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties} -The SKU (Stock Keeping Unit) assigned to this resource. +Properties of a private link resource. ```typespec -model Azure.ResourceManager.Foundations.Sku +model Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties ``` #### Properties -| Name | Type | Description | -| --------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | `string` | The name of the SKU, usually a combination of letters and numbers, for example, 'P3' | -| tier? | [`SkuTier`](./data-types.md#Azure.ResourceManager.Foundations.SkuTier) | This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. | -| size? | `string` | The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. | -| family? | `string` | If the service has different generations of hardware, for the same SKU, then that can be captured here. | -| capacity? | `int32` | If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. | +| Name | Type | Description | +| ------------------ | ---------- | ----------------------------------------------------- | +| groupId? | `string` | The private link resource group id. | +| requiredMembers? | `string[]` | The private link resource required member names. | +| requiredZoneNames? | `string[]` | The private link resource private link DNS zone name. | -### `SubscriptionBaseParameters` {#Azure.ResourceManager.Foundations.SubscriptionBaseParameters} +### `PrivateLinkServiceConnectionState` {#Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState} -The static parameters for a subscription based resource +A collection of information about the state of the connection between service consumer and provider. ```typespec -model Azure.ResourceManager.Foundations.SubscriptionBaseParameters +model Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState ``` #### Properties -| Name | Type | Description | -| -------------- | -------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | +| Name | Type | Description | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | +| status? | [`PrivateEndpointServiceConnectionStatus`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus) | Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. | +| description? | `string` | The reason for approval/rejection of the connection. | +| actionsRequired? | `string` | A message indicating if changes on the service provider require any updates on the consumer. | -### `SubscriptionScope` {#Azure.ResourceManager.Foundations.SubscriptionScope} +### `ProxyResource` {#Azure.ResourceManager.CommonTypes.ProxyResource} -Parameter model for listing a resource at the subscription scope +The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location ```typespec -model Azure.ResourceManager.Foundations.SubscriptionScope +model Azure.ResourceManager.CommonTypes.ProxyResource ``` -#### Template Parameters - -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | - #### Properties -| Name | Type | Description | -| -------------- | -------------------------------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | -| subscriptionId | `string` | The ID of the target subscription. | -| provider | `"Microsoft.ThisWillBeReplaced"` | | +None -### `SystemAssignedServiceIdentity` {#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity} +### `Resource` {#Azure.ResourceManager.CommonTypes.Resource} -The properties of the service-assigned identity associated with this resource. +Common fields that are returned in the response for all Azure Resource Manager resources ```typespec -model Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity +model Azure.ResourceManager.CommonTypes.Resource ``` #### Properties -| Name | Type | Description | -| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | -| tenantId? | `string` | The Active Directory tenant id of the principal. | -| principalId? | `string` | The active directory identifier of this principal. | -| type | [`SystemAssignedServiceIdentityType`](./data-types.md#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentityType) | The type of managed identity assigned to this resource. | +| Name | Type | Description | +| ----------- | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| id? | `Core.armResourceIdentifier` | Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} | +| name? | `string` | The name of the resource | +| type? | `string` | The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" | +| systemData? | [`SystemData`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemData) | Azure Resource Manager metadata containing createdBy and modifiedBy information. | -### `SystemData` {#Azure.ResourceManager.Foundations.SystemData} +### `ResourceGroupNameParameter` {#Azure.ResourceManager.CommonTypes.ResourceGroupNameParameter} -Metadata pertaining to creation and last modification of the resource. +The default resource group parameter type. ```typespec -model Azure.ResourceManager.Foundations.SystemData +model Azure.ResourceManager.CommonTypes.ResourceGroupNameParameter ``` #### Properties -| Name | Type | Description | -| ------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------- | -| createdBy? | `string` | The identity that created the resource. | -| createdByType? | [`createdByType`](./data-types.md#Azure.ResourceManager.Foundations.createdByType) | The type of identity that created the resource. | -| createdAt? | `plainDate` | The type of identity that created the resource. | -| lastModifiedBy? | `string` | The identity that last modified the resource. | -| lastModifiedByType? | [`createdByType`](./data-types.md#Azure.ResourceManager.Foundations.createdByType) | The type of identity that last modified the resource. | -| lastModifiedAt? | `plainDate` | The timestamp of resource last modification (UTC) | +| Name | Type | Description | +| ----------------- | -------- | ------------------------------------------------------------- | +| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | -### `TagsUpdateModel` {#Azure.ResourceManager.Foundations.TagsUpdateModel} +### `ResourceModelWithAllowedPropertySet` {#Azure.ResourceManager.CommonTypes.ResourceModelWithAllowedPropertySet} -The type used for updating tags in resources. +The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. ```typespec -model Azure.ResourceManager.Foundations.TagsUpdateModel +model Azure.ResourceManager.CommonTypes.ResourceModelWithAllowedPropertySet ``` -#### Template Parameters - -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | - #### Properties -| Name | Type | Description | -| ----- | ---------------- | -------------- | -| tags? | `Record` | Resource tags. | +| Name | Type | Description | +| ---------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| managedBy? | `string` | The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource.
If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. | +| kind? | `string` | Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type.
If supported, the resource provider must validate and persist this value. | +| eTag? | `string` | The etag field is _not_ required. If it is provided in the response body, it must also be provided as a header per the normal etag convention.
Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19),
If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. | +| identity? | [`Identity`](./data-types.md#Azure.ResourceManager.CommonTypes.Identity) | | +| sku? | [`Sku`](./data-types.md#Azure.ResourceManager.CommonTypes.Sku) | | +| plan? | [`Plan`](./data-types.md#Azure.ResourceManager.CommonTypes.Plan) | | -### `TenantBaseParameters` {#Azure.ResourceManager.Foundations.TenantBaseParameters} +### `ScopeParameter` {#Azure.ResourceManager.CommonTypes.ScopeParameter} -The static parameters for a tenant-based resource +The default Scope parameter type. ```typespec -model Azure.ResourceManager.Foundations.TenantBaseParameters +model Azure.ResourceManager.CommonTypes.ScopeParameter ``` #### Properties -| Name | Type | Description | -| ---------- | -------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | +| Name | Type | Description | +| ----- | -------- | ---------------------------------------------- | +| scope | `string` | The scope at which the operation is performed. | -### `TenantScope` {#Azure.ResourceManager.Foundations.TenantScope} +### `Sku` {#Azure.ResourceManager.CommonTypes.Sku} -Parameter model for listing a resource at the tenant scope +The resource model definition representing SKU ```typespec -model Azure.ResourceManager.Foundations.TenantScope +model Azure.ResourceManager.CommonTypes.Sku ``` -#### Template Parameters - -| Name | Description | -| -------- | ------------------------- | -| Resource | The type of the resource. | - #### Properties -| Name | Type | Description | -| ---------- | -------------------------------- | ------------------------------------------ | -| apiVersion | `string` | The API version to use for this operation. | -| provider | `"Microsoft.ThisWillBeReplaced"` | | +| Name | Type | Description | +| --------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | +| name | `string` | The name of the SKU. Ex - P3. It is typically a letter+number code | +| tier? | [`SkuTier`](./data-types.md#Azure.ResourceManager.CommonTypes.SkuTier) | This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. | +| size? | `string` | The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. | +| family? | `string` | If the service has different generations of hardware, for the same SKU, then that can be captured here. | +| capacity? | `int32` | If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. | + +### `SubscriptionIdParameter` {#Azure.ResourceManager.CommonTypes.SubscriptionIdParameter} + +The default subscriptionId parameter type. + +```typespec +model Azure.ResourceManager.CommonTypes.SubscriptionIdParameter +``` + +#### Properties + +| Name | Type | Description | +| -------------- | ----------- | ------------------------------------------------------------- | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | + +### `SystemAssignedServiceIdentity` {#Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentity} + +Managed service identity (either system assigned, or none) + +```typespec +model Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentity +``` + +#### Properties -### `TrackedResource` {#Azure.ResourceManager.Foundations.TrackedResource} +| Name | Type | Description | +| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| principalId? | `Core.uuid` | The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| tenantId? | `Core.uuid` | The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| type | [`SystemAssignedServiceIdentityType`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentityType) | The type of managed identity assigned to this resource. | -The base tracked resource. +### `SystemData` {#Azure.ResourceManager.CommonTypes.SystemData} + +Metadata pertaining to creation and last modification of the resource. ```typespec -model Azure.ResourceManager.Foundations.TrackedResource +model Azure.ResourceManager.CommonTypes.SystemData +``` + +#### Properties + +| Name | Type | Description | +| ------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------- | +| createdBy? | `string` | The identity that created the resource. | +| createdByType? | [`createdByType`](./data-types.md#Azure.ResourceManager.CommonTypes.createdByType) | The type of identity that created the resource. | +| createdAt? | `utcDateTime` | The timestamp of resource creation (UTC). | +| lastModifiedBy? | `string` | The identity that last modified the resource. | +| lastModifiedByType? | [`createdByType`](./data-types.md#Azure.ResourceManager.CommonTypes.createdByType) | The type of identity that last modified the resource. | +| lastModifiedAt? | `utcDateTime` | The timestamp of resource last modification (UTC) | + +### `TenantIdParameter` {#Azure.ResourceManager.CommonTypes.TenantIdParameter} + +The default ManagementGroupName parameter type. + +```typespec +model Azure.ResourceManager.CommonTypes.TenantIdParameter +``` + +#### Properties + +| Name | Type | Description | +| -------- | ----------- | ------------------------------------------------------------------------------------------------ | +| tenantId | `Core.uuid` | The Azure tenant ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) | + +### `TrackedResource` {#Azure.ResourceManager.CommonTypes.TrackedResource} + +The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' + +```typespec +model Azure.ResourceManager.CommonTypes.TrackedResource ``` #### Properties | Name | Type | Description | | -------- | ---------------- | ----------------------------------------- | -| location | `string` | The geo-location where the resource lives | | tags? | `Record` | Resource tags. | +| location | `string` | The geo-location where the resource lives | -### `UserAssignedIdentities` {#Azure.ResourceManager.Foundations.UserAssignedIdentities} +### `UserAssignedIdentities` {#Azure.ResourceManager.CommonTypes.UserAssignedIdentities} -The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", +The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. ```typespec -model Azure.ResourceManager.Foundations.UserAssignedIdentities +model Azure.ResourceManager.CommonTypes.UserAssignedIdentities ``` #### Properties | Name | Type | Description | | ---- | ------------------------------------------------------------------------------------------------ | --------------------- | -| | [`UserAssignedIdentity`](./data-types.md#Azure.ResourceManager.Foundations.UserAssignedIdentity) | Additional properties | +| | [`UserAssignedIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.UserAssignedIdentity) | Additional properties | -### `UserAssignedIdentity` {#Azure.ResourceManager.Foundations.UserAssignedIdentity} +### `UserAssignedIdentity` {#Azure.ResourceManager.CommonTypes.UserAssignedIdentity} -A managed identity assigned by the user. +User assigned identity properties ```typespec -model Azure.ResourceManager.Foundations.UserAssignedIdentity +model Azure.ResourceManager.CommonTypes.UserAssignedIdentity ``` #### Properties -| Name | Type | Description | -| ------------ | -------- | ---------------------------------------------------------- | -| clientId? | `string` | The active directory client identifier for this principal. | -| principalId? | `string` | The active directory identifier for this principal. | +| Name | Type | Description | +| ------------ | ----------- | ------------------------------------------ | +| principalId? | `Core.uuid` | The principal ID of the assigned identity. | +| clientId? | `Core.uuid` | The client ID of the assigned identity. | -### `ResourceHome` {#Azure.ResourceManager.Foundations.ResourceHome} +### `ResourceHome` {#Azure.ResourceManager.CommonTypes.ResourceHome} An internal enum to indicate the resource support for various path types ```typespec -enum Azure.ResourceManager.Foundations.ResourceHome +enum Azure.ResourceManager.CommonTypes.ResourceHome ``` -### `SkuTier` {#Azure.ResourceManager.Foundations.SkuTier} +### `Versions` {#Azure.ResourceManager.CommonTypes.Versions} -Available service tiers for the SKU. +The Azure Resource Manager common-types versions. ```typespec -enum Azure.ResourceManager.Foundations.SkuTier +enum Azure.ResourceManager.CommonTypes.Versions ``` -### `ActionType` {#Azure.ResourceManager.Foundations.ActionType} +### `ActionType` {#Azure.ResourceManager.CommonTypes.ActionType} Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. ```typespec -union Azure.ResourceManager.Foundations.ActionType +union Azure.ResourceManager.CommonTypes.ActionType ``` -### `CheckNameAvailabilityReason` {#Azure.ResourceManager.Foundations.CheckNameAvailabilityReason} +### `CheckNameAvailabilityReason` {#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason} Possible reasons for a name not being available. ```typespec -union Azure.ResourceManager.Foundations.CheckNameAvailabilityReason +union Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason ``` -### `createdByType` {#Azure.ResourceManager.Foundations.createdByType} +### `createdByType` {#Azure.ResourceManager.CommonTypes.createdByType} The kind of entity that created the resource. ```typespec -union Azure.ResourceManager.Foundations.createdByType +union Azure.ResourceManager.CommonTypes.createdByType +``` + +### `EncryptionStatus` {#Azure.ResourceManager.CommonTypes.EncryptionStatus} + +Indicates whether or not the encryption is enabled for container registry. + +```typespec +union Azure.ResourceManager.CommonTypes.EncryptionStatus ``` -### `ExtendedLocationType` {#Azure.ResourceManager.Foundations.ExtendedLocationType} +### `ExtendedLocationType` {#Azure.ResourceManager.CommonTypes.ExtendedLocationType} The supported ExtendedLocation types. ```typespec -union Azure.ResourceManager.Foundations.ExtendedLocationType +union Azure.ResourceManager.CommonTypes.ExtendedLocationType ``` -### `ManagedServiceIdentityType` {#Azure.ResourceManager.Foundations.ManagedServiceIdentityType} +### `InfrastructureEncryption` {#Azure.ResourceManager.CommonTypes.InfrastructureEncryption} -The kind of managed identity assigned to this resource. +(Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled. ```typespec -union Azure.ResourceManager.Foundations.ManagedServiceIdentityType +union Azure.ResourceManager.CommonTypes.InfrastructureEncryption ``` -### `Origin` {#Azure.ResourceManager.Foundations.Origin} +### `KeyEncryptionKeyIdentityType` {#Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentityType} + +The type of identity to use. + +```typespec +union Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentityType +``` + +### `ManagedServiceIdentityType` {#Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType} + +Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + +```typespec +union Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType +``` + +### `Origin` {#Azure.ResourceManager.CommonTypes.Origin} The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" ```typespec -union Azure.ResourceManager.Foundations.Origin +union Azure.ResourceManager.CommonTypes.Origin +``` + +### `PrivateEndpointConnectionProvisioningState` {#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState} + +The current provisioning state. + +```typespec +union Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState +``` + +### `PrivateEndpointServiceConnectionStatus` {#Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus} + +The private endpoint connection status. + +```typespec +union Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus +``` + +### `ResourceIdentityType` {#Azure.ResourceManager.CommonTypes.ResourceIdentityType} + +```typespec +union Azure.ResourceManager.CommonTypes.ResourceIdentityType +``` + +### `SkuTier` {#Azure.ResourceManager.CommonTypes.SkuTier} + +This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. + +```typespec +union Azure.ResourceManager.CommonTypes.SkuTier +``` + +### `SystemAssignedServiceIdentityType` {#Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentityType} + +Type of managed service identity (either system assigned, or none). + +```typespec +union Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentityType +``` + +## Azure.ResourceManager.Foundations + +### `ArmTagsProperty` {#Azure.ResourceManager.Foundations.ArmTagsProperty} + +Standard type definition for Azure Resource Manager Tags property. + +It is included in the TrackedResource template definition. +The Azure Resource Manager Resource tags. + +```typespec +model Azure.ResourceManager.Foundations.ArmTagsProperty +``` + +#### Properties + +| Name | Type | Description | +| ----- | ---------------- | -------------- | +| tags? | `Record` | Resource tags. | + +### `DefaultBaseParameters` {#Azure.ResourceManager.Foundations.DefaultBaseParameters} + +Base parameters for a resource. + +```typespec +model Azure.ResourceManager.Foundations.DefaultBaseParameters +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| ----------------- | ----------- | ---------------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| location | `string` | The location name. | +| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | +| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | + +### `ExtensionBaseParameters` {#Azure.ResourceManager.Foundations.ExtensionBaseParameters} + +The static parameters for an extension resource + +```typespec +model Azure.ResourceManager.Foundations.ExtensionBaseParameters +``` + +#### Properties + +| Name | Type | Description | +| ----------- | -------- | ---------------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | + +### `ExtensionScope` {#Azure.ResourceManager.Foundations.ExtensionScope} + +Parameter model for listing an extension resource + +```typespec +model Azure.ResourceManager.Foundations.ExtensionScope +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| ----------- | -------------------------------- | ---------------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | + +### `LocationBaseParameters` {#Azure.ResourceManager.Foundations.LocationBaseParameters} + +The static parameters for a location-based resource + +```typespec +model Azure.ResourceManager.Foundations.LocationBaseParameters ``` -### `SystemAssignedServiceIdentityType` {#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentityType} +#### Properties -The kind of managemed identity assigned to this resource. +| Name | Type | Description | +| -------------- | ----------- | ------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| location | `string` | The location name. | + +### `LocationScope` {#Azure.ResourceManager.Foundations.LocationScope} + +Parameter model for listing a resource at the location scope ```typespec -union Azure.ResourceManager.Foundations.SystemAssignedServiceIdentityType +model Azure.ResourceManager.Foundations.LocationScope ``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| -------------- | -------------------------------- | ------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| location | `string` | The location name. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | + +### `ProxyResourceUpdateModel` {#Azure.ResourceManager.Foundations.ProxyResourceUpdateModel} + +The type used for update operations of the resource. + +```typespec +model Azure.ResourceManager.Foundations.ProxyResourceUpdateModel +``` + +#### Template Parameters + +| Name | Description | +| ---------- | --------------------------- | +| Resource | The type of the resource. | +| Properties | The type of the properties. | + +#### Properties + +| Name | Type | Description | +| ----------- | --------------------------------------------------------------------------------- | ----------- | +| properties? | `ResourceManager.Foundations.ResourceUpdateModelProperties` | | + +### `ResourceGroupBaseParameters` {#Azure.ResourceManager.Foundations.ResourceGroupBaseParameters} + +The static parameters for a resource-group based resource + +```typespec +model Azure.ResourceManager.Foundations.ResourceGroupBaseParameters +``` + +#### Properties + +| Name | Type | Description | +| ----------------- | ----------- | ------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | + +### `ResourceGroupScope` {#Azure.ResourceManager.Foundations.ResourceGroupScope} + +Parameter model for listing a resource at the resource group scope + +```typespec +model Azure.ResourceManager.Foundations.ResourceGroupScope +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| ----------------- | -------------------------------- | ---------------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| location | `string` | The location name. | +| resourceGroupName | `string` | The name of the resource group. The name is case insensitive. | +| resourceUri | `string` | The fully qualified Azure Resource manager identifier of the resource. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | + +### `ResourceUpdateModel` {#Azure.ResourceManager.Foundations.ResourceUpdateModel} + +Defines a model type used to create named resource update models +e.g. `model MyResourceUpdate is ResourceUpdate {}` + +```typespec +model Azure.ResourceManager.Foundations.ResourceUpdateModel +``` + +#### Template Parameters + +| Name | Description | +| ---------- | --------------------------- | +| Resource | The type of the resource. | +| Properties | The type of the properties. | + +#### Properties + +| Name | Type | Description | +| ----------- | --------------------------------------------------------------------------------- | ----------- | +| properties? | `ResourceManager.Foundations.ResourceUpdateModelProperties` | | + +### `ResourceUpdateModelProperties` {#Azure.ResourceManager.Foundations.ResourceUpdateModelProperties} + +Defines a properties type used to create named resource update models. +This type is not used directly, it is referenced by ResourceUpdateModel. + +```typespec +model Azure.ResourceManager.Foundations.ResourceUpdateModelProperties +``` + +#### Template Parameters + +| Name | Description | +| ---------- | --------------------------- | +| Resource | The type of the resource. | +| Properties | The type of the properties. | + +#### Properties + +None + +### `SubscriptionBaseParameters` {#Azure.ResourceManager.Foundations.SubscriptionBaseParameters} + +The static parameters for a subscription based resource + +```typespec +model Azure.ResourceManager.Foundations.SubscriptionBaseParameters +``` + +#### Properties + +| Name | Type | Description | +| -------------- | ----------- | ------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | + +### `SubscriptionScope` {#Azure.ResourceManager.Foundations.SubscriptionScope} + +Parameter model for listing a resource at the subscription scope + +```typespec +model Azure.ResourceManager.Foundations.SubscriptionScope +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| -------------- | -------------------------------- | ------------------------------------------------------------- | +| apiVersion | `string` | The API version to use for this operation. | +| subscriptionId | `Core.uuid` | The ID of the target subscription. The value must be an UUID. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | + +### `TagsUpdateModel` {#Azure.ResourceManager.Foundations.TagsUpdateModel} + +The type used for updating tags in resources. + +```typespec +model Azure.ResourceManager.Foundations.TagsUpdateModel +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| ----- | ---------------- | -------------- | +| tags? | `Record` | Resource tags. | + +### `TenantBaseParameters` {#Azure.ResourceManager.Foundations.TenantBaseParameters} + +The static parameters for a tenant-based resource + +```typespec +model Azure.ResourceManager.Foundations.TenantBaseParameters +``` + +#### Properties + +| Name | Type | Description | +| ---------- | -------- | ------------------------------------------ | +| apiVersion | `string` | The API version to use for this operation. | + +### `TenantScope` {#Azure.ResourceManager.Foundations.TenantScope} + +Parameter model for listing a resource at the tenant scope + +```typespec +model Azure.ResourceManager.Foundations.TenantScope +``` + +#### Template Parameters + +| Name | Description | +| -------- | ------------------------- | +| Resource | The type of the resource. | + +#### Properties + +| Name | Type | Description | +| ---------- | -------------------------------- | ------------------------------------------ | +| apiVersion | `string` | The API version to use for this operation. | +| provider | `"Microsoft.ThisWillBeReplaced"` | | diff --git a/docs/libraries/azure-resource-manager/reference/decorators.md b/docs/libraries/azure-resource-manager/reference/decorators.md index 7f8fbcdc0b..9983be00ac 100644 --- a/docs/libraries/azure-resource-manager/reference/decorators.md +++ b/docs/libraries/azure-resource-manager/reference/decorators.md @@ -23,9 +23,9 @@ the version of the Azure Resource Manager common-types to use for refs in emitte #### Parameters -| Name | Type | Description | -| ------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| version | `valueof string \| EnumMember` | The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value. | +| Name | Type | Description | +| ------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | +| version | `valueof string \| EnumMember` | The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value like "v5". | ### `@armLibraryNamespace` {#@Azure.ResourceManager.armLibraryNamespace} diff --git a/docs/libraries/azure-resource-manager/reference/index.mdx b/docs/libraries/azure-resource-manager/reference/index.mdx index 51360a7a56..ef473192d6 100644 --- a/docs/libraries/azure-resource-manager/reference/index.mdx +++ b/docs/libraries/azure-resource-manager/reference/index.mdx @@ -115,7 +115,6 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager ### Models -- [`ApiVersionParameter`](./data-types.md#Azure.ResourceManager.ApiVersionParameter) - [`ArmAcceptedLroResponse`](./data-types.md#Azure.ResourceManager.ArmAcceptedLroResponse) - [`ArmAcceptedResponse`](./data-types.md#Azure.ResourceManager.ArmAcceptedResponse) - [`ArmAsyncOperationHeader`](./data-types.md#Azure.ResourceManager.ArmAsyncOperationHeader) @@ -135,35 +134,20 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`ArmResourceNotFoundResponse`](./data-types.md#Azure.ResourceManager.ArmResourceNotFoundResponse) - [`ArmResourceUpdatedResponse`](./data-types.md#Azure.ResourceManager.ArmResourceUpdatedResponse) - [`ArmResponse`](./data-types.md#Azure.ResourceManager.ArmResponse) -- [`CustomerManagedKeyEncryption`](./data-types.md#Azure.ResourceManager.CustomerManagedKeyEncryption) - [`DefaultProvisioningStateProperty`](./data-types.md#Azure.ResourceManager.DefaultProvisioningStateProperty) -- [`Encryption`](./data-types.md#Azure.ResourceManager.Encryption) -- [`EncryptionConfiguration`](./data-types.md#Azure.ResourceManager.EncryptionConfiguration) +- [`EncryptionProperty`](./data-types.md#Azure.ResourceManager.EncryptionProperty) - [`EntityTagProperty`](./data-types.md#Azure.ResourceManager.EntityTagProperty) -- [`ErrorResponse`](./data-types.md#Azure.ResourceManager.ErrorResponse) - [`ExtendedLocationProperty`](./data-types.md#Azure.ResourceManager.ExtendedLocationProperty) - [`ExtensionResource`](./data-types.md#Azure.ResourceManager.ExtensionResource) - [`KeysOf`](./data-types.md#Azure.ResourceManager.KeysOf) - [`LocationParameter`](./data-types.md#Azure.ResourceManager.LocationParameter) -- [`LocationResourceParameter`](./data-types.md#Azure.ResourceManager.LocationResourceParameter) - [`ManagedByProperty`](./data-types.md#Azure.ResourceManager.ManagedByProperty) - [`ManagedServiceIdentityProperty`](./data-types.md#Azure.ResourceManager.ManagedServiceIdentityProperty) - [`ManagedSystemAssignedIdentityProperty`](./data-types.md#Azure.ResourceManager.ManagedSystemAssignedIdentityProperty) - [`ParentKeysOf`](./data-types.md#Azure.ResourceManager.ParentKeysOf) -- [`PrivateEndpoint`](./data-types.md#Azure.ResourceManager.PrivateEndpoint) -- [`PrivateEndpointConnection`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnection) -- [`PrivateEndpointConnectionParameter`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionParameter) -- [`PrivateEndpointConnectionProperties`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionProperties) -- [`PrivateEndpointConnectionResourceListResult`](./data-types.md#Azure.ResourceManager.PrivateEndpointConnectionResourceListResult) -- [`PrivateLinkResource`](./data-types.md#Azure.ResourceManager.PrivateLinkResource) -- [`PrivateLinkResourceListResult`](./data-types.md#Azure.ResourceManager.PrivateLinkResourceListResult) -- [`PrivateLinkResourceParameter`](./data-types.md#Azure.ResourceManager.PrivateLinkResourceParameter) -- [`PrivateLinkResourceProperties`](./data-types.md#Azure.ResourceManager.PrivateLinkResourceProperties) -- [`PrivateLinkServiceConnectionState`](./data-types.md#Azure.ResourceManager.PrivateLinkServiceConnectionState) - [`ProviderNamespace`](./data-types.md#Azure.ResourceManager.ProviderNamespace) - [`ProxyResource`](./data-types.md#Azure.ResourceManager.ProxyResource) - [`ResourceGroupLocationResource`](./data-types.md#Azure.ResourceManager.ResourceGroupLocationResource) -- [`ResourceGroupParameter`](./data-types.md#Azure.ResourceManager.ResourceGroupParameter) - [`ResourceInstanceParameters`](./data-types.md#Azure.ResourceManager.ResourceInstanceParameters) - [`ResourceKindProperty`](./data-types.md#Azure.ResourceManager.ResourceKindProperty) - [`ResourceListResult`](./data-types.md#Azure.ResourceManager.ResourceListResult) @@ -172,13 +156,66 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`ResourcePlanProperty`](./data-types.md#Azure.ResourceManager.ResourcePlanProperty) - [`ResourceSkuProperty`](./data-types.md#Azure.ResourceManager.ResourceSkuProperty) - [`ResourceUriParameter`](./data-types.md#Azure.ResourceManager.ResourceUriParameter) -- [`SubscriptionIdParameter`](./data-types.md#Azure.ResourceManager.SubscriptionIdParameter) - [`SubscriptionLocationResource`](./data-types.md#Azure.ResourceManager.SubscriptionLocationResource) - [`TenantLocationResource`](./data-types.md#Azure.ResourceManager.TenantLocationResource) - [`TrackedResource`](./data-types.md#Azure.ResourceManager.TrackedResource) ## Azure.ResourceManager.CommonTypes +### Models + +- [`ApiVersionParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.ApiVersionParameter) +- [`AzureEntityResource`](./data-types.md#Azure.ResourceManager.CommonTypes.AzureEntityResource) +- [`CheckNameAvailabilityRequest`](./data-types.md#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest) +- [`CheckNameAvailabilityResponse`](./data-types.md#Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse) +- [`CustomerManagedKeyEncryption`](./data-types.md#Azure.ResourceManager.CommonTypes.CustomerManagedKeyEncryption) +- [`Encryption`](./data-types.md#Azure.ResourceManager.CommonTypes.Encryption) +- [`EncryptionProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.EncryptionProperties) +- [`ErrorAdditionalInfo`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo) +- [`ErrorDetail`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorDetail) +- [`ErrorResponse`](./data-types.md#Azure.ResourceManager.CommonTypes.ErrorResponse) +- [`ExtendedLocation`](./data-types.md#Azure.ResourceManager.CommonTypes.ExtendedLocation) +- [`ExtensionResource`](./data-types.md#Azure.ResourceManager.CommonTypes.ExtensionResource) +- [`Identity`](./data-types.md#Azure.ResourceManager.CommonTypes.Identity) +- [`IfMatchHeader`](./data-types.md#Azure.ResourceManager.CommonTypes.IfMatchHeader) +- [`IfNoneMatchHeader`](./data-types.md#Azure.ResourceManager.CommonTypes.IfNoneMatchHeader) +- [`KeyEncryptionKeyIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.KeyEncryptionKeyIdentity) +- [`KeyVaultProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.KeyVaultProperties) +- [`LocationData`](./data-types.md#Azure.ResourceManager.CommonTypes.LocationData) +- [`LocationParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.LocationParameter) +- [`LocationResourceParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.LocationResourceParameter) +- [`ManagedServiceIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.ManagedServiceIdentity) +- [`ManagementGroupNameParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.ManagementGroupNameParameter) +- [`Operation`](./data-types.md#Azure.ResourceManager.CommonTypes.Operation) +- [`OperationDisplay`](./data-types.md#Azure.ResourceManager.CommonTypes.OperationDisplay) +- [`OperationIdParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.OperationIdParameter) +- [`OperationListResult`](./data-types.md#Azure.ResourceManager.CommonTypes.OperationListResult) +- [`OperationStatusResult`](./data-types.md#Azure.ResourceManager.CommonTypes.OperationStatusResult) +- [`Plan`](./data-types.md#Azure.ResourceManager.CommonTypes.Plan) +- [`PrivateEndpoint`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpoint) +- [`PrivateEndpointConnection`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnection) +- [`PrivateEndpointConnectionListResult`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionListResult) +- [`PrivateEndpointConnectionParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionParameter) +- [`PrivateEndpointConnectionProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties) +- [`PrivateLinkResource`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResource) +- [`PrivateLinkResourceListResult`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResourceListResult) +- [`PrivateLinkResourceParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResourceParameter) +- [`PrivateLinkResourceProperties`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties) +- [`PrivateLinkServiceConnectionState`](./data-types.md#Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState) +- [`ProxyResource`](./data-types.md#Azure.ResourceManager.CommonTypes.ProxyResource) +- [`Resource`](./data-types.md#Azure.ResourceManager.CommonTypes.Resource) +- [`ResourceGroupNameParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.ResourceGroupNameParameter) +- [`ResourceModelWithAllowedPropertySet`](./data-types.md#Azure.ResourceManager.CommonTypes.ResourceModelWithAllowedPropertySet) +- [`ScopeParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.ScopeParameter) +- [`Sku`](./data-types.md#Azure.ResourceManager.CommonTypes.Sku) +- [`SubscriptionIdParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.SubscriptionIdParameter) +- [`SystemAssignedServiceIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemAssignedServiceIdentity) +- [`SystemData`](./data-types.md#Azure.ResourceManager.CommonTypes.SystemData) +- [`TenantIdParameter`](./data-types.md#Azure.ResourceManager.CommonTypes.TenantIdParameter) +- [`TrackedResource`](./data-types.md#Azure.ResourceManager.CommonTypes.TrackedResource) +- [`UserAssignedIdentities`](./data-types.md#Azure.ResourceManager.CommonTypes.UserAssignedIdentities) +- [`UserAssignedIdentity`](./data-types.md#Azure.ResourceManager.CommonTypes.UserAssignedIdentity) + ## Azure.ResourceManager.Foundations ### Operations @@ -191,40 +228,18 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager ### Models - [`ArmTagsProperty`](./data-types.md#Azure.ResourceManager.Foundations.ArmTagsProperty) -- [`AzureEntityResource`](./data-types.md#Azure.ResourceManager.Foundations.AzureEntityResource) -- [`CheckNameAvailabilityRequest`](./data-types.md#Azure.ResourceManager.Foundations.CheckNameAvailabilityRequest) -- [`CheckNameAvailabilityResponse`](./data-types.md#Azure.ResourceManager.Foundations.CheckNameAvailabilityResponse) - [`DefaultBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.DefaultBaseParameters) -- [`ErrorAdditionalInfo`](./data-types.md#Azure.ResourceManager.Foundations.ErrorAdditionalInfo) -- [`ErrorDetail`](./data-types.md#Azure.ResourceManager.Foundations.ErrorDetail) -- [`ExtendedLocation`](./data-types.md#Azure.ResourceManager.Foundations.ExtendedLocation) - [`ExtensionBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionBaseParameters) -- [`ExtensionResource`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionResource) - [`ExtensionScope`](./data-types.md#Azure.ResourceManager.Foundations.ExtensionScope) - [`LocationBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.LocationBaseParameters) - [`LocationScope`](./data-types.md#Azure.ResourceManager.Foundations.LocationScope) -- [`ManagedServiceIdentity`](./data-types.md#Azure.ResourceManager.Foundations.ManagedServiceIdentity) -- [`Operation`](./data-types.md#Azure.ResourceManager.Foundations.Operation) -- [`OperationDisplay`](./data-types.md#Azure.ResourceManager.Foundations.OperationDisplay) -- [`OperationIdParameter`](./data-types.md#Azure.ResourceManager.Foundations.OperationIdParameter) -- [`OperationListResult`](./data-types.md#Azure.ResourceManager.Foundations.OperationListResult) -- [`OperationStatusResult`](./data-types.md#Azure.ResourceManager.Foundations.OperationStatusResult) -- [`Plan`](./data-types.md#Azure.ResourceManager.Foundations.Plan) -- [`ProxyResource`](./data-types.md#Azure.ResourceManager.Foundations.ProxyResource) - [`ProxyResourceUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.ProxyResourceUpdateModel) -- [`Resource`](./data-types.md#Azure.ResourceManager.Foundations.Resource) - [`ResourceGroupBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.ResourceGroupBaseParameters) - [`ResourceGroupScope`](./data-types.md#Azure.ResourceManager.Foundations.ResourceGroupScope) - [`ResourceUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.ResourceUpdateModel) - [`ResourceUpdateModelProperties`](./data-types.md#Azure.ResourceManager.Foundations.ResourceUpdateModelProperties) -- [`Sku`](./data-types.md#Azure.ResourceManager.Foundations.Sku) - [`SubscriptionBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.SubscriptionBaseParameters) - [`SubscriptionScope`](./data-types.md#Azure.ResourceManager.Foundations.SubscriptionScope) -- [`SystemAssignedServiceIdentity`](./data-types.md#Azure.ResourceManager.Foundations.SystemAssignedServiceIdentity) -- [`SystemData`](./data-types.md#Azure.ResourceManager.Foundations.SystemData) - [`TagsUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.TagsUpdateModel) - [`TenantBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.TenantBaseParameters) - [`TenantScope`](./data-types.md#Azure.ResourceManager.Foundations.TenantScope) -- [`TrackedResource`](./data-types.md#Azure.ResourceManager.Foundations.TrackedResource) -- [`UserAssignedIdentities`](./data-types.md#Azure.ResourceManager.Foundations.UserAssignedIdentities) -- [`UserAssignedIdentity`](./data-types.md#Azure.ResourceManager.Foundations.UserAssignedIdentity) diff --git a/docs/libraries/azure-resource-manager/reference/interfaces.md b/docs/libraries/azure-resource-manager/reference/interfaces.md index e9faafed8d..bee0fa9964 100644 --- a/docs/libraries/azure-resource-manager/reference/interfaces.md +++ b/docs/libraries/azure-resource-manager/reference/interfaces.md @@ -25,7 +25,7 @@ interface Azure.ResourceManager.ExtensionResourceCollectionOperations #### `ExtensionResourceCollectionOperations.listByParent` {#Azure.ResourceManager.ExtensionResourceCollectionOperations.listByParent} ```typespec -op Azure.ResourceManager.ExtensionResourceCollectionOperations.listByParent(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceCollectionOperations.listByParent(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ExtensionResourceInstanceOperations` {#Azure.ResourceManager.ExtensionResourceInstanceOperations} @@ -46,25 +46,25 @@ interface Azure.ResourceManager.ExtensionResourceInstanceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceInstanceOperations.get(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceInstanceOperations.createOrUpdate` {#Azure.ResourceManager.ExtensionResourceInstanceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.ExtensionResourceInstanceOperations.createOrUpdate(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceInstanceOperations.createOrUpdate(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceInstanceOperations.update` {#Azure.ResourceManager.ExtensionResourceInstanceOperations.update} ```typespec -op Azure.ResourceManager.ExtensionResourceInstanceOperations.update(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceInstanceOperations.update(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceInstanceOperations.delete` {#Azure.ResourceManager.ExtensionResourceInstanceOperations.delete} ```typespec -op Azure.ResourceManager.ExtensionResourceInstanceOperations.delete(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceInstanceOperations.delete(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ExtensionResourceOperations` {#Azure.ResourceManager.ExtensionResourceOperations} @@ -85,31 +85,31 @@ interface Azure.ResourceManager.ExtensionResourceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceOperations.get(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceOperations.createOrUpdate` {#Azure.ResourceManager.ExtensionResourceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.ExtensionResourceOperations.createOrUpdate(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceOperations.createOrUpdate(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceOperations.update` {#Azure.ResourceManager.ExtensionResourceOperations.update} ```typespec -op Azure.ResourceManager.ExtensionResourceOperations.update(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceOperations.update(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceOperations.delete` {#Azure.ResourceManager.ExtensionResourceOperations.delete} ```typespec -op Azure.ResourceManager.ExtensionResourceOperations.delete(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceOperations.delete(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ExtensionResourceOperations.listByParent` {#Azure.ResourceManager.ExtensionResourceOperations.listByParent} ```typespec -op Azure.ResourceManager.ExtensionResourceOperations.listByParent(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ExtensionResourceOperations.listByParent(apiVersion: string, resourceUri: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `Operations` {#Azure.ResourceManager.Operations} @@ -128,7 +128,7 @@ interface Azure.ResourceManager.Operations<> List the operations for the provider ```typespec -op Azure.ResourceManager.Operations.list(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.Operations.list(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ProxyResourceOperations` {#Azure.ResourceManager.ProxyResourceOperations} @@ -155,25 +155,25 @@ interface Azure.ResourceManager.ProxyResourceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ProxyResourceOperations.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ProxyResourceOperations.createOrUpdate` {#Azure.ResourceManager.ProxyResourceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.ProxyResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ProxyResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ProxyResourceOperations.delete` {#Azure.ResourceManager.ProxyResourceOperations.delete} ```typespec -op Azure.ResourceManager.ProxyResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ProxyResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ProxyResourceOperations.listByParent` {#Azure.ResourceManager.ProxyResourceOperations.listByParent} ```typespec -op Azure.ResourceManager.ProxyResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ProxyResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceCollectionOperations` {#Azure.ResourceManager.ResourceCollectionOperations} @@ -194,13 +194,13 @@ interface Azure.ResourceManager.ResourceCollectionOperations> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceCollectionOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceCollectionOperations.listBySubscription` {#Azure.ResourceManager.ResourceCollectionOperations.listBySubscription} ```typespec -op Azure.ResourceManager.ResourceCollectionOperations.listBySubscription(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceCollectionOperations.listBySubscription(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceCreateAsync` {#Azure.ResourceManager.ResourceCreateAsync} @@ -221,7 +221,7 @@ interface Azure.ResourceManager.ResourceCreateAsync #### `ResourceCreateAsync.createOrUpdate` {#Azure.ResourceManager.ResourceCreateAsync.createOrUpdate} ```typespec -op Azure.ResourceManager.ResourceCreateAsync.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceCreateAsync.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceCreateSync` {#Azure.ResourceManager.ResourceCreateSync} @@ -242,7 +242,7 @@ interface Azure.ResourceManager.ResourceCreateSync #### `ResourceCreateSync.createOrUpdate` {#Azure.ResourceManager.ResourceCreateSync.createOrUpdate} ```typespec -op Azure.ResourceManager.ResourceCreateSync.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedSyncResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceCreateSync.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedSyncResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceDeleteAsync` {#Azure.ResourceManager.ResourceDeleteAsync} @@ -261,7 +261,7 @@ interface Azure.ResourceManager.ResourceDeleteAsync #### `ResourceDeleteAsync.delete` {#Azure.ResourceManager.ResourceDeleteAsync.delete} ```typespec -op Azure.ResourceManager.ResourceDeleteAsync.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceDeleteAsync.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceDeleteSync` {#Azure.ResourceManager.ResourceDeleteSync} @@ -282,7 +282,7 @@ interface Azure.ResourceManager.ResourceDeleteSync #### `ResourceDeleteSync.delete` {#Azure.ResourceManager.ResourceDeleteSync.delete} ```typespec -op Azure.ResourceManager.ResourceDeleteSync.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceDeleteSync.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceDeleteWithoutOkAsync` {#Azure.ResourceManager.ResourceDeleteWithoutOkAsync} @@ -301,7 +301,7 @@ interface Azure.ResourceManager.ResourceDeleteWithoutOkAsync | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceDeleteWithoutOkAsync.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceInstanceOperations` {#Azure.ResourceManager.ResourceInstanceOperations} @@ -324,25 +324,25 @@ interface Azure.ResourceManager.ResourceInstanceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceInstanceOperations.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceInstanceOperations.createOrUpdate` {#Azure.ResourceManager.ResourceInstanceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.ResourceInstanceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceInstanceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceInstanceOperations.update` {#Azure.ResourceManager.ResourceInstanceOperations.update} ```typespec -op Azure.ResourceManager.ResourceInstanceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceInstanceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceInstanceOperations.delete` {#Azure.ResourceManager.ResourceInstanceOperations.delete} ```typespec -op Azure.ResourceManager.ResourceInstanceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceInstanceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceListByParent` {#Azure.ResourceManager.ResourceListByParent} @@ -365,7 +365,7 @@ interface Azure.ResourceManager.ResourceListByParent> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceListByParent.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceListBySubscription` {#Azure.ResourceManager.ResourceListBySubscription} @@ -385,7 +385,7 @@ interface Azure.ResourceManager.ResourceListBySubscription #### `ResourceListBySubscription.listBySubscription` {#Azure.ResourceManager.ResourceListBySubscription.listBySubscription} ```typespec -op Azure.ResourceManager.ResourceListBySubscription.listBySubscription(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceListBySubscription.listBySubscription(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceOperations` {#Azure.ResourceManager.ResourceOperations} @@ -405,37 +405,37 @@ interface Azure.ResourceManager.ResourceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceOperations.createOrUpdate` {#Azure.ResourceManager.ResourceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.ResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceOperations.update` {#Azure.ResourceManager.ResourceOperations.update} ```typespec -op Azure.ResourceManager.ResourceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceOperations.delete` {#Azure.ResourceManager.ResourceOperations.delete} ```typespec -op Azure.ResourceManager.ResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceOperations.listByParent` {#Azure.ResourceManager.ResourceOperations.listByParent} ```typespec -op Azure.ResourceManager.ResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `ResourceOperations.listBySubscription` {#Azure.ResourceManager.ResourceOperations.listBySubscription} ```typespec -op Azure.ResourceManager.ResourceOperations.listBySubscription(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceOperations.listBySubscription(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceRead` {#Azure.ResourceManager.ResourceRead} @@ -456,7 +456,7 @@ interface Azure.ResourceManager.ResourceRead #### `ResourceRead.get` {#Azure.ResourceManager.ResourceRead.get} ```typespec -op Azure.ResourceManager.ResourceRead.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceRead.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceUpdateAsync` {#Azure.ResourceManager.ResourceUpdateAsync} @@ -476,7 +476,7 @@ interface Azure.ResourceManager.ResourceUpdateAsync): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse<"Resource update request accepted.", Azure.ResourceManager.{ location: string, retryAfter: int32 }> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceUpdateAsync.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse<"Resource update request accepted.", Azure.ResourceManager.{ location: string, retryAfter: int32 }> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ResourceUpdateSync` {#Azure.ResourceManager.ResourceUpdateSync} @@ -498,7 +498,7 @@ interface Azure.ResourceManager.ResourceUpdateSync): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ResourceUpdateSync.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `TenantResourceOperations` {#Azure.ResourceManager.TenantResourceOperations} @@ -525,31 +525,31 @@ interface Azure.ResourceManager.TenantResourceOperations #### `TenantResourceOperations.get` {#Azure.ResourceManager.TenantResourceOperations.get} ```typespec -op Azure.ResourceManager.TenantResourceOperations.get(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TenantResourceOperations.get(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TenantResourceOperations.createOrUpdate` {#Azure.ResourceManager.TenantResourceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.TenantResourceOperations.createOrUpdate(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TenantResourceOperations.createOrUpdate(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TenantResourceOperations.update` {#Azure.ResourceManager.TenantResourceOperations.update} ```typespec -op Azure.ResourceManager.TenantResourceOperations.update(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TenantResourceOperations.update(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TenantResourceOperations.delete` {#Azure.ResourceManager.TenantResourceOperations.delete} ```typespec -op Azure.ResourceManager.TenantResourceOperations.delete(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TenantResourceOperations.delete(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TenantResourceOperations.listByParent` {#Azure.ResourceManager.TenantResourceOperations.listByParent} ```typespec -op Azure.ResourceManager.TenantResourceOperations.listByParent(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TenantResourceOperations.listByParent(apiVersion: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `TrackedResourceOperations` {#Azure.ResourceManager.TrackedResourceOperations} @@ -574,37 +574,37 @@ interface Azure.ResourceManager.TrackedResourceOperations | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.get(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TrackedResourceOperations.createOrUpdate` {#Azure.ResourceManager.TrackedResourceOperations.createOrUpdate} ```typespec -op Azure.ResourceManager.TrackedResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.createOrUpdate(provider: "Microsoft.ThisWillBeReplaced", resource: Resource): Azure.ResourceManager.ArmResourceUpdatedResponse | Azure.ResourceManager.ArmResourceCreatedResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TrackedResourceOperations.update` {#Azure.ResourceManager.TrackedResourceOperations.update} ```typespec -op Azure.ResourceManager.TrackedResourceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.update(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TrackedResourceOperations.delete` {#Azure.ResourceManager.TrackedResourceOperations.delete} ```typespec -op Azure.ResourceManager.TrackedResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.delete(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmDeletedResponse | Azure.ResourceManager.ArmDeleteAcceptedLroResponse | Azure.ResourceManager.ArmDeletedNoContentResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TrackedResourceOperations.listByParent` {#Azure.ResourceManager.TrackedResourceOperations.listByParent} ```typespec -op Azure.ResourceManager.TrackedResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.listByParent(provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### `TrackedResourceOperations.listBySubscription` {#Azure.ResourceManager.TrackedResourceOperations.listBySubscription} ```typespec -op Azure.ResourceManager.TrackedResourceOperations.listBySubscription(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.TrackedResourceOperations.listBySubscription(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced"): Azure.ResourceManager.ArmResponse> | Azure.ResourceManager.CommonTypes.ErrorResponse ``` ### `ArmCustomPatchAsync` {#Azure.ResourceManager.ArmCustomPatchAsync} @@ -651,7 +651,7 @@ op Azure.ResourceManager.ArmCustomPatchSync(provider: "Microsoft.ThisWillBeRepla A resource list operation, at the subscription scope ```typespec -op Azure.ResourceManager.ArmListBySubscription(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced"): Response | Error +op Azure.ResourceManager.ArmListBySubscription(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced"): Response | Error ``` #### Template Parameters @@ -970,7 +970,7 @@ op Azure.ResourceManager.ArmResourceListByParent(provider: "Microsoft.ThisWillBe ### `ArmResourcePatchAsync` {#Azure.ResourceManager.ArmResourcePatchAsync} ```typespec -op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -986,7 +986,7 @@ op Azure.ResourceManager.ArmResourcePatchAsync(provider: "Microsoft.ThisWillBeRe ### `ArmResourcePatchSync` {#Azure.ResourceManager.ArmResourcePatchSync} ```typespec -op Azure.ResourceManager.ArmResourcePatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ArmResourcePatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.ResourceUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -1019,7 +1019,7 @@ op Azure.ResourceManager.ArmResourceRead(provider: "Microsoft.ThisWillBeReplaced ### `ArmTagsPatchAsync` {#Azure.ResourceManager.ArmTagsPatchAsync} ```typespec -op Azure.ResourceManager.ArmTagsPatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.TagsUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ArmTagsPatchAsync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.TagsUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ArmAcceptedLroResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -1035,7 +1035,7 @@ op Azure.ResourceManager.ArmTagsPatchAsync(provider: "Microsoft.ThisWillBeReplac ### `ArmTagsPatchSync` {#Azure.ResourceManager.ArmTagsPatchSync} ```typespec -op Azure.ResourceManager.ArmTagsPatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.TagsUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.ArmTagsPatchSync(provider: "Microsoft.ThisWillBeReplaced", properties: Azure.ResourceManager.Foundations.TagsUpdateModel): Azure.ResourceManager.ArmResponse | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -1049,7 +1049,7 @@ op Azure.ResourceManager.ArmTagsPatchSync(provider: "Microsoft.ThisWillBeReplace ### `checkGlobalNameAvailability` {#Azure.ResourceManager.checkGlobalNameAvailability} ```typespec -op Azure.ResourceManager.checkGlobalNameAvailability(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced", body: Request): Response | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.checkGlobalNameAvailability(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced", body: Request): Response | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -1063,7 +1063,7 @@ op Azure.ResourceManager.checkGlobalNameAvailability(apiVersion: string, subscri ### `checkLocalNameAvailability` {#Azure.ResourceManager.checkLocalNameAvailability} ```typespec -op Azure.ResourceManager.checkLocalNameAvailability(apiVersion: string, subscriptionId: string, provider: "Microsoft.ThisWillBeReplaced", location: string, body: Request): Response | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.checkLocalNameAvailability(apiVersion: string, subscriptionId: Azure.Core.uuid, provider: "Microsoft.ThisWillBeReplaced", location: string, body: Request): Response | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters @@ -1127,7 +1127,7 @@ a resource name must be globally unique (for example, if the resource exposes an endpoint that uses the resource name in the url) ```typespec -op Azure.ResourceManager.Foundations.checkNameAvailability(apiVersion: string, body: Request): Response | Azure.ResourceManager.ErrorResponse +op Azure.ResourceManager.Foundations.checkNameAvailability(apiVersion: string, body: Request): Response | Azure.ResourceManager.CommonTypes.ErrorResponse ``` #### Template Parameters diff --git a/packages/samples/specs/resource-manager/arm-library/ref-library/int-templates.tsp b/packages/samples/specs/resource-manager/arm-library/ref-library/int-templates.tsp index 8e59e40e18..48b7755e1a 100644 --- a/packages/samples/specs/resource-manager/arm-library/ref-library/int-templates.tsp +++ b/packages/samples/specs/resource-manager/arm-library/ref-library/int-templates.tsp @@ -11,6 +11,7 @@ using Azure.ResourceManager; #suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "cuz" @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) +@useDependency(Azure.ResourceManager.CommonTypes.Versions.v3) @armLibraryNamespace namespace Microsoft.InterfacesTest; diff --git a/packages/samples/specs/resource-manager/arm-library/ref-library/op-templates.tsp b/packages/samples/specs/resource-manager/arm-library/ref-library/op-templates.tsp index 4106ef2383..63c4ce47eb 100644 --- a/packages/samples/specs/resource-manager/arm-library/ref-library/op-templates.tsp +++ b/packages/samples/specs/resource-manager/arm-library/ref-library/op-templates.tsp @@ -11,6 +11,7 @@ using Azure.ResourceManager; #suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "cuz" @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) +@useDependency(Azure.ResourceManager.CommonTypes.Versions.v3) @armLibraryNamespace namespace Microsoft.OperationsTest; diff --git a/packages/samples/specs/resource-manager/operations/operation-status/main.tsp b/packages/samples/specs/resource-manager/operations/operation-status/main.tsp index 62e829a52c..25a7b0d1b9 100644 --- a/packages/samples/specs/resource-manager/operations/operation-status/main.tsp +++ b/packages/samples/specs/resource-manager/operations/operation-status/main.tsp @@ -19,7 +19,7 @@ namespace Microsoft.OperationStatusSample; enum Versions { @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) @useDependency(Azure.Core.Versions.v1_0_Preview_2) - @armCommonTypesVersion("v5") + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) `2022-11-01-preview`, } diff --git a/packages/samples/specs/resource-manager/resource-common-properties/common-properties/main.tsp b/packages/samples/specs/resource-manager/resource-common-properties/common-properties/main.tsp new file mode 100644 index 0000000000..0b9bfdeb33 --- /dev/null +++ b/packages/samples/specs/resource-manager/resource-common-properties/common-properties/main.tsp @@ -0,0 +1,68 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.ResourceManager; +using Azure.Core; + +@armProviderNamespace("Contoso.CommonEnvelopePropertiesExample") +@service({ + title: "Contoso.CommonEnvelopePropertiesExample", +}) +@versioned(Versions) +@doc("An example of using some of common envelope and property bag properties in a resource type. Their names are all end with 'Property'.") +namespace Microsoft.UpdateTests; + +/** UpdateTests API versions */ +enum Versions { + /** 2023-03-01-preview version */ + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) + `2023-03-01-preview`, +} + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Widget Resource") +model WidgetResource is TrackedResource { + @pattern("^[a-zA-Z0-9-]{3,24}$") + @doc("The name of the widget.") + @key("widgetName") + @segment("widgets") + @path + name: string; + + ...ExtendedLocationProperty; + ...ManagedByProperty; +} + +@doc("Widget Resource Properties.") +model WidgetResourceProperties { + @doc("The widget color.") + @visibility("create", "read") + color: string; + + /** Provisioning state */ + @visibility("read") + provisioningState?: ResourceProvisioningState; + + ...EntityTagProperty; + ...ResourceKindProperty; + ...ResourcePlanProperty; + ...ResourceSkuProperty; +} + +@armResourceOperations +interface Widgets { + get is ArmResourceRead; + create is ArmResourceCreateOrReplaceAsync; + update is ArmTagsPatchSync; + delete is ArmResourceDeleteWithoutOkAsync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; +} diff --git a/packages/samples/specs/resource-manager/resource-common-properties/encryption/main.tsp b/packages/samples/specs/resource-manager/resource-common-properties/encryption/main.tsp index a1cc373bd2..812435d79b 100644 --- a/packages/samples/specs/resource-manager/resource-common-properties/encryption/main.tsp +++ b/packages/samples/specs/resource-manager/resource-common-properties/encryption/main.tsp @@ -14,14 +14,18 @@ using Azure.Core; @service({ title: "Contoso.CustomerManagedKeyExample", }) -@OpenAPI.info({ - version: "2023-03-01-preview", -}) +@versioned(Versions) @doc("An example of using the Customer Managed Key Encryption properties in a resource type.") -@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) -@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) namespace Microsoft.UpdateTests; +/** UpdateTests API versions */ +enum Versions { + /** 2023-03-01-preview version */ + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) + `2023-03-01-preview`, +} + interface Operations extends Azure.ResourceManager.Operations {} @doc("Widget Resource") @@ -44,7 +48,7 @@ model WidgetResourceProperties { @visibility("read") provisioningState?: ResourceProvisioningState; - ...Encryption; + ...EncryptionProperty; } @armResourceOperations diff --git a/packages/samples/specs/resource-manager/resource-common-properties/managed-identity/main.tsp b/packages/samples/specs/resource-manager/resource-common-properties/managed-identity/main.tsp new file mode 100644 index 0000000000..33af6987c1 --- /dev/null +++ b/packages/samples/specs/resource-manager/resource-common-properties/managed-identity/main.tsp @@ -0,0 +1,62 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.ResourceManager; +using Azure.Core; + +@armProviderNamespace("Contoso.ManagedIdentityExample") +@service({ + title: "Contoso.ManagedIdentityExample", +}) +@versioned(Versions) +@doc("An example of using the ManagedIdentity properties in a resource type.") +namespace Microsoft.UpdateTests; + +/** UpdateTests API versions */ +enum Versions { + /** 2023-03-01-preview version */ + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) + `2023-03-01-preview`, +} + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Widget Resource") +model WidgetResource is TrackedResource { + @pattern("^[a-zA-Z0-9-]{3,24}$") + @doc("The name of the widget.") + @key("widgetName") + @segment("widgets") + @path + name: string; + + ...ManagedServiceIdentityProperty; // Or ...ManagedSystemAssignedIdentityProperty; +} + +@doc("Widget Resource Properties.") +model WidgetResourceProperties { + @doc("The widget color.") + @visibility("create", "read") + color: string; + + /** Provisioning state */ + @visibility("read") + provisioningState?: ResourceProvisioningState; +} + +@armResourceOperations +interface Widgets { + get is ArmResourceRead; + create is ArmResourceCreateOrUpdateAsync; + update is ArmTagsPatchSync; + delete is ArmResourceDeleteWithoutOkAsync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; +} diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json new file mode 100644 index 0000000000..55c9e6e16d --- /dev/null +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -0,0 +1,554 @@ +{ + "swagger": "2.0", + "info": { + "title": "Contoso.CommonEnvelopePropertiesExample", + "version": "2023-03-01-preview", + "description": "An example of using some of common envelope and property bag properties in a resource type. Their names are all end with 'Property'.", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "host": "management.azure.com", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow.", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "tags": [ + { + "name": "Operations" + }, + { + "name": "Widgets" + } + ], + "paths": { + "/providers/Contoso.CommonEnvelopePropertiesExample/operations": { + "get": { + "operationId": "Operations_List", + "tags": [ + "Operations" + ], + "description": "List the operations for the provider", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/OperationListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Contoso.CommonEnvelopePropertiesExample/widgets": { + "get": { + "operationId": "Widgets_ListBySubscription", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by subscription ID", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.CommonEnvelopePropertiesExample/widgets": { + "get": { + "operationId": "Widgets_ListByResourceGroup", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by resource group", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.CommonEnvelopePropertiesExample/widgets/{widgetName}": { + "get": { + "operationId": "Widgets_Get", + "tags": [ + "Widgets" + ], + "description": "Get a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "put": { + "operationId": "Widgets_Create", + "tags": [ + "Widgets" + ], + "description": "Create a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'WidgetResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "201": { + "description": "Resource 'WidgetResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + }, + "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Widgets_Update", + "tags": [ + "Widgets" + ], + "description": "Update a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResourceTagsUpdate" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "delete": { + "operationId": "Widgets_Delete", + "tags": [ + "Widgets" + ], + "description": "Delete a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "204": { + "description": "Resource does not exist." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + } + }, + "definitions": { + "Azure.ResourceManager.CommonTypes.ExtendedLocation": { + "type": "object", + "description": "The complex type of the extended location.", + "properties": { + "name": { + "type": "string", + "description": "The name of the extended location." + }, + "type": { + "$ref": "#/definitions/Azure.ResourceManager.CommonTypes.ExtendedLocationType", + "description": "The type of the extended location." + } + }, + "required": [ + "name", + "type" + ] + }, + "Azure.ResourceManager.CommonTypes.ExtendedLocationType": { + "type": "string", + "description": "The supported ExtendedLocation types.", + "enum": [ + "EdgeZone", + "CustomLocation" + ], + "x-ms-enum": { + "name": "ExtendedLocationType", + "modelAsString": true, + "values": [ + { + "name": "EdgeZone", + "value": "EdgeZone", + "description": "Azure Edge Zones location type" + }, + { + "name": "CustomLocation", + "value": "CustomLocation", + "description": "Azure Custom Locations type" + } + ] + } + }, + "Azure.ResourceManager.ResourceProvisioningState": { + "type": "string", + "description": "The provisioning state of a resource type.", + "enum": [ + "Succeeded", + "Failed", + "Canceled" + ], + "x-ms-enum": { + "name": "ResourceProvisioningState", + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + } + ] + }, + "readOnly": true + }, + "WidgetResource": { + "type": "object", + "description": "Widget Resource", + "properties": { + "properties": { + "$ref": "#/definitions/WidgetResourceProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + }, + "extendedLocation": { + "$ref": "#/definitions/Azure.ResourceManager.CommonTypes.ExtendedLocation", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "managedBy": { + "type": "string", + "description": "The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource." + } + }, + "allOf": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/TrackedResource" + } + ] + }, + "WidgetResourceListResult": { + "type": "object", + "description": "The response of a WidgetResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The WidgetResource items on this page", + "items": { + "$ref": "#/definitions/WidgetResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "WidgetResourceProperties": { + "type": "object", + "description": "Widget Resource Properties.", + "properties": { + "color": { + "type": "string", + "description": "The widget color.", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "provisioningState": { + "$ref": "#/definitions/Azure.ResourceManager.ResourceProvisioningState", + "description": "Provisioning state", + "readOnly": true + }, + "eTag": { + "type": "string", + "description": "If eTag is provided in the response body, it may also be provided as a header per the normal etag convention. Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields.", + "readOnly": true + }, + "kind": { + "type": "string", + "description": "Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value.", + "pattern": "^[-\\w\\._,\\(\\\\\\)]+$", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "plan": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Plan", + "description": "Details of the resource plan." + }, + "sku": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/Sku", + "description": "The SKU (Stock Keeping Unit) assigned to this resource." + } + }, + "required": [ + "color" + ] + }, + "WidgetResourceTagsUpdate": { + "type": "object", + "description": "The type used for updating tags in WidgetResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "parameters": {} +} diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json similarity index 76% rename from packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json rename to packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json index 55d9acba80..49b6327cae 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -56,20 +56,20 @@ "description": "List the operations for the provider", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" } ], "responses": { "200": { "description": "Azure operation completed successfully.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/OperationListResult" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/OperationListResult" } }, "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } }, @@ -87,10 +87,10 @@ "description": "List WidgetResource resources by subscription ID", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { @@ -103,7 +103,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } }, @@ -121,13 +121,13 @@ "description": "List WidgetResource resources by resource group", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" } ], "responses": { @@ -140,7 +140,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } }, @@ -158,13 +158,13 @@ "description": "Get a WidgetResource", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" }, { "name": "widgetName", @@ -185,7 +185,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } } @@ -198,13 +198,13 @@ "description": "Create a WidgetResource", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" }, { "name": "widgetName", @@ -251,7 +251,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } }, @@ -268,13 +268,13 @@ "description": "Update a WidgetResource", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" }, { "name": "widgetName", @@ -304,7 +304,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } } @@ -317,13 +317,13 @@ "description": "Delete a WidgetResource", "parameters": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" }, { "name": "widgetName", @@ -355,7 +355,7 @@ "default": { "description": "An unexpected error response.", "schema": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" } } }, @@ -414,7 +414,7 @@ }, "allOf": [ { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/TrackedResource" + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/TrackedResource" } ] }, @@ -457,7 +457,7 @@ "readOnly": true }, "encryption": { - "$ref": "../../../../../../../../specs/resource-manager/common-types/v5/customermanagedkeys.json#/definitions/encryption", + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/customermanagedkeys.json#/definitions/encryption", "description": "All encryption configuration for a resource." } }, diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json new file mode 100644 index 0000000000..f90ff76fb9 --- /dev/null +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -0,0 +1,483 @@ +{ + "swagger": "2.0", + "info": { + "title": "Contoso.ManagedIdentityExample", + "version": "2023-03-01-preview", + "description": "An example of using the ManagedIdentity properties in a resource type.", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "host": "management.azure.com", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow.", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "tags": [ + { + "name": "Operations" + }, + { + "name": "Widgets" + } + ], + "paths": { + "/providers/Contoso.ManagedIdentityExample/operations": { + "get": { + "operationId": "Operations_List", + "tags": [ + "Operations" + ], + "description": "List the operations for the provider", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/OperationListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Contoso.ManagedIdentityExample/widgets": { + "get": { + "operationId": "Widgets_ListBySubscription", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by subscription ID", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.ManagedIdentityExample/widgets": { + "get": { + "operationId": "Widgets_ListByResourceGroup", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by resource group", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.ManagedIdentityExample/widgets/{widgetName}": { + "get": { + "operationId": "Widgets_Get", + "tags": [ + "Widgets" + ], + "description": "Get a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "put": { + "operationId": "Widgets_Create", + "tags": [ + "Widgets" + ], + "description": "Create a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'WidgetResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "201": { + "description": "Resource 'WidgetResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + }, + "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Widgets_Update", + "tags": [ + "Widgets" + ], + "description": "Update a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResourceTagsUpdate" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + } + }, + "delete": { + "operationId": "Widgets_Delete", + "tags": [ + "Widgets" + ], + "description": "Delete a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "204": { + "description": "Resource does not exist." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + } + }, + "definitions": { + "Azure.ResourceManager.ResourceProvisioningState": { + "type": "string", + "description": "The provisioning state of a resource type.", + "enum": [ + "Succeeded", + "Failed", + "Canceled" + ], + "x-ms-enum": { + "name": "ResourceProvisioningState", + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + } + ] + }, + "readOnly": true + }, + "WidgetResource": { + "type": "object", + "description": "Widget Resource", + "properties": { + "properties": { + "$ref": "#/definitions/WidgetResourceProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true, + "x-ms-mutability": [ + "read", + "create" + ] + }, + "identity": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/managedidentity.json#/definitions/ManagedServiceIdentity", + "description": "The managed service identities assigned to this resource." + } + }, + "allOf": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/types.json#/definitions/TrackedResource" + } + ] + }, + "WidgetResourceListResult": { + "type": "object", + "description": "The response of a WidgetResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The WidgetResource items on this page", + "items": { + "$ref": "#/definitions/WidgetResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "WidgetResourceProperties": { + "type": "object", + "description": "Widget Resource Properties.", + "properties": { + "color": { + "type": "string", + "description": "The widget color.", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "provisioningState": { + "$ref": "#/definitions/Azure.ResourceManager.ResourceProvisioningState", + "description": "Provisioning state", + "readOnly": true + } + }, + "required": [ + "color" + ] + }, + "WidgetResourceTagsUpdate": { + "type": "object", + "description": "The type used for updating tags in WidgetResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "parameters": {} +} diff --git a/packages/typespec-autorest/test/arm/arm.test.ts b/packages/typespec-autorest/test/arm/arm.test.ts index 39513d75f0..35d3b5cfb5 100644 --- a/packages/typespec-autorest/test/arm/arm.test.ts +++ b/packages/typespec-autorest/test/arm/arm.test.ts @@ -69,6 +69,7 @@ it("can share types with a library namespace", async () => { it("can use private links with common-types references", async () => { const openapi = await openApiFor( `@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) @armProviderNamespace namespace Microsoft.PrivateLinkTest; @@ -120,6 +121,7 @@ it("can use private endpoints with common-types references", async () => { const openapi = await openApiFor( `@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) @armProviderNamespace + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) namespace Microsoft.PrivateLinkTest; interface Operations extends Azure.ResourceManager.Operations {} @@ -160,6 +162,7 @@ it("can use ResourceNameParameter for custom name parameter definition", async ( const openapi = await openApiFor( `@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) @armProviderNamespace + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) namespace Microsoft.PrivateLinkTest; interface Operations extends Azure.ResourceManager.Operations {} @@ -199,6 +202,7 @@ it("can use ResourceNameParameter for default name parameter definition", async const openapi = await openApiFor( `@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) @armProviderNamespace + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) namespace Microsoft.PrivateLinkTest; interface Operations extends Azure.ResourceManager.Operations {} diff --git a/packages/typespec-azure-portal-core/test/decorators.test.ts b/packages/typespec-azure-portal-core/test/decorators.test.ts index 91cd9a37d3..41390cfe3f 100644 --- a/packages/typespec-azure-portal-core/test/decorators.test.ts +++ b/packages/typespec-azure-portal-core/test/decorators.test.ts @@ -296,10 +296,12 @@ export function createTestSpec( enum Versions { @useDependency(Azure.Core.Versions.v1_0_Preview_2) @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_09_02_preview: "2022-09-02-preview", @useDependency(Azure.Core.Versions.v1_0_Preview_2) @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) v2024_02_20_preview: "2024-02-20-preview", } diff --git a/packages/typespec-azure-resource-manager/README.md b/packages/typespec-azure-resource-manager/README.md index a539c76ec9..703b9022a6 100644 --- a/packages/typespec-azure-resource-manager/README.md +++ b/packages/typespec-azure-resource-manager/README.md @@ -103,9 +103,9 @@ the version of the Azure Resource Manager common-types to use for refs in emitte ##### Parameters -| Name | Type | Description | -| ------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| version | `valueof string \| EnumMember` | The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value. | +| Name | Type | Description | +| ------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | +| version | `valueof string \| EnumMember` | The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value like "v5". | #### `@armLibraryNamespace` diff --git a/packages/typespec-azure-resource-manager/lib/arm.tsp b/packages/typespec-azure-resource-manager/lib/arm.tsp index dec73193f1..0a471f32bc 100644 --- a/packages/typespec-azure-resource-manager/lib/arm.tsp +++ b/packages/typespec-azure-resource-manager/lib/arm.tsp @@ -5,14 +5,9 @@ import "@typespec/rest"; import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; -import "./arm.foundations.tsp"; +import "./foundations/arm.foundations.tsp"; import "./common-types/common-types.tsp"; -import "./common-types/backcompat.tsp"; -import "./common-types/types.tsp"; -import "./common-types/managed-identity.tsp"; -import "./common-types/private-links.tsp"; -import "./common-types/customer-managed-keys.tsp"; -import "./common-types/extended-location.tsp"; +import "./backcompat.tsp"; import "./private.decorators.tsp"; import "./models.tsp"; import "./operations.tsp"; diff --git a/packages/typespec-azure-resource-manager/lib/backcompat.tsp b/packages/typespec-azure-resource-manager/lib/backcompat.tsp new file mode 100644 index 0000000000..57a60f2ac1 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/backcompat.tsp @@ -0,0 +1,27 @@ +using Azure.ResourceManager.CommonTypes; + +namespace Azure.ResourceManager; + +// customer-managed-keys +alias InfrastructureEncryption = CommonTypes.InfrastructureEncryption; +alias KeyEncryptionIdentity = CommonTypes.KeyEncryptionKeyIdentity; +alias KeyEncryptionKeyIdentity = CommonTypes.KeyEncryptionKeyIdentity; +alias CustomerManagedKeyEncryption = CommonTypes.CustomerManagedKeyEncryption; +alias EncryptionConfiguration = CommonTypes.Encryption; + +// private-links +alias PrivateEndpoint = CommonTypes.PrivateEndpoint; +alias PrivateEndpointConnection = CommonTypes.PrivateEndpointConnection; +alias PrivateEndpointConnectionProperties = CommonTypes.PrivateEndpointConnectionProperties; +alias PrivateLinkServiceConnectionState = CommonTypes.PrivateLinkServiceConnectionState; +alias PrivateEndpointConnectionProvisioningState = CommonTypes.PrivateEndpointConnectionProvisioningState; +alias PrivateEndpointServiceConnectionStatus = CommonTypes.PrivateEndpointServiceConnectionStatus; +alias PrivateEndpointConnectionParameter = CommonTypes.PrivateEndpointConnectionParameter; +alias PrivateLinkResource = CommonTypes.PrivateLinkResource; +alias PrivateLinkResourceProperties = CommonTypes.PrivateLinkResourceProperties; +alias PrivateLinkResourceParameter = CommonTypes.PrivateLinkResourceParameter; +alias PrivateEndpointConnectionResourceListResult = CommonTypes.PrivateEndpointConnectionListResult; +alias PrivateLinkResourceListResult = CommonTypes.PrivateLinkResourceListResult; + +// types +alias ErrorResponse = CommonTypes.ErrorResponse; diff --git a/packages/typespec-azure-resource-manager/lib/common-types/common-types.tsp b/packages/typespec-azure-resource-manager/lib/common-types/common-types.tsp index 187403ac1a..211ef3d5e5 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/common-types.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/common-types.tsp @@ -1,10 +1,20 @@ import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "./common-types.tsp"; +import "./types-ref.tsp"; +import "./managed-identity-ref.tsp"; +import "./private-links-ref.tsp"; +import "./customer-managed-keys-ref.tsp"; +import "./extended-location-ref.tsp"; +import "./internal.tsp"; +import "./commontypes.private.decorators.tsp"; using TypeSpec.Versioning; +@versioned(Versions) namespace Azure.ResourceManager.CommonTypes; -@Private.armCommonTypesVersions +@CommonTypes.Private.armCommonTypesVersions @doc("The Azure Resource Manager common-types versions.") enum Versions { @doc("The Azure Resource Manager v3 common types.") diff --git a/packages/typespec-azure-resource-manager/lib/common-types/commontypes.private.decorators.tsp b/packages/typespec-azure-resource-manager/lib/common-types/commontypes.private.decorators.tsp new file mode 100644 index 0000000000..889a7ec8e1 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/commontypes.private.decorators.tsp @@ -0,0 +1,43 @@ +import "../../dist/src/commontypes.private.decorators.js"; + +namespace Azure.ResourceManager.CommonTypes.Private; + +using TypeSpec.Reflection; + +/** + * Describes the shape of model literals accepted by the `version` parameter of + * the `armCommonDefinition` and `armCommonParameter` decorators. + */ +alias ArmCommonTypeVersionSpec = { + version: string | EnumMember; + isDefault: boolean; +}; + +/** + * @param definitionName Definition name + * @param version Azure Resource Manager Version + * @param referenceFile Reference file + */ +extern dec armCommonDefinition( + target: Model, + definitionName?: valueof string, + version?: valueof EnumMember | ArmCommonTypeVersionSpec | string, + referenceFile?: valueof string +); + +/** + * @param definitionName Definition name + * @param version Azure Resource Manager Version + * @param referenceFile Reference file + */ +extern dec armCommonParameter( + target: ModelProperty, + definitionName?: valueof string, + version?: valueof EnumMember | ArmCommonTypeVersionSpec | string, + referenceFile?: valueof string +); + +/** + * Marks an enum as representing the valid `common-types` versions. + */ +extern dec armCommonTypesVersions(target: Enum); diff --git a/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys-ref.tsp b/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys-ref.tsp new file mode 100644 index 0000000000..3df1e5168a --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys-ref.tsp @@ -0,0 +1,27 @@ +import "./customer-managed-keys.tsp"; + +using Azure.ResourceManager.CommonTypes.Private; + +namespace Azure.ResourceManager.CommonTypes; + +@@armCommonDefinition(Encryption, + "encryption", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, + "customermanagedkeys.json" +); +@@armCommonDefinition(Encryption, + "encryption", + Azure.ResourceManager.CommonTypes.Versions.v5, + "customermanagedkeys.json" +); + +@@armCommonDefinition(CustomerManagedKeyEncryption, + "customerManagedKeyEncryption", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, + "customermanagedkeys.json" +); +@@armCommonDefinition(CustomerManagedKeyEncryption, + "customerManagedKeyEncryption", + Azure.ResourceManager.CommonTypes.Versions.v5, + "customermanagedkeys.json" +); diff --git a/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys.tsp b/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys.tsp index eefe408a05..577098f95b 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/customer-managed-keys.tsp @@ -1,84 +1,75 @@ using Azure.Core; -using Azure.ResourceManager.Private; +using TypeSpec.Versioning; -namespace Azure.ResourceManager; +namespace Azure.ResourceManager.CommonTypes; -@doc("(Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled.") +/** (Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled. */ +@added(Versions.v4) union InfrastructureEncryption { - @doc("Encryption is enabled") + /** Encryption is enabled */ Enabled: "enabled", - @doc("Encryption is disabled") + /** Encryption is disabled */ Disabled: "disabled", string, } -/** Alias of keyEncryptionKeyIdentity for back compatibility. Please change to keyEncryptionKeyIdentity. */ -alias KeyEncryptionIdentity = KeyEncryptionKeyIdentity; - -@doc("The type of identity to use.") -union KeyEncryptionKeyIdentity { - @doc("System assigned identity") +/** The type of identity to use. */ +@added(Versions.v4) +union KeyEncryptionKeyIdentityType { + /** System assigned identity */ SystemAssignedIdentity: "systemAssignedIdentity", - @doc("User assigned identity") + /** User assigned identity */ UserAssignedIdentity: "userAssignedIdentity", - @doc("Delegated identity") + /** Delegated identity */ DelegatedResourceIdentity: "delegatedResourceIdentity", string, } -@doc("Customer-managed key encryption properties for the resource.") -model CustomerManagedKeyEncryption { - @doc("The type of identity to use. Values can be systemAssignedIdentity, userAssignedIdentity, or delegatedResourceIdentity.") - keyEncryptionKeyIdentity?: KeyEncryptionKeyIdentity; +/** All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. */ +@added(Versions.v4) +model KeyEncryptionKeyIdentity { + /** The type of identity to use. Values can be systemAssignedIdentity, userAssignedIdentity, or delegatedResourceIdentity. */ + identityType?: KeyEncryptionKeyIdentityType; - @doc("User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.") + /** User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity. */ userAssignedIdentityResourceId?: Azure.Core.armResourceIdentifier<[ { type: "Microsoft.ManagedIdentity/userAssignedIdentities"; } ]>; - @doc("application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540") + /** application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540 */ + @added(Versions.v5) federatedClientId?: uuid; - @doc("delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only.") + /** delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only. */ delegatedIdentityClientId?: uuid; } -@doc("All encryption configuration for a resource.") -@armCommonDefinition( - "encryption", - Azure.ResourceManager.CommonTypes.Versions.v5, - "customermanagedkeys.json" -) -model EncryptionConfiguration { - @doc("Indicates if infrastructure encryption is enabled or disabled.") - infrastructureEncryption?: InfrastructureEncryption; - - @doc("All customer-managed key encryption properties for the resource.") - customerManagedKeyEncryption?: CustomerManagedKeyEncryption; +/** Customer-managed key encryption properties for the resource. */ +@added(Versions.v4) +model CustomerManagedKeyEncryption { + /** All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. */ + keyEncryptionKeyIdentity?: KeyEncryptionKeyIdentity; - @doc("key encryption key Url, versioned or unversioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek.") + /** key encryption key Url, versioned or non-versioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek. */ keyEncryptionKeyUrl?: string; } -/** - * Model used only to spread in the `encryption` envelope property for a resource. - * @example - * - * ```typespec - * model Foo is TrackedResource { - * ...Encryption; - * } - * ``` - */ -@doc("All encryption configuration for a resource.") +/** (Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled. */ +@added(Versions.v4) +@encodedName("application/json", "encryption") model Encryption { - @doc("All encryption configuration for a resource.") - encryption: EncryptionConfiguration; + /** Values are enabled and disabled. */ + infrastructureEncryption?: InfrastructureEncryption; + + /** All Customer-managed key encryption properties for the resource. */ + @added(Versions.v4) + @removed(Versions.v5) + customerManagedKeyEncryption?: CustomerManagedKeyEncryption; } diff --git a/packages/typespec-azure-resource-manager/lib/common-types/extended-location-ref.tsp b/packages/typespec-azure-resource-manager/lib/common-types/extended-location-ref.tsp new file mode 100644 index 0000000000..5feca7a65a --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/extended-location-ref.tsp @@ -0,0 +1 @@ +import "./extended-location.tsp"; diff --git a/packages/typespec-azure-resource-manager/lib/common-types/extended-location.tsp b/packages/typespec-azure-resource-manager/lib/common-types/extended-location.tsp index c9a7a398d8..3ff52b38aa 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/extended-location.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/extended-location.tsp @@ -1,21 +1,20 @@ -namespace Azure.ResourceManager.Foundations { - /** The complex type of the extended location. */ - model ExtendedLocation { - /** The name of the extended location. */ - name: string; +namespace Azure.ResourceManager.CommonTypes; +/** The complex type of the extended location. */ +model ExtendedLocation { + /** The name of the extended location. */ + name: string; - /** The type of the extended location. */ - type: ExtendedLocationType; - } + /** The type of the extended location. */ + type: ExtendedLocationType; +} - /** The supported ExtendedLocation types. */ - union ExtendedLocationType { - /** Azure Edge Zones location type */ - EdgeZone: "EdgeZone", +/** The supported ExtendedLocation types. */ +union ExtendedLocationType { + /** Azure Edge Zones location type */ + EdgeZone: "EdgeZone", - /** Azure Custom Locations type */ - CustomLocation: "CustomLocation", + /** Azure Custom Locations type */ + CustomLocation: "CustomLocation", - string, - } + string, } diff --git a/packages/typespec-azure-resource-manager/lib/common-types/internal.tsp b/packages/typespec-azure-resource-manager/lib/common-types/internal.tsp new file mode 100644 index 0000000000..c1334a48a3 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/internal.tsp @@ -0,0 +1,24 @@ +namespace Azure.ResourceManager.CommonTypes; + +/** + * An internal enum to indicate the resource support for various path types + */ +enum ResourceHome { + @doc("The resource is bound to a tenant") + Tenant, + + @doc("The resource is bound to a subscription") + Subscription, + + @doc("The resource is bound to a location") + Location, + + @doc("The resource is bound to a resource group") + ResourceGroup, + + @doc("The resource is bound to an extension") + Extension, +} + +/** Alias of keyEncryptionKeyIdentity for back compatibility. Please change to keyEncryptionKeyIdentity. */ +alias KeyEncryptionIdentity = KeyEncryptionKeyIdentity; diff --git a/packages/typespec-azure-resource-manager/lib/common-types/managed-identity-ref.tsp b/packages/typespec-azure-resource-manager/lib/common-types/managed-identity-ref.tsp new file mode 100644 index 0000000000..c839d489ed --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/managed-identity-ref.tsp @@ -0,0 +1,79 @@ +import "./managed-identity.tsp"; + +using Azure.ResourceManager.CommonTypes.Private; + +namespace Azure.ResourceManager.CommonTypes; + +/** + * The properties of the managed service identities assigned to this resource. + */ +@@armCommonDefinition(ManagedServiceIdentity, + "ManagedServiceIdentity", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "managedidentity.json" +); +@@armCommonDefinition(ManagedServiceIdentity, + "ManagedServiceIdentity", + Azure.ResourceManager.CommonTypes.Versions.v4, + "managedidentity.json" +); +@@armCommonDefinition(ManagedServiceIdentity, + "ManagedServiceIdentity", + Azure.ResourceManager.CommonTypes.Versions.v5, + "managedidentity.json" +); + +/** The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", */ +@@armCommonDefinition(UserAssignedIdentities, + "UserAssignedIdentities", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "managedidentity.json" +); +@@armCommonDefinition(UserAssignedIdentities, + "UserAssignedIdentities", + Azure.ResourceManager.CommonTypes.Versions.v4, + "managedidentity.json" +); +@@armCommonDefinition(UserAssignedIdentities, + "UserAssignedIdentities", + Azure.ResourceManager.CommonTypes.Versions.v5, + "managedidentity.json" +); + +/** + * The properties of the service-assigned identity associated with this resource. + */ +@@armCommonDefinition(SystemAssignedServiceIdentity, + "SystemAssignedServiceIdentity", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "managedidentity.json" +); +@@armCommonDefinition(SystemAssignedServiceIdentity, + "SystemAssignedServiceIdentity", + Azure.ResourceManager.CommonTypes.Versions.v4, + "managedidentity.json" +); +@@armCommonDefinition(SystemAssignedServiceIdentity, + "SystemAssignedServiceIdentity", + Azure.ResourceManager.CommonTypes.Versions.v5, + "managedidentity.json" +); + +/** + * A managed identity assigned by the user. + */ +@@armCommonDefinition(UserAssignedIdentity, + "UserAssignedIdentity", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "managedidentity.json" +); +@@armCommonDefinition(UserAssignedIdentity, + "UserAssignedIdentity", + Azure.ResourceManager.CommonTypes.Versions.v4, + "managedidentity.json" +); +@@armCommonDefinition(UserAssignedIdentity, + "UserAssignedIdentity", + Azure.ResourceManager.CommonTypes.Versions.v5, + "managedidentity.json" +); diff --git a/packages/typespec-azure-resource-manager/lib/common-types/managed-identity.tsp b/packages/typespec-azure-resource-manager/lib/common-types/managed-identity.tsp index f44b698300..f42f111d84 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/managed-identity.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/managed-identity.tsp @@ -1,137 +1,100 @@ -using Azure.ResourceManager.Private; +using Azure.Core; +using TypeSpec.Versioning; -namespace Azure.ResourceManager.Foundations; +namespace Azure.ResourceManager.CommonTypes; + +/** The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests. */ +#deprecated "Do not use this model. Instead, use Record directly. Using this model will result in a different client SDK when generated from TypeSpec compared to the Swagger." +model UserAssignedIdentities is Record; -#deprecated "Please change ManagedIdentityProperties to ManagedServiceIdentity." -alias ManagedIdentityProperties = ManagedServiceIdentity; /** - * The properties of the managed service identities assigned to this resource. + * Managed service identity (system assigned and/or user assigned identities) */ -@armCommonDefinition( - "ManagedServiceIdentity", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "managedidentity.json" -) -@armCommonDefinition( - "ManagedServiceIdentity", - Azure.ResourceManager.CommonTypes.Versions.v5, - "managedidentity.json" -) model ManagedServiceIdentity { - @doc("The Active Directory tenant id of the principal.") + /** The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. */ @visibility("read") - tenantId?: string; + principalId?: uuid; - @doc("The active directory identifier of this principal.") + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ @visibility("read") - principalId?: string; + tenantId?: uuid; - @doc("The type of managed identity assigned to this resource.") + /** The type of managed identity assigned to this resource. */ type: ManagedServiceIdentityType; - @doc("The identities assigned to this resource by the user.") - userAssignedIdentities?: Record; + /** The identities assigned to this resource by the user. */ + @typeChangedFrom(Versions.v5, Record) + userAssignedIdentities?: Record | null; } -/** The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", */ -#deprecated "Do not use this model. Instead, use Record directly. Using this model will result in a different client SDK when generated from TypeSpec compared to the Swagger." -@armCommonDefinition( - "UserAssignedIdentities", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "managedidentity.json" -) -@armCommonDefinition( - "UserAssignedIdentities", - Azure.ResourceManager.CommonTypes.Versions.v5, - "managedidentity.json" -) -model UserAssignedIdentities is Record; - -#deprecated "Please change ManagedSystemIdentityProperties to SystemAssignedServiceIdentity." -alias ManagedSystemIdentityProperties = SystemAssignedServiceIdentity; /** - * The properties of the service-assigned identity associated with this resource. + * Managed service identity (either system assigned, or none) */ -@armCommonDefinition( - "SystemAssignedServiceIdentity", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "managedidentity.json" -) -@armCommonDefinition( - "SystemAssignedServiceIdentity", - Azure.ResourceManager.CommonTypes.Versions.v5, - "managedidentity.json" -) model SystemAssignedServiceIdentity { - @doc("The Active Directory tenant id of the principal.") + /** The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. */ @visibility("read") - tenantId?: string; + principalId?: uuid; - @doc("The active directory identifier of this principal.") + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ @visibility("read") - principalId?: string; + tenantId?: uuid; - @doc("The type of managed identity assigned to this resource.") + /** The type of managed identity assigned to this resource. */ type: SystemAssignedServiceIdentityType; } -/** Alias of ManagedServiceIdentityType for back compatability. Please change to ManagedServiceIdentityType. */ -#deprecated "Please change to ManagedServiceIdentityType." -alias ManagedIdentityType = ManagedServiceIdentityType; /** - * A managed identity assigned by the user. + * User assigned identity properties */ -@armCommonDefinition( - "UserAssignedIdentity", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "managedidentity.json" -) -@armCommonDefinition( - "UserAssignedIdentity", - Azure.ResourceManager.CommonTypes.Versions.v5, - "managedidentity.json" -) -@doc("A managed identity assigned by the user.") model UserAssignedIdentity { - @doc("The active directory client identifier for this principal.") - clientId?: string; + /** The principal ID of the assigned identity. */ + @visibility("read") + principalId?: uuid; - @doc("The active directory identifier for this principal.") - principalId?: string; + /** The client ID of the assigned identity. */ + @visibility("read") + clientId?: uuid; } /** - * The kind of managed identity assigned to this resource. + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). */ -@doc("The kind of managed identity assigned to this resource.") union ManagedServiceIdentityType { - @doc("No managed identity.") + /** No managed identity. */ None: "None", - @doc("System assigned managed identity.") + /** System assigned managed identity. */ SystemAssigned: "SystemAssigned", - @doc("User assigned managed identity.") + /** User assigned managed identity. */ UserAssigned: "UserAssigned", - @doc("System and user assigned managed identity.") - SystemAndUserAssigned: "SystemAssigned, UserAssigned", + /** System and user assigned managed identity. */ + @renamedFrom(Versions.v3, "SystemAndUserAssigned") + @removed(Versions.v4) + SystemAndUserAssignedV3: "SystemAssigned,UserAssigned", + + /** System and user assigned managed identity. */ + @added(Versions.v4) + @renamedFrom(Versions.v4, "SystemAndUserAssigned") + @removed(Versions.v5) + SystemAndUserAssignedV4: "SystemAssigned, UserAssigned", + + /** System and user assigned managed identity. */ + @added(Versions.v5) + SystemAndUserAssigned: "SystemAssigned,UserAssigned", string, } -/** Alias of SystemAssignedServiceIdentityType for back compatability. Please change to SystemAssignedServiceIdentityType. */ -alias ManagedSystemIdentityType = SystemAssignedServiceIdentityType; - /** - * The kind of managemed identity assigned to this resource. + * Type of managed service identity (either system assigned, or none). */ -@doc("The kind of managemed identity assigned to this resource.") union SystemAssignedServiceIdentityType { - @doc("No managed system identity.") + /** No managed system identity. */ None: "None", - @doc("System assigned managed system identity.") + /** System assigned managed system identity. */ SystemAssigned: "SystemAssigned", string, diff --git a/packages/typespec-azure-resource-manager/lib/common-types/private-links-ref.tsp b/packages/typespec-azure-resource-manager/lib/common-types/private-links-ref.tsp new file mode 100644 index 0000000000..2fca19e18d --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/private-links-ref.tsp @@ -0,0 +1,159 @@ +import "./private-links.tsp"; + +using Azure.ResourceManager.CommonTypes.Private; + +namespace Azure.ResourceManager.CommonTypes; + +/** The private endpoint */ +@@armCommonDefinition(PrivateEndpoint, + "PrivateEndpoint", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpoint, + "PrivateEndpoint", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpoint, + "PrivateEndpoint", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** The private endpoint resource */ +@@armCommonDefinition(PrivateLinkResource, + "PrivateLinkResource", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResource, + "PrivateLinkResource", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResource, + "PrivateLinkResource", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** PrivateEndpointConnection */ +@@armCommonDefinition(PrivateEndpointConnection, + "PrivateEndpointConnection", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnection, + "PrivateEndpointConnection", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnection, + "PrivateEndpointConnection", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** Properties of he private endpoint connection resource */ +@@armCommonDefinition(PrivateEndpointConnectionProperties, + "PrivateEndpointConnectionProperties", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnectionProperties, + "PrivateEndpointConnectionProperties", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnectionProperties, + "PrivateEndpointConnectionProperties", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** A collection of information about the state of the connection between service consumer and provider. */ +@@armCommonDefinition(PrivateLinkServiceConnectionState, + "PrivateLinkServiceConnectionState", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkServiceConnectionState, + "PrivateLinkServiceConnectionState", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkServiceConnectionState, + "PrivateLinkServiceConnectionState", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** Properties of a private link resource. */ +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state" "Matches current common code" +@@armCommonDefinition(PrivateLinkResourceProperties, + "PrivateLinkResourceProperties", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResourceProperties, + "PrivateLinkResourceProperties", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResourceProperties, + "PrivateLinkResourceProperties", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** PrivateEndpointConnectionListResult */ +@@armCommonDefinition(PrivateEndpointConnectionListResult, + "PrivateEndpointConnectionListResult", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnectionListResult, + "PrivateEndpointConnectionListResult", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateEndpointConnectionListResult, + "PrivateEndpointConnectionListResult", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** PrivateLinkResourceListResult */ +@@armCommonDefinition(PrivateLinkResourceListResult, + "PrivateLinkResourceListResult", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResourceListResult, + "PrivateLinkResourceListResult", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@armCommonDefinition(PrivateLinkResourceListResult, + "PrivateLinkResourceListResult", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); + +/** PrivateEndpointConnectionParameter */ +@@CommonTypes.Private.armCommonParameter(PrivateEndpointConnectionParameter.name, + "PrivateEndpointConnectionName", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v3, isDefault: true }, + "privatelinks.json" +); +@@CommonTypes.Private.armCommonParameter(PrivateEndpointConnectionParameter.name, + "PrivateEndpointConnectionName", + Azure.ResourceManager.CommonTypes.Versions.v4, + "privatelinks.json" +); +@@CommonTypes.Private.armCommonParameter(PrivateEndpointConnectionParameter.name, + "PrivateEndpointConnectionName", + Azure.ResourceManager.CommonTypes.Versions.v5, + "privatelinks.json" +); diff --git a/packages/typespec-azure-resource-manager/lib/common-types/private-links.tsp b/packages/typespec-azure-resource-manager/lib/common-types/private-links.tsp index 1936211379..694bb96022 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/private-links.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/private-links.tsp @@ -1,29 +1,13 @@ -import "@typespec/openapi"; -import "@typespec/http"; -import "@typespec/rest"; -import "@typespec/versioning"; -import "@azure-tools/typespec-azure-core"; - using TypeSpec.Http; -using TypeSpec.OpenAPI; using TypeSpec.Versioning; -using Azure.ResourceManager.Private; - -namespace Azure.ResourceManager; - -/** The private endpoint resource */ -@armCommonDefinition( - "PrivateEndpoint", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "privatelinks.json" -) -@armCommonDefinition( - "PrivateEndpoint", - Azure.ResourceManager.CommonTypes.Versions.v5, - "privatelinks.json" -) +using OpenAPI; + +namespace Azure.ResourceManager.CommonTypes; + +/** The Private Endpoint resource. */ model PrivateEndpoint { /** The resource identifier for private endpoint */ + @visibility("read") id?: Azure.Core.armResourceIdentifier<[ { type: "Microsoft.Network/privateEndpoints"; @@ -31,49 +15,65 @@ model PrivateEndpoint { ]>; } +/** A private link resource. */ +model PrivateLinkResource extends Resource { + /** Resource properties. */ + @extension("x-ms-client-flatten", true) + properties?: PrivateLinkResourceProperties; +} + +/** Properties of a private link resource. */ +model PrivateLinkResourceProperties { + /** The private link resource group id. */ + @visibility("read") + groupId?: string; + + /** The private link resource required member names. */ + @visibility("read") + requiredMembers?: string[]; + + /** The private link resource private link DNS zone name. */ + requiredZoneNames?: string[]; +} + +/** A list of private link resources. */ +model PrivateLinkResourceListResult { + /** Array of private link resources */ + value?: PrivateLinkResource[]; +} +//#region /** The private endpoint connection resource */ -model PrivateEndpointConnection extends Azure.ResourceManager.Foundations.ProxyResource { +model PrivateEndpointConnection extends Resource { /** The private endpoint connection properties */ + @extension("x-ms-client-flatten", true) properties?: PrivateEndpointConnectionProperties; } -/** Properties of he private endpoint connection resource */ -@armCommonDefinition( - "PrivateEndpointConnectionProperties", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "privatelinks.json" -) -@armCommonDefinition( - "PrivateEndpointConnectionProperties", - Azure.ResourceManager.CommonTypes.Versions.v5, - "privatelinks.json" -) +/** List of private endpoint connections associated with the specified resource. */ +model PrivateEndpointConnectionListResult { + /** Array of private endpoint connections. */ + value?: PrivateEndpointConnection[]; +} + +/** Properties of the private endpoint connection. */ model PrivateEndpointConnectionProperties { - /** The group identifiers for the private endpoint resource */ + /** The group ids for the private endpoint resource. */ @visibility("read") + @added(Versions.v4) groupIds?: string[]; - /** The private endpoint resource */ + /** The private endpoint resource. */ privateEndpoint?: PrivateEndpoint; /** A collection of information about the state of the connection between service consumer and provider. */ privateLinkServiceConnectionState: PrivateLinkServiceConnectionState; /** The provisioning state of the private endpoint connection resource. */ + @visibility("read") provisioningState?: PrivateEndpointConnectionProvisioningState; } /** A collection of information about the state of the connection between service consumer and provider. */ -@armCommonDefinition( - "PrivateLinkServiceConnectionState", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "privatelinks.json" -) -@armCommonDefinition( - "PrivateLinkServiceConnectionState", - Azure.ResourceManager.CommonTypes.Versions.v5, - "privatelinks.json" -) model PrivateLinkServiceConnectionState { /** Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. */ status?: PrivateEndpointServiceConnectionStatus; @@ -85,18 +85,24 @@ model PrivateLinkServiceConnectionState { actionsRequired?: string; } -/** The provisioning state of the connection */ +/** The current provisioning state. */ union PrivateEndpointConnectionProvisioningState { - ResourceProvisioningState, + string, + + /** Connection has been provisioned */ + Succeeded: "Succeeded", /** Connection is being created */ Creating: "Creating", /** Connection is being deleted */ Deleting: "Deleting", + + /** Connection provisioning has failed */ + Failed: "Failed", } -/** The private endpoint connection status */ +/** The private endpoint connection status. */ union PrivateEndpointServiceConnectionStatus { /** Connectionaiting for approval or rejection */ Pending: "Pending", @@ -110,48 +116,6 @@ union PrivateEndpointServiceConnectionStatus { string, } -model PrivateLinkResource extends Azure.ResourceManager.Foundations.ProxyResource { - /** Properties of the private link resource. */ - properties?: PrivateLinkResourceProperties; -} - -/** Properties of a private link resource. */ -#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state" "Matches current common code" -@armCommonDefinition( - "PrivateLinkResourceProperties", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "privatelinks.json" -) -@armCommonDefinition( - "PrivateLinkResourceProperties", - Azure.ResourceManager.CommonTypes.Versions.v5, - "privatelinks.json" -) -model PrivateLinkResourceProperties { - /** The private link resource group id. */ - @visibility("read") - groupId?: string; - - /** The private link resource required member names. */ - @visibility("read") - requiredMembers?: string[]; - - /** The private link resource private link DNS zone name. */ - requiredZoneNames?: string[]; -} - -/** List of private endpoint connections associated with the specified resource. */ -model PrivateEndpointConnectionResourceListResult { - /** Array of private endpoint connections */ - value?: PrivateEndpointConnection[]; -} - -/** A list of private link resources. */ -model PrivateLinkResourceListResult { - /** Array of private link resources */ - value?: PrivateLinkResource[]; -} - /** * The name of the private endpoint connection associated with the Azure resource. * @template Segment The resource type name for private endpoint connections (default is privateEndpointConnections) @@ -159,16 +123,6 @@ model PrivateLinkResourceListResult { model PrivateEndpointConnectionParameter { /** The name of the private endpoint connection associated with the Azure resource. */ @path - @armCommonParameter( - "PrivateEndpointConnectionName", - #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, - "privatelinks.json" - ) - @armCommonParameter( - "PrivateEndpointConnectionName", - Azure.ResourceManager.CommonTypes.Versions.v5, - "privatelinks.json" - ) @TypeSpec.Rest.segment(Segment) @key("privateEndpointConnectionName") name: string; diff --git a/packages/typespec-azure-resource-manager/lib/common-types/types-ref.tsp b/packages/typespec-azure-resource-manager/lib/common-types/types-ref.tsp new file mode 100644 index 0000000000..09cadfb7ba --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/common-types/types-ref.tsp @@ -0,0 +1,414 @@ +import "../private.decorators.tsp"; +import "./common-types.tsp"; +import "./types.tsp"; + +using Azure.ResourceManager.Private; +using Azure.ResourceManager.CommonTypes.Private; + +namespace Azure.ResourceManager.CommonTypes; + +/** Common resource fields that are returned in the response for all Azure Resource Manager resources. */ +@@armCommonDefinition(Resource, "Resource", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(Resource, "Resource", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(Resource, "Resource", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** The resource model definition for an Azure Resource Manager resource with an etag. */ +@@armCommonDefinition(AzureEntityResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(AzureEntityResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(AzureEntityResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The base tracked resource. + */ +@@armCommonDefinition(TrackedResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(TrackedResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(TrackedResource, + "TrackedResource", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The base proxy resource. + */ +@@armCommonDefinition(ProxyResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(ProxyResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(ProxyResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The base extension resource. + */ +@@armCommonDefinition(ExtensionResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(ExtensionResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(ExtensionResource, + "ProxyResource", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The SKU (Stock Keeping Unit) assigned to this resource. + */ +@@armCommonDefinition(Sku, "Sku", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(Sku, "Sku", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(Sku, "Sku", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + */ +@@armCommonDefinition(OperationListResult, + "OperationListResult", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(OperationListResult, + "OperationListResult", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(OperationListResult, + "OperationListResult", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API + */ +@@armCommonDefinition(Operation, "Operation", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(Operation, "Operation", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(Operation, "Operation", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * Localized display information for and operation. + */ +@@armCommonDefinition(OperationDisplay, + "OperationDisplay", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(OperationDisplay, + "OperationDisplay", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(OperationDisplay, + "OperationDisplay", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The current status of an async operation. + */ +@@armCommonDefinition(OperationStatusResult, + "OperationStatusResult", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(OperationStatusResult, + "OperationStatusResult", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(OperationStatusResult, + "OperationStatusResult", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * locationData + */ +@@armCommonDefinition(LocationData, "locationData", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(LocationData, "locationData", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(LocationData, "locationData", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * The error detail. + */ +@@armCommonDefinition(ErrorDetail, "ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(ErrorDetail, "ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(ErrorDetail, "ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * The resource management error additional info. + */ +@@armCommonDefinition(ErrorAdditionalInfo, + "ErrorAdditionalInfo", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(ErrorAdditionalInfo, + "ErrorAdditionalInfo", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(ErrorAdditionalInfo, + "ErrorAdditionalInfo", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * Identity + */ +@@armCommonDefinition(Identity, "Identity", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(Identity, "Identity", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(Identity, "Identity", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * Metadata pertaining to creation and last modification of the resource. + */ +@@armCommonDefinition(SystemData, "systemData", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(SystemData, "systemData", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(SystemData, "systemData", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * Details of the resource plan. + */ +@@armCommonDefinition(Plan, "Plan", Azure.ResourceManager.CommonTypes.Versions.v3); +@@armCommonDefinition(Plan, "Plan", Azure.ResourceManager.CommonTypes.Versions.v4); +@@armCommonDefinition(Plan, "Plan", Azure.ResourceManager.CommonTypes.Versions.v5); + +/** + * encryptionProperties + */ +@@armCommonDefinition(EncryptionProperties, + "encryptionProperties", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(EncryptionProperties, + "encryptionProperties", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(EncryptionProperties, + "encryptionProperties", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * KeyVaultProperties + */ +@@armCommonDefinition(KeyVaultProperties, + "KeyVaultProperties", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(KeyVaultProperties, + "KeyVaultProperties", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(KeyVaultProperties, + "KeyVaultProperties", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * ResourceModelWithAllowedPropertySet + */ +@@armCommonDefinition(ResourceModelWithAllowedPropertySet, + "ResourceModelWithAllowedPropertySet", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(ResourceModelWithAllowedPropertySet, + "ResourceModelWithAllowedPropertySet", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(ResourceModelWithAllowedPropertySet, + "ResourceModelWithAllowedPropertySet", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The check availability request body. + */ +@@armCommonDefinition(CheckNameAvailabilityRequest, + "CheckNameAvailabilityRequest", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(CheckNameAvailabilityRequest, + "CheckNameAvailabilityRequest", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(CheckNameAvailabilityRequest, + "CheckNameAvailabilityRequest", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The check availability result. + */ +@@armCommonDefinition(CheckNameAvailabilityResponse, + "CheckNameAvailabilityResponse", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(CheckNameAvailabilityResponse, + "CheckNameAvailabilityResponse", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(CheckNameAvailabilityResponse, + "CheckNameAvailabilityResponse", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +@@armCommonDefinition(ErrorResponse, + "ErrorResponse", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonDefinition(ErrorResponse, + "ErrorResponse", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonDefinition(ErrorResponse, + "ErrorResponse", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +// -- Parameters +/** ApiVersionParameter */ +@@armCommonParameter(ApiVersionParameter.apiVersion, + "ApiVersionParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(ApiVersionParameter.apiVersion, + "ApiVersionParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(ApiVersionParameter.apiVersion, + "ApiVersionParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +@@resourceParameterBaseFor(ApiVersionParameter.apiVersion, + [ + ResourceHome.ResourceGroup, + ResourceHome.Subscription, + ResourceHome.Location, + ResourceHome.Tenant, + ResourceHome.Extension + ] +); + +/** SubscriptionIdParameter */ +@@armCommonParameter(SubscriptionIdParameter.subscriptionId, + "SubscriptionIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(SubscriptionIdParameter.subscriptionId, + "SubscriptionIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(SubscriptionIdParameter.subscriptionId, + "SubscriptionIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); +@@resourceParameterBaseFor(SubscriptionIdParameter.subscriptionId, + [ResourceHome.ResourceGroup, ResourceHome.Subscription, ResourceHome.Location] +); + +/** ResourceGroupNameParameter */ +@@armCommonParameter(ResourceGroupNameParameter.resourceGroupName, + "ResourceGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(ResourceGroupNameParameter.resourceGroupName, + "ResourceGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(ResourceGroupNameParameter.resourceGroupName, + "ResourceGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); +@@resourceParameterBaseFor(ResourceGroupNameParameter.resourceGroupName, + [ResourceHome.ResourceGroup] +); + +/** ManagementGroupNameParameter */ +@@armCommonParameter(ManagementGroupNameParameter.managementGroupName, + "ManagementGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(ManagementGroupNameParameter.managementGroupName, + "ManagementGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(ManagementGroupNameParameter.managementGroupName, + "ManagementGroupNameParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** ScopeParameter */ +@@armCommonParameter(ScopeParameter.scope, + "ScopeParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(ScopeParameter.scope, + "ScopeParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(ScopeParameter.scope, + "ScopeParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** LocationResourceParameter */ +@@armCommonParameter(LocationResourceParameter.location, + "LocationParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(LocationResourceParameter.location, + "LocationParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(LocationResourceParameter.location, + "LocationParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * The default operationId parameter type. + */ +@@armCommonParameter(OperationIdParameter.operationId, + "OperationIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(OperationIdParameter.operationId, + "OperationIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(OperationIdParameter.operationId, + "OperationIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); + +/** + * TenantIdParameter + */ +@@armCommonParameter(TenantIdParameter.tenantId, + "TenantIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v3 +); +@@armCommonParameter(TenantIdParameter.tenantId, + "TenantIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v4 +); +@@armCommonParameter(TenantIdParameter.tenantId, + "TenantIdParameter", + Azure.ResourceManager.CommonTypes.Versions.v5 +); diff --git a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp index cc1815421c..b2d5c8b19a 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/types.tsp +++ b/packages/typespec-azure-resource-manager/lib/common-types/types.tsp @@ -1,259 +1,220 @@ using TypeSpec.Http; +using TypeSpec.Rest; using TypeSpec.OpenAPI; +using TypeSpec.Versioning; using Azure.Core; -using Azure.ResourceManager.Private; -namespace Azure.ResourceManager.Foundations; +namespace Azure.ResourceManager.CommonTypes; -/** - * Base model that defines common properties for all Azure Resource Manager resources. - */ -@doc("Common properties for all Azure Resource Manager resources.") +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +@extension("x-ms-azure-resource", true) model Resource { - @doc("Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}") + /** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */ + @typeChangedFrom(Versions.v4, string) @visibility("read") - id?: string; + id?: armResourceIdentifier; - @doc("The name of the resource") + /** The name of the resource */ @visibility("read") name?: string; - @doc("The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"") + /** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */ @visibility("read") type?: string; - @doc("Azure Resource Manager metadata containing createdBy and modifiedBy information.") + /** Azure Resource Manager metadata containing createdBy and modifiedBy information. */ @visibility("read") systemData?: SystemData; } /** The resource model definition for an Azure Resource Manager resource with an etag. */ -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v5) model AzureEntityResource extends Resource { /** Resource Etag. */ @visibility("read") - etag: string; + etag?: string; } /** - * Standard type definition for Azure Resource Manager Tags property. - * - * It is included in the TrackedResource template definition. + * The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -@doc("The Azure Resource Manager Resource tags.") -model ArmTagsProperty { - @doc("Resource tags.") +model TrackedResource extends Resource { + /** Resource tags. */ tags?: Record; -} -/** - * The base tracked resource. - */ -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("TrackedResource", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'") -model TrackedResource extends Resource { - @doc("The geo-location where the resource lives") + /** The geo-location where the resource lives */ @visibility("read", "create") location: string; - - ...ArmTagsProperty; } /** - * The base proxy resource. + * The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ -@doc("The base proxy resource.") -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v5) model ProxyResource extends Resource {} /** * The base extension resource. */ // Note that ProxyResource is the base definition for both kinds of resources -@doc("The base extension resource.") -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("ProxyResource", Azure.ResourceManager.CommonTypes.Versions.v5) model ExtensionResource extends Resource {} /** - * The SKU (Stock Keeping Unit) assigned to this resource. + * The resource model definition containing the full set of allowed properties for a resource. Except properties bag, there cannot be a top level property outside of this set. + */ +@extension("x-ms-azure-resource", true) +model ResourceModelWithAllowedPropertySet extends TrackedResource { + /** The fully qualified resource ID of the resource that manages this resource. Indicates if this resource is managed by another Azure resource. + * If this is present, complete mode deployment will not delete the resource if it is removed from the template since it is managed by another resource. */ + managedBy?: string; + + /** Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. + * If supported, the resource provider must validate and persist this value. */ + @pattern("^[-\\w\\._,\\(\\)]+$") + @visibility("read", "create") + kind?: string; + + /** The etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal etag convention. + * Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), + * If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. */ + eTag?: string; + + identity?: Identity; + sku?: Sku; + plan?: Plan; +} + +/** + * The resource model definition representing SKU */ -@doc("The SKU (Stock Keeping Unit) assigned to this resource.") -@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("Sku", Azure.ResourceManager.CommonTypes.Versions.v5) model Sku { - @doc("The name of the SKU, usually a combination of letters and numbers, for example, 'P3'") + /** The name of the SKU. Ex - P3. It is typically a letter+number code */ name: string; - @doc("This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.") + /** This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. */ tier?: SkuTier; - @doc("The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code.") + /** The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. */ size?: string; - @doc("If the service has different generations of hardware, for the same SKU, then that can be captured here.") + /** If the service has different generations of hardware, for the same SKU, then that can be captured here. */ family?: string; - @doc("If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted.") + /** If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted. */ capacity?: int32; } /** - * Available service tiers for the SKU. + * This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT. */ -@doc("Available service tiers for the SKU.") -enum SkuTier { - @doc("The Free service tier.") - Free, +union SkuTier { + /** The Free service tier. */ + Free: "Free", - @doc("The Basic service tier.") - Basic, + /** The Basic service tier. */ + Basic: "Basic", - @doc("The Standard service tier.") - Standard, + /** The Standard service tier. */ + Standard: "Standard", - @doc("The Premium service tier.") - Premium, + /** The Premium service tier. */ + Premium: "Premium", } /** * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */ -@armCommonDefinition("OperationListResult", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("OperationListResult", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("OperationListResult", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc(""" - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - """) +@friendlyName("OperationListResult") model OperationListResult is Azure.Core.Page; /** * Details of a REST API operation, returned from the Resource Provider Operations API */ -@armCommonDefinition("Operation", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("Operation", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("Operation", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("Details of a REST API operation, returned from the Resource Provider Operations API") model Operation { - @doc(""" + /** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" - """) + */ @visibility("read") name?: string; - @doc(""" + /** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. - """) + */ @visibility("read") isDataAction?: boolean; - @doc("Localized display information for this particular operation.") + /** Localized display information for this particular operation. */ display?: OperationDisplay; - @doc(""" + /** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" - """) + */ @visibility("read") origin?: Origin; - @doc(""" + /** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """) + */ actionType?: ActionType; } /** * Localized display information for and operation. */ -@armCommonDefinition("OperationDisplay", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("OperationDisplay", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("OperationDisplay", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("Localized display information for and operation.") model OperationDisplay { - @doc(""" - The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". - """) + /** + The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + */ provider?: string; - @doc(""" + /** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". - """) + */ resource?: string; - @doc(""" + /** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - """) + */ operation?: string; - @doc("The short, localized friendly description of the operation; suitable for tool tips and detailed views.") + /** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */ description?: string; } /** * The current status of an async operation. */ -@armCommonDefinition("OperationStatusResult", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("OperationStatusResult", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("OperationStatusResult", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The current status of an async operation.") model OperationStatusResult { - @doc("Fully qualified ID for the async operation.") + /** Fully qualified ID for the async operation. */ id?: string; - @doc("Name of the async operation.") + /** Name of the async operation. */ name?: string; - @doc("Operation status.") + /** Operation status. */ status: string; - @doc("Percent of the operation that is complete.") + /** Percent of the operation that is complete. */ @minValue(0) @maxValue(100) percentComplete?: float64; - @doc("The start time of the operation.") + /** The start time of the operation. */ startTime?: utcDateTime; - @doc("The end time of the operation.") + /** The end time of the operation. */ endTime?: utcDateTime; - @doc("The operations list.") - operations: OperationStatusResult[]; + /** The operations list. */ + operations?: OperationStatusResult[]; - @doc("If present, details of the operation error.") + /** If present, details of the operation error. */ error?: ErrorDetail; } -/** - * The default operationId parameter type. - */ -@doc("The default operationId parameter type.") -model OperationIdParameter { - @path - @minLength(1) - @doc("The ID of an ongoing async operation.") - @armCommonParameter("OperationIdParameter", Azure.ResourceManager.CommonTypes.Versions.v3) - @armCommonParameter("OperationIdParameter", Azure.ResourceManager.CommonTypes.Versions.v4) - @armCommonParameter("OperationIdParameter", Azure.ResourceManager.CommonTypes.Versions.v5) - operationId: string; -} - /** * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */ -@doc(""" - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """) union ActionType { - @doc("Actions are for internal-only APIs.") + /** Actions are for internal-only APIs. */ Internal: "Internal", string, @@ -262,17 +223,14 @@ union ActionType { /** * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */ -@doc(""" - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" - """) union Origin { - @doc("Indicates the operation is initiated by a user.") + /** Indicates the operation is initiated by a user. */ user: "user", - @doc("Indicates the operation is initiated by a system.") + /** Indicates the operation is initiated by a system. */ system: "system", - @doc("Indicates the operation is initiated by a user or system.") + /** Indicates the operation is initiated by a user or system. */ `user,system`: "user,system", string, @@ -281,47 +239,47 @@ union Origin { /** * The error detail. */ -@armCommonDefinition("ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("ErrorDetail", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The error detail.") model ErrorDetail { - @doc("The error code.") + /** The error code. */ @visibility("read") code?: string; - @doc("The error message.") + /** The error message. */ @visibility("read") message?: string; - @doc("The error target.") + /** The error target. */ @visibility("read") target?: string; + /** The error details. */ @extension("x-ms-identifiers", ["message", "target"]) - @doc("The error details.") @visibility("read") details?: ErrorDetail[]; - @extension("x-ms-identifiers", ["message", "target"]) - @doc("The error additional info.") + /** The error additional info. */ @visibility("read") additionalInfo?: ErrorAdditionalInfo[]; } +/** + * Common error response for all Azure Resource Manager APIs to return error details for failed operations. + */ +@error +model ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + /** * The resource management error additional info. */ -@armCommonDefinition("ErrorAdditionalInfo", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("ErrorAdditionalInfo", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("ErrorAdditionalInfo", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The resource management error additional info.") model ErrorAdditionalInfo { - @doc("The additional info type.") + /** The additional info type. */ @visibility("read") type?: string; - @doc("The additional info.") + /** The additional info. */ @visibility("read") info?: {}; } @@ -329,124 +287,288 @@ model ErrorAdditionalInfo { /** * Metadata pertaining to creation and last modification of the resource. */ -@armCommonDefinition("systemData", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("systemData", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("systemData", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("Metadata pertaining to creation and last modification of the resource.") model SystemData { - @visibility("read") - @doc("The identity that created the resource.") + /** The identity that created the resource. */ createdBy?: string; - @visibility("read") - @doc("The type of identity that created the resource.") + /** The type of identity that created the resource. */ createdByType?: createdByType; - @visibility("read") - @doc("The type of identity that created the resource.") - createdAt?: plainDate; + /** The timestamp of resource creation (UTC). */ + createdAt?: utcDateTime; - @visibility("read") - @doc("The identity that last modified the resource.") + /** The identity that last modified the resource. */ lastModifiedBy?: string; - @visibility("read") - @doc("The type of identity that last modified the resource.") + /** The type of identity that last modified the resource. */ lastModifiedByType?: createdByType; - @visibility("read") - @doc("The timestamp of resource last modification (UTC)") - lastModifiedAt?: plainDate; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: utcDateTime; } /** * The kind of entity that created the resource. */ // NOTE: This is how the extensible enum is named in types.json -@doc("The kind of entity that created the resource.") union createdByType { - @doc("The entity was created by a user.") + /** The entity was created by a user. */ User: "User", - @doc("The entity was created by an application.") + /** The entity was created by an application. */ Application: "Application", - @doc("The entity was created by a managed identity.") + /** The entity was created by a managed identity. */ ManagedIdentity: "ManagedIdentity", - @doc("The entity was created by a key.") + /** The entity was created by a key. */ Key: "Key", string, } +union ResourceIdentityType { + SystemAssigned: "SystemAssigned", +} + +/** Identity for the resource. */ +model Identity { + /** The principal ID of resource identity. The value must be an UUID. */ + @typeChangedFrom(Versions.v4, string) + @visibility("read") + principalId?: uuid; + + /** The tenant ID of resource. The value must be an UUID. */ + @typeChangedFrom(Versions.v4, string) + @visibility("read") + tenantId?: uuid; + + /** The identity type. */ + type?: ResourceIdentityType; +} + +model KeyVaultProperties { + /** Key vault uri to access the encryption key. */ + keyIdentifier?: string; + + /** The client ID of the identity which will be used to access key vault. */ + identity?: string; +} /** - * Details of the resource plan. + * Plan for the resource. */ -@doc("Details of the resource plan.") -@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("Plan", Azure.ResourceManager.CommonTypes.Versions.v5) model Plan { - @doc("A user defined name of the 3rd Party Artifact that is being procured.") + /** A user defined name of the 3rd Party Artifact that is being procured. */ name: string; - @doc("The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic") + /** The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic */ publisher: string; - @doc("The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. ") + /** The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding. */ product: string; - @doc("A publisher provided promotion code as provisioned in Data Market for the said product/artifact.") + /** A publisher provided promotion code as provisioned in Data Market for the said product/artifact. */ promotionCode?: string; - @doc("The version of the desired product/artifact.") + /** The version of the desired product/artifact. */ version?: string; } /** * The check availability request body. */ -@armCommonDefinition("CheckNameAvailabilityRequest", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("CheckNameAvailabilityRequest", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("CheckNameAvailabilityRequest", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The check availability request body.") model CheckNameAvailabilityRequest { - @doc("The name of the resource for which availability needs to be checked.") + /** The name of the resource for which availability needs to be checked. */ name?: string; - @doc("The resource type.") + /** The resource type. */ type?: string; } /** * The check availability result. */ -@armCommonDefinition("CheckNameAvailabilityResponse", Azure.ResourceManager.CommonTypes.Versions.v3) -@armCommonDefinition("CheckNameAvailabilityResponse", Azure.ResourceManager.CommonTypes.Versions.v4) -@armCommonDefinition("CheckNameAvailabilityResponse", Azure.ResourceManager.CommonTypes.Versions.v5) -@doc("The check availability result.") model CheckNameAvailabilityResponse { - @doc("Indicates if the resource name is available.") + /** Indicates if the resource name is available. */ nameAvailable?: boolean; - @doc("The reason why the given name is not available.") + /** The reason why the given name is not available. */ reason?: CheckNameAvailabilityReason; - @doc("Detailed reason why the given name is not available.") + /** Detailed reason why the given name is not available. */ message?: string; } /** * Possible reasons for a name not being available. */ -@doc("Possible reasons for a name not being available.") union CheckNameAvailabilityReason { - @doc("Name is invalid.") + /** Name is invalid. */ Invalid: "Invalid", - @doc("Name already exists.") + /** Name already exists. */ AlreadyExists: "AlreadyExists", string, } + +/** Indicates whether or not the encryption is enabled for container registry. */ +union EncryptionStatus { + /** Encryption is enabled. */ + enabled: "enabled", + + /** Encryption is disabled. */ + disabled: "disabled", + + string, +} +/** + * Configuration of key for data encryption + */ +model EncryptionProperties { + /** Indicates whether or not the encryption is enabled for container registry. */ + status?: EncryptionStatus; + + /** Key vault properties. */ + keyVaultProperties?: KeyVaultProperties; +} + +/** + * Metadata pertaining to the geographic location of the resource. + */ +model LocationData { + /** A canonical name for the geographic or physical location. */ + @maxLength(256) + name: string; + + /** The city or locality where the resource is located. */ + city?: string; + + /** The district, state, or province where the resource is located. */ + district?: string; + + /** The country or region where the resource is located */ + countryOrRegion?: string; +} + +/** + * The default api-version parameter type. + */ +model ApiVersionParameter { + /** The API version to use for this operation. */ + @query("api-version") + @minLength(1) + apiVersion: string; +} + +/** + * The default operationId parameter type. + */ +model OperationIdParameter { + /** The ID of an ongoing async operation. */ + @path + @minLength(1) + operationId: string; +} + +/** + * The default location parameter type. + */ +model LocationParameter { + /** The name of Azure region. */ + @path + @minLength(1) + @segment("locations") + location: string; +} + +/** + * The default resource group parameter type. + */ +model ResourceGroupNameParameter { + /** The name of the resource group. The name is case insensitive. */ + @path + @minLength(1) + @maxLength(90) + @segment("resourceGroups") + @pattern("^[-\\w\\._\\(\\)]+$") + resourceGroupName: string; +} + +/** + * The default subscriptionId parameter type. + */ +model SubscriptionIdParameter { + /** The ID of the target subscription. The value must be an UUID. */ + @typeChangedFrom(Versions.v4, string) + @path + @segment("subscriptions") + subscriptionId: uuid; +} + +/** The default location parameter type. */ +model LocationResourceParameter { + /** The name of the Azure region. */ + @path + @minLength(1) + @segment("locations") + @key + location: string; +} + +/** + * The default ManagementGroupName parameter type. + */ +@added(Versions.v4) +model ManagementGroupNameParameter { + /** The name of the management group. The name is case insensitive. */ + @path + @minLength(1) + @maxLength(90) + @segment("managementGroups") + managementGroupName: string; +} + +/** + * The default Scope parameter type. + */ +@added(Versions.v4) +model ScopeParameter { + /** The scope at which the operation is performed. */ + @path + @segment("scope") + @minLength(1) + @extension("x-ms-skip-url-encoding", true) + scope: string; +} + +/** + * The default ManagementGroupName parameter type. + */ +@added(Versions.v4) +model TenantIdParameter { + /** The Azure tenant ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) */ + @path + @segment("tenant") + tenantId: uuid; +} + +/** + * The default ARM If-Match header type. + */ +@added(Versions.v4) +model IfMatchHeader { + /** The If-Match header that makes a request conditional. */ + @header("If-Match") + ifMatch: string; +} + +/** + * The default ARM If-Match header type. + */ +@added(Versions.v4) +model IfNoneMatchHeader { + /** The If-None-Match header that makes a request conditional. */ + @header("If-None-Match") + ifNoneMatch: string; +} diff --git a/packages/typespec-azure-resource-manager/lib/decorators.tsp b/packages/typespec-azure-resource-manager/lib/decorators.tsp index 027cd9c75d..6923f09652 100644 --- a/packages/typespec-azure-resource-manager/lib/decorators.tsp +++ b/packages/typespec-azure-resource-manager/lib/decorators.tsp @@ -180,7 +180,7 @@ extern dec armResourceOperations(target: Interface, _?: unknown); * This decorator is used either on a namespace or a version enum value to indicate * the version of the Azure Resource Manager common-types to use for refs in emitted Swagger files. * - * @param version The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value. + * @param version The Azure.ResourceManager.CommonTypes.Versions for the desired common-types version or an equivalent string value like "v5". */ extern dec armCommonTypesVersion( target: Namespace | EnumMember, diff --git a/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp b/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp similarity index 93% rename from packages/typespec-azure-resource-manager/lib/arm.foundations.tsp rename to packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp index 47fdbf802f..644bc0437f 100644 --- a/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp +++ b/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp @@ -1,30 +1,21 @@ +import "@typespec/openapi"; +import "@typespec/http"; +import "@typespec/rest"; + +import "./backcompat.tsp"; +import "./deprecation.tsp"; +import "../common-types/common-types.tsp"; +import "../decorators.tsp"; +import "../responses.tsp"; +import "../private.decorators.tsp"; +import "../parameters.tsp"; + using TypeSpec.Http; using TypeSpec.OpenAPI; -using TypeSpec.Versioning; using Azure.ResourceManager.Private; namespace Azure.ResourceManager.Foundations; -/** - * An internal enum to indicate the resource support for various path types - */ -enum ResourceHome { - @doc("The resource is bound to a tenant") - Tenant, - - @doc("The resource is bound to a subscription") - Subscription, - - @doc("The resource is bound to a location") - Location, - - @doc("The resource is bound to a resource group") - ResourceGroup, - - @doc("The resource is bound to an extension") - Extension, -} - /** * Base parameters for a resource. * @@ -53,6 +44,17 @@ model DefaultBaseParameters { ...ResourceUriParameter; } +/** + * Standard type definition for Azure Resource Manager Tags property. + * + * It is included in the TrackedResource template definition. + */ +/** The Azure Resource Manager Resource tags. */ +model ArmTagsProperty { + /** Resource tags. */ + tags?: Record; +} + /** * The static parameters for a tenant-based resource */ diff --git a/packages/typespec-azure-resource-manager/lib/foundations/backcompat.tsp b/packages/typespec-azure-resource-manager/lib/foundations/backcompat.tsp new file mode 100644 index 0000000000..e8b0595352 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/foundations/backcompat.tsp @@ -0,0 +1,39 @@ +namespace Azure.ResourceManager.Foundations { + // extended-location + alias ExtendedLocation = CommonTypes.ExtendedLocation; + alias ExtendedLocationType = CommonTypes.ExtendedLocationType; + + // managed-identities + alias ManagedServiceIdentity = CommonTypes.ManagedServiceIdentity; + #suppress "deprecated" "Need for back compatibility in common-types" + alias UserAssignedIdentities = CommonTypes.UserAssignedIdentities; + alias SystemAssignedServiceIdentity = CommonTypes.SystemAssignedServiceIdentity; + alias UserAssignedIdentity = CommonTypes.UserAssignedIdentity; + alias ManagedServiceIdentityType = CommonTypes.ManagedServiceIdentityType; + alias SystemAssignedServiceIdentityType = CommonTypes.SystemAssignedServiceIdentityType; + alias ManagedSystemIdentityType = SystemAssignedServiceIdentityType; + + // types + alias Resource = CommonTypes.Resource; + alias AzureEntityResource = CommonTypes.AzureEntityResource; + alias TrackedResource = CommonTypes.TrackedResource; + alias ProxyResource = CommonTypes.ProxyResource; + alias ExtensionResource = CommonTypes.ExtensionResource; + alias Sku = CommonTypes.Sku; + alias SkuTier = CommonTypes.SkuTier; + alias OperationListResult = CommonTypes.OperationListResult; + alias Operation = CommonTypes.Operation; + alias OperationDisplay = CommonTypes.OperationDisplay; + alias OperationStatusResult = CommonTypes.OperationStatusResult; + alias OperationIdParameter = CommonTypes.OperationIdParameter; + alias ActionType = CommonTypes.ActionType; + alias Origin = CommonTypes.Origin; + alias ErrorDetail = CommonTypes.ErrorDetail; + alias ErrorAdditionalInfo = CommonTypes.ErrorAdditionalInfo; + alias SystemData = CommonTypes.SystemData; + alias createdByType = CommonTypes.createdByType; + alias Plan = CommonTypes.Plan; + alias CheckNameAvailabilityRequest = CommonTypes.CheckNameAvailabilityRequest; + alias CheckNameAvailabilityResponse = CommonTypes.CheckNameAvailabilityResponse; + alias CheckNameAvailabilityReason = CommonTypes.CheckNameAvailabilityReason; +} diff --git a/packages/typespec-azure-resource-manager/lib/common-types/backcompat.tsp b/packages/typespec-azure-resource-manager/lib/foundations/deprecation.tsp similarity index 59% rename from packages/typespec-azure-resource-manager/lib/common-types/backcompat.tsp rename to packages/typespec-azure-resource-manager/lib/foundations/deprecation.tsp index bca365485f..e9f0d74cec 100644 --- a/packages/typespec-azure-resource-manager/lib/common-types/backcompat.tsp +++ b/packages/typespec-azure-resource-manager/lib/foundations/deprecation.tsp @@ -17,3 +17,14 @@ alias ResourceSkuType = Sku; #deprecated "Please use Foundations.Plan instead of Foundations.ResourcePlanType" alias ResourcePlanType = Plan; + +// managed-identity +#deprecated "Please change ManagedIdentityProperties to ManagedServiceIdentity." +alias ManagedIdentityProperties = ManagedServiceIdentity; + +#deprecated "Please change ManagedSystemIdentityProperties to SystemAssignedServiceIdentity." +alias ManagedSystemIdentityProperties = SystemAssignedServiceIdentity; + +/** Alias of ManagedServiceIdentityType for back compatability. Please change to ManagedServiceIdentityType. */ +#deprecated "Please change to ManagedServiceIdentityType." +alias ManagedIdentityType = ManagedServiceIdentityType; diff --git a/packages/typespec-azure-resource-manager/lib/models.tsp b/packages/typespec-azure-resource-manager/lib/models.tsp index a5bb6d4e5e..e5eb45bf68 100644 --- a/packages/typespec-azure-resource-manager/lib/models.tsp +++ b/packages/typespec-azure-resource-manager/lib/models.tsp @@ -352,4 +352,22 @@ model ManagedByProperty { managedBy?: string; } +/** Please use the spread model EncryptionProperty */ +alias Encryption = EncryptionProperty; +/** + * Model used only to spread in the `encryption` envelope property for a resource. + * @example + * + * ```typespec + * model Foo is TrackedResource { + * ...Encryption; + * } + * ``` + */ +/** All encryption configuration for a resource. */ +model EncryptionProperty { + /** All encryption configuration for a resource. */ + encryption: EncryptionConfiguration; +} + //#endregion diff --git a/packages/typespec-azure-resource-manager/lib/parameters.tsp b/packages/typespec-azure-resource-manager/lib/parameters.tsp index 79788ad073..43a17c652e 100644 --- a/packages/typespec-azure-resource-manager/lib/parameters.tsp +++ b/packages/typespec-azure-resource-manager/lib/parameters.tsp @@ -3,80 +3,45 @@ using TypeSpec.Rest; using TypeSpec.OpenAPI; using Azure.ResourceManager.Foundations; using Azure.ResourceManager.Private; +using Azure.ResourceManager.CommonTypes; +using Azure.ResourceManager.CommonTypes.Private; namespace Azure.ResourceManager; /** * The default api-version parameter type. */ -@doc("The default api-version parameter type.") -model ApiVersionParameter { - @query("api-version") - @minLength(1) - @doc("The API version to use for this operation.") - @armCommonParameter("ApiVersionParameter", Azure.ResourceManager.CommonTypes.Versions.v3) - @armCommonParameter("ApiVersionParameter", Azure.ResourceManager.CommonTypes.Versions.v4) - @armCommonParameter("ApiVersionParameter", Azure.ResourceManager.CommonTypes.Versions.v5) - @resourceParameterBaseFor( - [ - ResourceHome.ResourceGroup, - ResourceHome.Subscription, - ResourceHome.Location, - ResourceHome.Tenant, - ResourceHome.Extension - ] - ) - apiVersion: string; -} +alias ApiVersionParameter = CommonTypes.ApiVersionParameter; /** * The default subscriptionId parameter type. */ -@doc("The default subscriptionId parameter type.") -model SubscriptionIdParameter { - @path - @minLength(1) - @segment("subscriptions") - @doc("The ID of the target subscription.") - @armCommonParameter("SubscriptionIdParameter", Azure.ResourceManager.CommonTypes.Versions.v3) - @armCommonParameter("SubscriptionIdParameter", Azure.ResourceManager.CommonTypes.Versions.v4) - @armCommonParameter("SubscriptionIdParameter", Azure.ResourceManager.CommonTypes.Versions.v5) - @resourceParameterBaseFor( - [ResourceHome.ResourceGroup, ResourceHome.Subscription, ResourceHome.Location] - ) - subscriptionId: string; -} +alias SubscriptionIdParameter = CommonTypes.SubscriptionIdParameter; /** - * DEPRECATED - DO NOT USE - * The default location parameter type. + * The default ResourceGroup parameter type. */ -@doc("The default location parameter type.") -model LocationParameter { - @path - @minLength(1) - @segment("locations") - @doc("The location name.") - @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v3) - @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v4) - @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v5) - @resourceParameterBaseFor([ResourceHome.Location]) - location: string; -} +alias ResourceGroupParameter = CommonTypes.ResourceGroupNameParameter; + +/** + * The default LocationResource parameter type. + */ +alias LocationResourceParameter = CommonTypes.LocationResourceParameter; /** + * DEPRECATED - DO NOT USE * The default location parameter type. */ @doc("The default location parameter type.") -model LocationResourceParameter { +model LocationParameter { @path @minLength(1) @segment("locations") @doc("The location name.") - @key @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v3) @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v4) @armCommonParameter("LocationParameter", Azure.ResourceManager.CommonTypes.Versions.v5) + @resourceParameterBaseFor([ResourceHome.Location]) location: string; } @@ -113,24 +78,6 @@ model ArmLocationResource = program.stateMap(ArmStateKeys.armCommonTypesVersions); return map?.values().next().value as any; } +export function getArmCommonTypesVersionFromString( + program: Program, + entity: Namespace | EnumMember, + versionStr: string +): [EnumMember | undefined, readonly Diagnostic[]] { + const commonTypeVersionEnum = program.resolveTypeReference( + `Azure.ResourceManager.CommonTypes.Versions.${versionStr}` + )[0] as EnumMember; + if (commonTypeVersionEnum === undefined) { + return [ + undefined, + [ + createDiagnostic({ + code: "arm-common-types-invalid-version", + target: entity, + format: { + versionString: versionStr, + supportedVersions: [...getArmCommonTypesVersions(program).type.members.keys()].join( + ", " + ), + }, + }), + ], + ]; + } else { + return [commonTypeVersionEnum, []]; + } +} + /** * Check if a given model or model property is an ARM common type. * @param {Type} entity - The entity to be checked. @@ -58,9 +87,34 @@ export function $armCommonTypesVersion( entity: Namespace | EnumMember, version: string | EnumValue ) { - context.program - .stateMap(ArmStateKeys.armCommonTypesVersion) - .set(entity, typeof version === "string" ? version : version.value.name); + // try convert string to EnumMember + let versionEnum: EnumMember; + if (typeof version === "string") { + const [foundEnumMember, diagnostics] = getArmCommonTypesVersionFromString( + context.program, + entity, + version + ); + if (!foundEnumMember) { + context.program.reportDiagnostics(diagnostics); + return; + } + versionEnum = foundEnumMember as EnumMember; + } else { + versionEnum = version.value; + } + + context.program.stateMap(ArmStateKeys.armCommonTypesVersion).set(entity, versionEnum.name); + + if (entity.kind === "Namespace") { + const versioned = entity.decorators.find((x) => x.definition?.name === "@versioned"); + // If it is versioned namespace, we will skip adding @useDependency to namespace + if (versioned) { + return; + } + } + // Add @useDependency on version enum members or on unversioned namespace + context.call($useDependency, entity, versionEnum); } /** diff --git a/packages/typespec-azure-resource-manager/src/commontypes.private.decorators.ts b/packages/typespec-azure-resource-manager/src/commontypes.private.decorators.ts new file mode 100644 index 0000000000..326a380203 --- /dev/null +++ b/packages/typespec-azure-resource-manager/src/commontypes.private.decorators.ts @@ -0,0 +1,135 @@ +import { + DecoratorContext, + Enum, + EnumValue, + Model, + ModelProperty, + Program, +} from "@typespec/compiler"; +import { ArmStateKeys } from "./state.js"; + +export const namespace = "Azure.ResourceManager.CommonTypes.Private"; + +export const ArmCommonTypesDefaultVersion = "v3"; + +function getArmTypesPath(program: Program): string { + return program.getOption("arm-types-path") || "{arm-types-dir}"; +} + +function storeCommonTypeRecord( + context: DecoratorContext, + entity: Model | ModelProperty, + kind: "definitions" | "parameters", + name: string, + version?: string | EnumValue | ArmCommonTypeVersionSpec, + referenceFile?: string +): void { + const basePath: string = getArmTypesPath(context.program).trim(); + + // NOTE: Right now we don't try to prevent multiple versions from declaring that they are the default + let isDefault = false; + if (version && typeof version !== "string" && !("valueKind" in version)) { + isDefault = !!version.isDefault; + version = version.version; + } + + // for backward compatibility, skip if we are trying to access a non-default file and emit the type + if ((version || referenceFile) && basePath.endsWith(".json")) return; + if (!version) version = ArmCommonTypesDefaultVersion; + if (!referenceFile) referenceFile = "types.json"; + + const versionStr = typeof version === "string" ? version : version.value.name; + const records = getCommonTypeRecords(context.program, entity); + + records.records[versionStr] = { + name, + kind, + version: versionStr, + basePath, + referenceFile, + }; + if (isDefault) { + records.defaultKey = versionStr; + } + context.program.stateMap(ArmStateKeys.armCommonDefinitions).set(entity, records); +} + +export interface ArmCommonTypeRecord { + name: string; + kind: "definitions" | "parameters"; + version: string; + basePath: string; + referenceFile?: string; +} + +export interface ArmCommonTypeRecords { + records: { [key: string]: ArmCommonTypeRecord }; + defaultKey?: string; +} + +export function getCommonTypeRecords( + program: Program, + entity: Model | ModelProperty +): ArmCommonTypeRecords { + return program.stateMap(ArmStateKeys.armCommonDefinitions).get(entity) ?? { records: {} }; +} + +interface ArmCommonTypeVersionSpec { + version: string | EnumValue; + isDefault: boolean; +} + +/** + * Refer an model property to be a common ARM parameter + * @param {DecoratorContext} context DecoratorContext object + * @param {Type} entity Decorator target type. Must be `Model` + * @param {string?} definitionName Optional definition name + * @param {string?} version Optional version + * @param {string?} referenceFile Optional common file path + * @returns void + */ +export function $armCommonParameter( + context: DecoratorContext, + entity: ModelProperty, + parameterName?: string, + version?: string | EnumValue | ArmCommonTypeVersionSpec, + referenceFile?: string +): void { + // Use the name of the model type if not specified + if (!parameterName) { + parameterName = entity.name; + } + + storeCommonTypeRecord(context, entity, "parameters", parameterName, version, referenceFile); +} + +/** + * Using ARM common definition for a Model + * @param {DecoratorContext} context DecoratorContext object + * @param {Type} entity Decorator target type. Must be `Model` + * @param {string?} definitionName Optional definition name + * @param {string?} version Optional version + * @param {string?} referenceFile Optional common file path + * @returns {void} + */ +export function $armCommonDefinition( + context: DecoratorContext, + entity: Model, + definitionName?: string, + version?: string | EnumValue | ArmCommonTypeVersionSpec, + referenceFile?: string +): void { + // Use the name of the model type if not specified + if (!definitionName) { + definitionName = entity.name; + } + + storeCommonTypeRecord(context, entity, "definitions", definitionName, version, referenceFile); +} + +export function $armCommonTypesVersions(context: DecoratorContext, enumType: Enum) { + context.program.stateMap(ArmStateKeys.armCommonTypesVersions).set(enumType, { + type: enumType, + allVersions: Array.from(enumType.members.values()).reverse(), + }); +} diff --git a/packages/typespec-azure-resource-manager/src/lib.ts b/packages/typespec-azure-resource-manager/src/lib.ts index 4ba733df3b..11dd6eca9c 100644 --- a/packages/typespec-azure-resource-manager/src/lib.ts +++ b/packages/typespec-azure-resource-manager/src/lib.ts @@ -76,6 +76,12 @@ export const $lib = createTypeSpecLibrary({ default: paramMessage`No ARM common-types version for this type satisfies the expected version ${"selectedVersion"}. This type only supports the following version(s): ${"supportedVersions"}`, }, }, + "arm-common-types-invalid-version": { + severity: "error", + messages: { + default: paramMessage`No ARM common-types version matches the version string ${"versionString"}. The following versions are supported: ${"supportedVersions"}`, + }, + }, "decorator-in-namespace": { severity: "error", messages: { diff --git a/packages/typespec-azure-resource-manager/src/namespace.ts b/packages/typespec-azure-resource-manager/src/namespace.ts index f8a44002d7..4ea6b15449 100644 --- a/packages/typespec-azure-resource-manager/src/namespace.ts +++ b/packages/typespec-azure-resource-manager/src/namespace.ts @@ -1,6 +1,9 @@ import { __unsupported_enable_checkStandardOperations } from "@azure-tools/typespec-azure-core"; import { DecoratorContext, + Enum, + EnumMember, + EnumValue, Model, ModelProperty, Namespace, @@ -12,10 +15,35 @@ import { import * as http from "@typespec/http"; import { getAuthentication, setAuthentication, setRouteOptionsForNamespace } from "@typespec/http"; import { getResourceTypeForKeyParam } from "@typespec/rest"; +import { $armCommonTypesVersion } from "./common-types.js"; import { reportDiagnostic } from "./lib.js"; import { getSingletonResourceKey } from "./resource.js"; import { ArmStateKeys } from "./state.js"; +function getArmCommonTypesVersion( + context: DecoratorContext, + entity: Namespace | EnumMember +): EnumValue | undefined { + return entity.decorators.find((x) => x.definition?.name === "@armCommonTypesVersion")?.args[0] + .jsValue as EnumValue | undefined; +} + +function setArmCommonTypesVersionIfDoesnotExist( + context: DecoratorContext, + entity: Namespace | EnumMember, + commonTypeVersion: string +) { + // Determine whether to set a default ARM CommonTypes.Version + const armCommonTypesVersion = entity.decorators.find( + (x) => x.definition?.name === "@armCommonTypesVersion" + ); + // if no existing @armCommonTypesVersion decorator, add default. + // This will NOT cause error if overrode on version enum. + if (!armCommonTypesVersion) { + context.call($armCommonTypesVersion, entity, commonTypeVersion); + } +} + /** * Mark the target namespace as containign only ARM library types. This is used to create libraries to share among RPs * @param context The doecorator context, automatically supplied by the compiler @@ -29,6 +57,8 @@ export function $armLibraryNamespace(context: DecoratorContext, entity: Namespac __unsupported_enable_checkStandardOperations(false); program.stateMap(ArmStateKeys.armLibraryNamespaces).set(entity, true); + + setArmCommonTypesVersionIfDoesnotExist(context, entity, "v3"); } /** @@ -128,6 +158,27 @@ export function $armProviderNamespace( } } + const armCommonTypesVersion = getArmCommonTypesVersion(context, entity); + + // If it is versioned namespace, we will check each Version enum member. If no + // @armCommonTypeVersion decorator, add the one + const versioned = entity.decorators.find((x) => x.definition?.name === "@versioned"); + if (versioned) { + const versionEnum = versioned.args[0].value as Enum; + versionEnum.members.forEach((v) => { + if (!getArmCommonTypesVersion(context, v)) { + context.call($armCommonTypesVersion, v, armCommonTypesVersion ?? "v3"); + } + }); + } else { + // if it is unversioned namespace, set @armCommonTypesVersion and + // no existing @armCommonTypesVersion decorator, add default. + // This will NOT cause error if overrode on version enum. + if (!armCommonTypesVersion) { + context.call($armCommonTypesVersion, entity, "v3"); + } + } + // 'namespace' is optional, use the actual namespace string if omitted const typespecNamespace = getNamespaceFullName(entity); if (!armProviderNamespace) { diff --git a/packages/typespec-azure-resource-manager/src/private.decorators.ts b/packages/typespec-azure-resource-manager/src/private.decorators.ts index 4aa53d8548..39afe7bc27 100644 --- a/packages/typespec-azure-resource-manager/src/private.decorators.ts +++ b/packages/typespec-azure-resource-manager/src/private.decorators.ts @@ -2,8 +2,6 @@ import { $key, $visibility, DecoratorContext, - Enum, - EnumValue, Interface, Model, ModelProperty, @@ -31,8 +29,6 @@ import { ArmStateKeys } from "./state.js"; export const namespace = "Azure.ResourceManager.Private"; -export const ArmCommonTypesDefaultVersion = "v3"; - export function $omitIfEmpty(context: DecoratorContext, entity: Model, propertyName: string) { const modelProp = getProperty(entity, propertyName); @@ -160,121 +156,6 @@ function isResourceParameterBaseForInternal( return false; } -function getArmTypesPath(program: Program): string { - return program.getOption("arm-types-path") || "{arm-types-dir}"; -} - -function storeCommonTypeRecord( - context: DecoratorContext, - entity: Model | ModelProperty, - kind: "definitions" | "parameters", - name: string, - version?: string | EnumValue | ArmCommonTypeVersionSpec, - referenceFile?: string -): void { - const basePath: string = getArmTypesPath(context.program).trim(); - - // NOTE: Right now we don't try to prevent multiple versions from declaring that they are the default - let isDefault = false; - if (version && typeof version !== "string" && !("valueKind" in version)) { - isDefault = !!version.isDefault; - version = version.version; - } - - // for backward compatibility, skip if we are trying to access a non-default file and emit the type - if ((version || referenceFile) && basePath.endsWith(".json")) return; - if (!version) version = ArmCommonTypesDefaultVersion; - if (!referenceFile) referenceFile = "types.json"; - - const versionStr = typeof version === "string" ? version : version.value.name; - const records = getCommonTypeRecords(context.program, entity); - - records.records[versionStr] = { - name, - kind, - version: versionStr, - basePath, - referenceFile, - }; - if (isDefault) { - records.defaultKey = versionStr; - } - context.program.stateMap(ArmStateKeys.armCommonDefinitions).set(entity, records); -} - -export interface ArmCommonTypeRecord { - name: string; - kind: "definitions" | "parameters"; - version: string; - basePath: string; - referenceFile?: string; -} - -export interface ArmCommonTypeRecords { - records: { [key: string]: ArmCommonTypeRecord }; - defaultKey?: string; -} - -export function getCommonTypeRecords( - program: Program, - entity: Model | ModelProperty -): ArmCommonTypeRecords { - return program.stateMap(ArmStateKeys.armCommonDefinitions).get(entity) ?? { records: {} }; -} - -interface ArmCommonTypeVersionSpec { - version: string | EnumValue; - isDefault: boolean; -} - -/** - * Refer an model property to be a common ARM parameter - * @param {DecoratorContext} context DecoratorContext object - * @param {Type} entity Decorator target type. Must be `Model` - * @param {string?} definitionName Optional definition name - * @param {string?} version Optional version - * @param {string?} referenceFile Optional common file path - * @returns void - */ -export function $armCommonParameter( - context: DecoratorContext, - entity: ModelProperty, - parameterName?: string, - version?: string | EnumValue | ArmCommonTypeVersionSpec, - referenceFile?: string -): void { - // Use the name of the model type if not specified - if (!parameterName) { - parameterName = entity.name; - } - - storeCommonTypeRecord(context, entity, "parameters", parameterName, version, referenceFile); -} - -/** - * Using ARM common definition for a Model - * @param {DecoratorContext} context DecoratorContext object - * @param {Type} entity Decorator target type. Must be `Model` - * @param {string?} definitionName Optional definition name - * @param {string?} version Optional version - * @param {string?} referenceFile Optional common file path - * @returns {void} - */ -export function $armCommonDefinition( - context: DecoratorContext, - entity: Model, - definitionName?: string, - version?: string | EnumValue | ArmCommonTypeVersionSpec, - referenceFile?: string -): void { - // Use the name of the model type if not specified - if (!definitionName) { - definitionName = entity.name; - } - - storeCommonTypeRecord(context, entity, "definitions", definitionName, version, referenceFile); -} - /** * This decorator dynamically assigns the serviceNamespace from the containing * namespace to the string literal value of the path parameter to which this @@ -469,10 +350,3 @@ function hasProperty(program: Program, model: Model): boolean { if (model.baseModel) return hasProperty(program, model.baseModel); return false; } - -export function $armCommonTypesVersions(context: DecoratorContext, enumType: Enum) { - context.program.stateMap(ArmStateKeys.armCommonTypesVersions).set(enumType, { - type: enumType, - allVersions: Array.from(enumType.members.values()).reverse(), - }); -} diff --git a/packages/typespec-azure-resource-manager/src/rules/arm-common-types-version.ts b/packages/typespec-azure-resource-manager/src/rules/arm-common-types-version.ts index dc3b262185..0da4458e1c 100644 --- a/packages/typespec-azure-resource-manager/src/rules/arm-common-types-version.ts +++ b/packages/typespec-azure-resource-manager/src/rules/arm-common-types-version.ts @@ -1,7 +1,6 @@ import { Program, SemanticNodeListener, createRule } from "@typespec/compiler"; import { getAllHttpServices } from "@typespec/http"; import { getVersion } from "@typespec/versioning"; -import { getArmCommonTypesVersion } from "../common-types.js"; import { getArmProviderNamespace } from "../namespace.js"; /** @@ -34,9 +33,16 @@ export const armCommonTypesVersionRule = createRule({ versionMap && versionMap .getVersions() - .every((version) => !!getArmCommonTypesVersion(program, version.enumMember)) + .every( + (version) => + !!version.enumMember.decorators.find( + (x) => x.definition?.name === "@armCommonTypesVersion" + ) + ) ) && - !getArmCommonTypesVersion(program, service.namespace) + !service.namespace.decorators.find( + (x) => x.definition?.name === "@armCommonTypesVersion" + ) ) { context.reportDiagnostic({ target: service.namespace, diff --git a/packages/typespec-azure-resource-manager/src/rules/core-operations.ts b/packages/typespec-azure-resource-manager/src/rules/core-operations.ts index 8d5da0574b..7bde58f7f0 100644 --- a/packages/typespec-azure-resource-manager/src/rules/core-operations.ts +++ b/packages/typespec-azure-resource-manager/src/rules/core-operations.ts @@ -90,7 +90,7 @@ function isApiParameter(program: Program, property: ModelProperty): boolean { if (sourceModel === undefined) return false; return ( sourceModel.name === "ApiVersionParameter" && - getNamespaceName(program, sourceModel) === "Azure.ResourceManager" + getNamespaceName(program, sourceModel) === "Azure.ResourceManager.CommonTypes" ); } diff --git a/packages/typespec-azure-resource-manager/test/arm-common-types-registration.test.ts b/packages/typespec-azure-resource-manager/test/arm-common-types-registration.test.ts index f5b3adb969..bb365e7367 100644 --- a/packages/typespec-azure-resource-manager/test/arm-common-types-registration.test.ts +++ b/packages/typespec-azure-resource-manager/test/arm-common-types-registration.test.ts @@ -3,7 +3,7 @@ import { getService } from "@typespec/compiler"; import { expectDiagnosticEmpty, expectDiagnostics } from "@typespec/compiler/testing"; import { describe, expect, it } from "vitest"; import { findArmCommonTypeRecord } from "../src/common-types.js"; -import type { ArmCommonTypeRecord } from "../src/private.decorators.js"; +import type { ArmCommonTypeRecord } from "../src/commontypes.private.decorators.js"; import { createAzureResourceManagerTestRunner } from "./test-host.js"; function boilerplate(version: string | undefined) { @@ -44,9 +44,9 @@ describe("common definition", () => { it.each(["v3", "v4", "v5"])("link to %s", async (version) => { const [ref, diagnostics] = await compute( ` - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v3, "foo.json") - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v3, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `, version ); @@ -63,8 +63,8 @@ describe("common definition", () => { describe("type added in v4", () => { const decorators = ` - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `; it.each(["v3"])("using in %s emits diagnostics", async () => { const [_, diagnostics] = await compute(decorators, "v3"); @@ -89,7 +89,7 @@ describe("common definition", () => { describe("type added in v5", () => { const decorators = ` - @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `; it.each(["v3", "v4"])("using in %s emits diagnostics", async () => { const [_, diagnostics] = await compute(decorators, "v3"); @@ -137,9 +137,9 @@ describe("common parameters", () => { it.each(["v3", "v4", "v5"])("using %s link to version", async (version) => { const [ref, diagnostics] = await compute( ` - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v3, "foo.json") - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v3, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `, version ); @@ -156,8 +156,8 @@ describe("common parameters", () => { describe("type added in v4", () => { const decorators = ` - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v4, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `; it.each(["v3"])("using in %s emits diagnostics", async () => { const [_, diagnostics] = await compute(decorators, "v3"); @@ -182,7 +182,7 @@ describe("common parameters", () => { describe("type added in v5", () => { const decorators = ` - @Azure.ResourceManager.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") + @Azure.ResourceManager.CommonTypes.Private.armCommonParameter("Foo", Azure.ResourceManager.CommonTypes.Versions.v5, "foo.json") `; it.each(["v3", "v4"])("using in %s emits diagnostics", async () => { const [_, diagnostics] = await compute(decorators, "v3"); diff --git a/packages/typespec-azure-resource-manager/test/enforce-constraint.test.ts b/packages/typespec-azure-resource-manager/test/enforce-constraint.test.ts index b89efdebab..a7267c1af1 100644 --- a/packages/typespec-azure-resource-manager/test/enforce-constraint.test.ts +++ b/packages/typespec-azure-resource-manager/test/enforce-constraint.test.ts @@ -73,20 +73,18 @@ describe("typespec-azure-resource-manager: @enforceConstraint", () => { `); expectDiagnostics(diagnostics, [ { - code: "@azure-tools/typespec-azure-resource-manager/template-type-constraint-no-met", - message: `The template parameter "Widget" for "ArmResourceCreateOrReplaceSync" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.`, - }, - { - code: "@azure-tools/typespec-azure-resource-manager/template-type-constraint-no-met", - message: `The template parameter "Widget" for "create" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.`, + code: "invalid-argument", + message: `Argument of type 'Microsoft.Contoso.Widget' is not assignable to parameter of type 'Azure.ResourceManager.CommonTypes.Resource'`, }, { code: "@azure-tools/typespec-azure-resource-manager/template-type-constraint-no-met", - message: `The template parameter "CustomResource" for "ArmResourceCreateOrReplaceSync" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.`, + message: + 'The template parameter "CustomResource" for "ArmResourceCreateOrReplaceSync" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.', }, { code: "@azure-tools/typespec-azure-resource-manager/template-type-constraint-no-met", - message: `The template parameter "CustomResource" for "delete" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.`, + message: + 'The template parameter "CustomResource" for "delete" does not extend the constraint type "Resource". Please use the "TrackedResource", "ProxyResource", or "ExtensionResource" template to define the resource.', }, ]); }); diff --git a/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts b/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts index 93bdd46d2f..b6e31b5842 100644 --- a/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/arm-resource-interface.test.ts @@ -32,9 +32,11 @@ describe("typespec-azure-resource-manager: detect non-post actions", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } diff --git a/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts b/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts index c76fa3904a..6242e29c55 100644 --- a/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts @@ -83,9 +83,11 @@ describe("typespec-azure-resource-manager: core operations rule", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } @@ -147,9 +149,13 @@ describe("typespec-azure-resource-manager: core operations rule", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @useDependency(Azure.Core.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @useDependency(Azure.Core.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } diff --git a/packages/typespec-azure-resource-manager/test/rules/operation-usage.test.ts b/packages/typespec-azure-resource-manager/test/rules/operation-usage.test.ts index b15b677562..94e2b592ec 100644 --- a/packages/typespec-azure-resource-manager/test/rules/operation-usage.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/operation-usage.test.ts @@ -36,9 +36,11 @@ describe("typespec-azure-resource-manager: detect non-post actions", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } diff --git a/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts b/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts index 72bf418487..c8fbf35197 100644 --- a/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts @@ -33,9 +33,11 @@ describe("typespec-azure-resource-manager: core operations rule", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } @@ -106,9 +108,11 @@ describe("typespec-azure-resource-manager: core operations rule", () => { enum Versions { @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) v2021_09_21: "2022-09-21-preview", @doc(".") @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) v2022_01_10: "2022-01-10-alpha.1" } diff --git a/packages/typespec-azure-resource-manager/test/rules/retry-after.test.ts b/packages/typespec-azure-resource-manager/test/rules/retry-after.test.ts index 0220cfe8b9..36fb856064 100644 --- a/packages/typespec-azure-resource-manager/test/rules/retry-after.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/retry-after.test.ts @@ -24,27 +24,38 @@ describe("typespec-azure-resource-manager: retry-after rule", () => { await tester .expect( ` - @useDependency(Azure.Core.Versions.v1_0_Preview_2) - @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @service @armProviderNamespace + @versioned(Versions) namespace Microsoft.Foo; - + + /** Contoso API versions */ + enum Versions { + /** 2021-10-01-preview version */ + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4) + "2021-10-01-preview", + } + model FooResource is TrackedResource<{}> { - @key("foo") @segment("foo") @path + @key("foo") + @segment("foo") + @path name: string; } - + model UpdateFooResponse { @header("Retry-After") retryAfter: utcDateTime; ...FooResource; } - + @armResourceOperations interface FooResources { @armResourceUpdate(FooResource) @OpenAPI.extension("x-ms-long-running-operation", true) - @patch - op update(): UpdateFooResponse; + @patch + update(): UpdateFooResponse; } ` ) From d30db5bd8bf78c5eb237ea8cdbc0e98755a86be1 Mon Sep 17 00:00:00 2001 From: Mark Cowlishaw Date: Tue, 11 Jun 2024 23:06:35 -0700 Subject: [PATCH 07/10] Make Resource Properties Bag Updatable (#979) --- .chronus/changes/res-vis-2024-5-12-4-34-46.md | 8 +++++ .../typespec-autorest/openapi.json | 36 ++++--------------- .../typespec-autorest/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 6 +--- .../2023-03-01-preview/openapi.json | 6 +--- .../2023-03-01-preview/openapi.json | 6 +--- .../2023-03-01-preview/openapi.json | 6 +--- .../2023-08-01-preview/openapi.json | 18 ++-------- .../2023-11-01-preview/openapi.json | 18 ++-------- .../2021-10-01-preview/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 12 ++----- .../2021-10-01-preview/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 6 +--- .../2021-10-01-preview/openapi.json | 6 +--- .../lib/foundations/arm.foundations.tsp | 6 +++- .../lib/models.tsp | 3 -- 18 files changed, 38 insertions(+), 129 deletions(-) create mode 100644 .chronus/changes/res-vis-2024-5-12-4-34-46.md diff --git a/.chronus/changes/res-vis-2024-5-12-4-34-46.md b/.chronus/changes/res-vis-2024-5-12-4-34-46.md new file mode 100644 index 0000000000..a5b220fe19 --- /dev/null +++ b/.chronus/changes/res-vis-2024-5-12-4-34-46.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Make Resource Properties Bag Updatable diff --git a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json index c51ac0ef33..bc2f3ddd5f 100644 --- a/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/arm-library/@azure-tools/typespec-autorest/openapi.json @@ -1660,11 +1660,7 @@ "properties": { "$ref": "#/definitions/AllPropertiesProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true }, "eTag": { "type": "string", @@ -1822,11 +1818,7 @@ "properties": { "$ref": "#/definitions/Microsoft.InterfacesTest.TestExtensionProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -1858,11 +1850,7 @@ "properties": { "$ref": "#/definitions/Microsoft.InterfacesTest.TestTenantProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -1878,11 +1866,7 @@ "properties": { "$ref": "#/definitions/Microsoft.InterfacesTest.TrackedChildProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -1918,11 +1902,7 @@ "properties": { "$ref": "#/definitions/Microsoft.InterfacesTest.TestTrackedProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -1972,11 +1952,7 @@ "properties": { "$ref": "#/definitions/Microsoft.OperationsTest.TestTrackedProperties2", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json index 26f450a967..31b260c10d 100644 --- a/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/contoso/@azure-tools/typespec-autorest/openapi.json @@ -377,11 +377,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 8f2c907e51..daecccb955 100644 --- a/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/operations/nobody-action/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -588,11 +588,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json index 55c9e6e16d..22d4543ac4 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/common-properties/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -447,11 +447,7 @@ "properties": { "$ref": "#/definitions/WidgetResourceProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true }, "extendedLocation": { "$ref": "#/definitions/Azure.ResourceManager.CommonTypes.ExtendedLocation", diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json index 49b6327cae..c31a6041a9 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/encryption/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -405,11 +405,7 @@ "properties": { "$ref": "#/definitions/WidgetResourceProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json index f90ff76fb9..a476b4b43c 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -405,11 +405,7 @@ "properties": { "$ref": "#/definitions/WidgetResourceProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true }, "identity": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/managedidentity.json#/definitions/ManagedServiceIdentity", diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json index 260e62648b..410346aa0f 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-08-01-preview/openapi.json @@ -649,11 +649,7 @@ "properties": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v4/privatelinks.json#/definitions/PrivateEndpointConnectionProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -690,11 +686,7 @@ "properties": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v4/privatelinks.json#/definitions/PrivateLinkResourceProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -759,11 +751,7 @@ "properties": { "$ref": "#/definitions/TestTrackedProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json index dd52faa934..4645f79a80 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-common-properties/private-links/@azure-tools/typespec-autorest/2023-11-01-preview/openapi.json @@ -649,11 +649,7 @@ "properties": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateEndpointConnectionProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -690,11 +686,7 @@ "properties": { "$ref": "../../../../../../../../../specs/resource-manager/common-types/v5/privatelinks.json#/definitions/PrivateLinkResourceProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -759,11 +751,7 @@ "properties": { "$ref": "#/definitions/TestTrackedProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index b1a17b9ae5..b9c7ea9a6d 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/extension/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -402,11 +402,7 @@ "properties": { "$ref": "#/definitions/RoleAssignmentProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 5b1ee9e4c1..08ccc875f8 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/location/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -437,11 +437,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 3d4924b7bf..05ff8d16da 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/proxy/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -731,11 +731,7 @@ "properties": { "$ref": "#/definitions/DependentProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ @@ -821,11 +817,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 7615e63f83..c432ec176d 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/singleton/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -336,11 +336,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index a882b24dea..0e3dd4ae27 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/tenant/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -374,11 +374,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index eae05cf8bc..409703629a 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/tracked/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -450,11 +450,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json index 2a67c3d2b7..8fead9ff27 100644 --- a/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json +++ b/packages/samples/test/output/azure/resource-manager/resource-types/virtual-resource/@azure-tools/typespec-autorest/2021-10-01-preview/openapi.json @@ -542,11 +542,7 @@ "properties": { "$ref": "#/definitions/EmployeeProperties", "description": "The resource-specific properties for this resource.", - "x-ms-client-flatten": true, - "x-ms-mutability": [ - "read", - "create" - ] + "x-ms-client-flatten": true } }, "allOf": [ diff --git a/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp b/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp index 644bc0437f..454caec07a 100644 --- a/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp +++ b/packages/typespec-azure-resource-manager/lib/foundations/arm.foundations.tsp @@ -115,7 +115,11 @@ model ResourceUpdateModelProperties< model ResourceUpdateModel< Resource extends Foundations.Resource, Properties extends TypeSpec.Reflection.Model -> is OptionalProperties>> { +> + is OptionalProperties>> { @extension("x-ms-client-flatten", true) properties?: ResourceUpdateModelProperties; } diff --git a/packages/typespec-azure-resource-manager/lib/models.tsp b/packages/typespec-azure-resource-manager/lib/models.tsp index e5eb45bf68..fb0bfca16e 100644 --- a/packages/typespec-azure-resource-manager/lib/models.tsp +++ b/packages/typespec-azure-resource-manager/lib/models.tsp @@ -46,7 +46,6 @@ model ResourceNameParameter< @includeInapplicableMetadataInPayload(false) model TrackedResource extends Foundations.TrackedResource { @doc("The resource-specific properties for this resource.") - @visibility("read", "create") @extension("x-ms-client-flatten", true) properties?: Properties; } @@ -62,7 +61,6 @@ model TrackedResource extends Foundations.TrackedResource @includeInapplicableMetadataInPayload(false) model ProxyResource extends Foundations.ProxyResource { @doc("The resource-specific properties for this resource.") - @visibility("read", "create") @extension("x-ms-client-flatten", true) properties?: Properties; } @@ -79,7 +77,6 @@ model ProxyResource extends Foundations.ProxyResource { @includeInapplicableMetadataInPayload(false) model ExtensionResource extends Foundations.ExtensionResource { @doc("The resource-specific properties for this resource.") - @visibility("read", "create") @extension("x-ms-client-flatten", true) properties?: Properties; } From 6fc46453b0ecf7c7246f09980f7b2bfc93c2a6ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 07:50:54 -0700 Subject: [PATCH 08/10] Bump core from `ac93dfa` to `913aa03` (#994) Bumps [core](https://github.com/microsoft/typespec) from `ac93dfa` to `913aa03`.
Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index ac93dfa318..913aa03f78 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit ac93dfa318bb02217b99d0aa3b0898c725d88c0a +Subproject commit 913aa03f78cf5b85b03c5efc5a8666b45f48d514 From 17238644e6ec27695831f44eceedde54bec7ffb3 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Wed, 12 Jun 2024 18:55:28 -0700 Subject: [PATCH 09/10] Adding Legacy V4 ManagedIdentity to avoid breaking change in spec with mixed v3 and v4 types (#998) --- ...egacyManagedIdentity-2024-5-12-18-14-55.md | 7 + .../reference/data-types.md | 55 ++ .../reference/index.mdx | 7 + .../legacy/managed-identity/main.tsp | 62 +++ .../2023-03-01-preview/openapi.json | 479 ++++++++++++++++++ .../lib/Legacy/arm.legacy.tsp | 1 + .../lib/Legacy/managed-identity.tsp | 74 +++ .../lib/arm.tsp | 1 + .../src/common-types.ts | 4 +- 9 files changed, 689 insertions(+), 1 deletion(-) create mode 100644 .chronus/changes/addV4LegacyManagedIdentity-2024-5-12-18-14-55.md create mode 100644 packages/samples/specs/resource-manager/legacy/managed-identity/main.tsp create mode 100644 packages/samples/test/output/azure/resource-manager/legacy/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json create mode 100644 packages/typespec-azure-resource-manager/lib/Legacy/arm.legacy.tsp create mode 100644 packages/typespec-azure-resource-manager/lib/Legacy/managed-identity.tsp diff --git a/.chronus/changes/addV4LegacyManagedIdentity-2024-5-12-18-14-55.md b/.chronus/changes/addV4LegacyManagedIdentity-2024-5-12-18-14-55.md new file mode 100644 index 0000000000..137c8af66e --- /dev/null +++ b/.chronus/changes/addV4LegacyManagedIdentity-2024-5-12-18-14-55.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-azure-resource-manager" +--- + +Adding legacy v4 ManagedServiceIdentity model to avoid breaking changes in specs with mixed v3 and v4 common type reference \ No newline at end of file diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 178430fad5..a3d412af29 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -2154,3 +2154,58 @@ model Azure.ResourceManager.Foundations.TenantScope | ---------- | -------------------------------- | ------------------------------------------ | | apiVersion | `string` | The API version to use for this operation. | | provider | `"Microsoft.ThisWillBeReplaced"` | | + +## Azure.ResourceManager.Legacy + +### `ManagedServiceIdentityV4` {#Azure.ResourceManager.Legacy.ManagedServiceIdentityV4} + +Managed service identity (system assigned and/or user assigned identities) + +```typespec +model Azure.ResourceManager.Legacy.ManagedServiceIdentityV4 +``` + +#### Properties + +| Name | Type | Description | +| ----------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| principalId? | `Core.uuid` | The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| tenantId? | `Core.uuid` | The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. | +| type | [`ManagedServiceIdentityType`](./data-types.md#Azure.ResourceManager.Legacy.ManagedServiceIdentityType) | The type of managed identity assigned to this resource. | +| userAssignedIdentities? | `Record` | The identities assigned to this resource by the user. | + +### `ManagedServiceIdentityV4Property` {#Azure.ResourceManager.Legacy.ManagedServiceIdentityV4Property} + +Model representing the standard `ManagedServiceIdentity` envelope property from V4 of common type. + +Please note that this is only included for legacy specs with mixed v3 and v4 types, which would cause +breaking changes due to the ManagedServiceIdentityType.SystemAndUserAssigned value changes. + +Do not use this if you are already on CommonTypes.Version.v4 or beyond. + +```typespec +model Azure.ResourceManager.Legacy.ManagedServiceIdentityV4Property +``` + +#### Examples + +```typespec +model Foo is TrackedResource { + ...ResourceNameParameter; + ...Legacy.ManagedServiceIdentityV4Property; +} +``` + +#### Properties + +| Name | Type | Description | +| --------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | +| identity? | [`ManagedServiceIdentityV4`](./data-types.md#Azure.ResourceManager.Legacy.ManagedServiceIdentityV4) | The managed service identities assigned to this resource. | + +### `ManagedServiceIdentityType` {#Azure.ResourceManager.Legacy.ManagedServiceIdentityType} + +Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + +```typespec +union Azure.ResourceManager.Legacy.ManagedServiceIdentityType +``` diff --git a/docs/libraries/azure-resource-manager/reference/index.mdx b/docs/libraries/azure-resource-manager/reference/index.mdx index ef473192d6..5ecf4cb7ca 100644 --- a/docs/libraries/azure-resource-manager/reference/index.mdx +++ b/docs/libraries/azure-resource-manager/reference/index.mdx @@ -243,3 +243,10 @@ npm install --save-peer @azure-tools/typespec-azure-resource-manager - [`TagsUpdateModel`](./data-types.md#Azure.ResourceManager.Foundations.TagsUpdateModel) - [`TenantBaseParameters`](./data-types.md#Azure.ResourceManager.Foundations.TenantBaseParameters) - [`TenantScope`](./data-types.md#Azure.ResourceManager.Foundations.TenantScope) + +## Azure.ResourceManager.Legacy + +### Models + +- [`ManagedServiceIdentityV4`](./data-types.md#Azure.ResourceManager.Legacy.ManagedServiceIdentityV4) +- [`ManagedServiceIdentityV4Property`](./data-types.md#Azure.ResourceManager.Legacy.ManagedServiceIdentityV4Property) diff --git a/packages/samples/specs/resource-manager/legacy/managed-identity/main.tsp b/packages/samples/specs/resource-manager/legacy/managed-identity/main.tsp new file mode 100644 index 0000000000..add7878931 --- /dev/null +++ b/packages/samples/specs/resource-manager/legacy/managed-identity/main.tsp @@ -0,0 +1,62 @@ +import "@typespec/http"; +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Http; +using TypeSpec.Rest; +using TypeSpec.Versioning; +using Azure.ResourceManager; +using Azure.Core; + +@armProviderNamespace("Contoso.ManagedIdentityExample") +@service({ + title: "Contoso.ManagedIdentityExample", +}) +@versioned(Versions) +@doc("An example of using the ManagedIdentity properties in a resource type.") +namespace Microsoft.UpdateTests; + +/** UpdateTests API versions */ +enum Versions { + /** 2023-03-01-preview version */ + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) + `2023-03-01-preview`, +} + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("Widget Resource") +model WidgetResource is TrackedResource { + @pattern("^[a-zA-Z0-9-]{3,24}$") + @doc("The name of the widget.") + @key("widgetName") + @segment("widgets") + @path + name: string; + + ...Legacy.ManagedServiceIdentityV4Property; // Or ...ManagedSystemAssignedIdentityProperty; +} + +@doc("Widget Resource Properties.") +model WidgetResourceProperties { + @doc("The widget color.") + @visibility("create", "read") + color: string; + + /** Provisioning state */ + @visibility("read") + provisioningState?: ResourceProvisioningState; +} + +@armResourceOperations +interface Widgets { + get is ArmResourceRead; + create is ArmResourceCreateOrUpdateAsync; + update is ArmTagsPatchSync; + delete is ArmResourceDeleteWithoutOkAsync; + listByResourceGroup is ArmResourceListByParent; + listBySubscription is ArmListBySubscription; +} diff --git a/packages/samples/test/output/azure/resource-manager/legacy/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json b/packages/samples/test/output/azure/resource-manager/legacy/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json new file mode 100644 index 0000000000..dc8b04501c --- /dev/null +++ b/packages/samples/test/output/azure/resource-manager/legacy/managed-identity/@azure-tools/typespec-autorest/2023-03-01-preview/openapi.json @@ -0,0 +1,479 @@ +{ + "swagger": "2.0", + "info": { + "title": "Contoso.ManagedIdentityExample", + "version": "2023-03-01-preview", + "description": "An example of using the ManagedIdentity properties in a resource type.", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "host": "management.azure.com", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "description": "Azure Active Directory OAuth2 Flow.", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "tags": [ + { + "name": "Operations" + }, + { + "name": "Widgets" + } + ], + "paths": { + "/providers/Contoso.ManagedIdentityExample/operations": { + "get": { + "operationId": "Operations_List", + "tags": [ + "Operations" + ], + "description": "List the operations for the provider", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/OperationListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/providers/Contoso.ManagedIdentityExample/widgets": { + "get": { + "operationId": "Widgets_ListBySubscription", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by subscription ID", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.ManagedIdentityExample/widgets": { + "get": { + "operationId": "Widgets_ListByResourceGroup", + "tags": [ + "Widgets" + ], + "description": "List WidgetResource resources by resource group", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ResourceGroupNameParameter" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResourceListResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Contoso.ManagedIdentityExample/widgets/{widgetName}": { + "get": { + "operationId": "Widgets_Get", + "tags": [ + "Widgets" + ], + "description": "Get a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + } + }, + "put": { + "operationId": "Widgets_Create", + "tags": [ + "Widgets" + ], + "description": "Create a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "resource", + "in": "body", + "description": "Resource create parameters.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResource" + } + } + ], + "responses": { + "200": { + "description": "Resource 'WidgetResource' update operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "201": { + "description": "Resource 'WidgetResource' create operation succeeded", + "schema": { + "$ref": "#/definitions/WidgetResource" + }, + "headers": { + "Azure-AsyncOperation": { + "type": "string", + "description": "A link to the status monitor" + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true + }, + "patch": { + "operationId": "Widgets_Update", + "tags": [ + "Widgets" + ], + "description": "Update a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + }, + { + "name": "properties", + "in": "body", + "description": "The resource properties to be updated.", + "required": true, + "schema": { + "$ref": "#/definitions/WidgetResourceTagsUpdate" + } + } + ], + "responses": { + "200": { + "description": "Azure operation completed successfully.", + "schema": { + "$ref": "#/definitions/WidgetResource" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + } + }, + "delete": { + "operationId": "Widgets_Delete", + "tags": [ + "Widgets" + ], + "description": "Delete a WidgetResource", + "parameters": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "name": "widgetName", + "in": "path", + "description": "The name of the widget.", + "required": true, + "type": "string", + "pattern": "^[a-zA-Z0-9-]{3,24}$" + } + ], + "responses": { + "202": { + "description": "Resource deletion accepted.", + "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, + "Retry-After": { + "type": "integer", + "format": "int32", + "description": "The Retry-After header can indicate how long the client should wait before polling the operation status." + } + } + }, + "204": { + "description": "Resource does not exist." + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/ErrorResponse" + } + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "location" + }, + "x-ms-long-running-operation": true + } + } + }, + "definitions": { + "Azure.ResourceManager.ResourceProvisioningState": { + "type": "string", + "description": "The provisioning state of a resource type.", + "enum": [ + "Succeeded", + "Failed", + "Canceled" + ], + "x-ms-enum": { + "name": "ResourceProvisioningState", + "modelAsString": true, + "values": [ + { + "name": "Succeeded", + "value": "Succeeded", + "description": "Resource has been created." + }, + { + "name": "Failed", + "value": "Failed", + "description": "Resource creation failed." + }, + { + "name": "Canceled", + "value": "Canceled", + "description": "Resource creation was canceled." + } + ] + }, + "readOnly": true + }, + "WidgetResource": { + "type": "object", + "description": "Widget Resource", + "properties": { + "properties": { + "$ref": "#/definitions/WidgetResourceProperties", + "description": "The resource-specific properties for this resource.", + "x-ms-client-flatten": true + }, + "identity": { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v4/managedidentity.json#/definitions/ManagedServiceIdentity", + "description": "The managed service identities assigned to this resource." + } + }, + "allOf": [ + { + "$ref": "../../../../../../../../../specs/resource-manager/common-types/v3/types.json#/definitions/TrackedResource" + } + ] + }, + "WidgetResourceListResult": { + "type": "object", + "description": "The response of a WidgetResource list operation.", + "properties": { + "value": { + "type": "array", + "description": "The WidgetResource items on this page", + "items": { + "$ref": "#/definitions/WidgetResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "WidgetResourceProperties": { + "type": "object", + "description": "Widget Resource Properties.", + "properties": { + "color": { + "type": "string", + "description": "The widget color.", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "provisioningState": { + "$ref": "#/definitions/Azure.ResourceManager.ResourceProvisioningState", + "description": "Provisioning state", + "readOnly": true + } + }, + "required": [ + "color" + ] + }, + "WidgetResourceTagsUpdate": { + "type": "object", + "description": "The type used for updating tags in WidgetResource resources.", + "properties": { + "tags": { + "type": "object", + "description": "Resource tags.", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "parameters": {} +} diff --git a/packages/typespec-azure-resource-manager/lib/Legacy/arm.legacy.tsp b/packages/typespec-azure-resource-manager/lib/Legacy/arm.legacy.tsp new file mode 100644 index 0000000000..65fe4b9ae1 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/Legacy/arm.legacy.tsp @@ -0,0 +1 @@ +import "./managed-identity.tsp"; diff --git a/packages/typespec-azure-resource-manager/lib/Legacy/managed-identity.tsp b/packages/typespec-azure-resource-manager/lib/Legacy/managed-identity.tsp new file mode 100644 index 0000000000..5983443382 --- /dev/null +++ b/packages/typespec-azure-resource-manager/lib/Legacy/managed-identity.tsp @@ -0,0 +1,74 @@ +import "@azure-tools/typespec-azure-core"; +import "../common-types/common-types.tsp"; + +using Azure.Core; +using Azure.ResourceManager.CommonTypes.Private; + +namespace Azure.ResourceManager.Legacy; + +/** + * Model representing the standard `ManagedServiceIdentity` envelope property from V4 of common type. + * + * Please note that this is only included for legacy specs with mixed v3 and v4 types, which would cause + * breaking changes due to the ManagedServiceIdentityType.SystemAndUserAssigned value changes. + * + * Do not use this if you are already on CommonTypes.Version.v4 or beyond. + * + * @example + * + * ```typespec + * model Foo is TrackedResource { + * ...ResourceNameParameter; + * ...Legacy.ManagedServiceIdentityV4Property; + * } + * ``` + */ +@doc("The managed service identities envelope.") +model ManagedServiceIdentityV4Property { + @doc("The managed service identities assigned to this resource.") + identity?: ManagedServiceIdentityV4; +} + +/** + * Managed service identity (system assigned and/or user assigned identities) + */ +#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-incompatible-version" "intended only for v3/v4 mix backcompat cases" +@armCommonDefinition( + "ManagedServiceIdentity", + #{ version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, + "managedidentity.json" +) +model ManagedServiceIdentityV4 { + /** The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + @visibility("read") + principalId?: uuid; + + /** The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. */ + @visibility("read") + tenantId?: uuid; + + /** The type of managed identity assigned to this resource. */ + type: ManagedServiceIdentityType; + + /** The identities assigned to this resource by the user. */ + userAssignedIdentities?: Record; +} + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +union ManagedServiceIdentityType { + /** No managed identity. */ + None: "None", + + /** System assigned managed identity. */ + SystemAssigned: "SystemAssigned", + + /** User assigned managed identity. */ + UserAssigned: "UserAssigned", + + /** System and user assigned managed identity. */ + SystemAndUserAssigned: "SystemAssigned, UserAssigned", + + string, +} diff --git a/packages/typespec-azure-resource-manager/lib/arm.tsp b/packages/typespec-azure-resource-manager/lib/arm.tsp index 0a471f32bc..f80479cab0 100644 --- a/packages/typespec-azure-resource-manager/lib/arm.tsp +++ b/packages/typespec-azure-resource-manager/lib/arm.tsp @@ -6,6 +6,7 @@ import "@typespec/versioning"; import "@azure-tools/typespec-azure-core"; import "./foundations/arm.foundations.tsp"; +import "./Legacy/arm.legacy.tsp"; import "./common-types/common-types.tsp"; import "./backcompat.tsp"; import "./private.decorators.tsp"; diff --git a/packages/typespec-azure-resource-manager/src/common-types.ts b/packages/typespec-azure-resource-manager/src/common-types.ts index 8b69d3bf93..f0cb277c79 100644 --- a/packages/typespec-azure-resource-manager/src/common-types.ts +++ b/packages/typespec-azure-resource-manager/src/common-types.ts @@ -187,11 +187,13 @@ export function findArmCommonTypeRecord( break; } } - } else { + } + if (record === undefined) { // If no version was found, use the default version record = records[defaultKey ?? ArmCommonTypesDefaultVersion]; } + // If after resolve version AND unable to load default version, report diagnostic if (record === undefined) { return [ undefined, From 70ffbbcd18ca48a570d6855437f9549394448425 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:01:49 +0000 Subject: [PATCH 10/10] Bump core from `913aa03` to `4ed71bf` (#1012) Bumps [core](https://github.com/microsoft/typespec) from `913aa03` to `4ed71bf`.
Commits
  • 4ed71bf Add release notes for 0.57.0 (#3560)
  • 147335d fix error when model property is invalid (#3574)
  • e4c4d2b Add support for completion of extends and is (#3443)
  • 5bc98d9 Fix: Using a scalar constructor defined in a parent scalar doesn't reference ...
  • 35e8625 support loglevel filter in playground (#3569)
  • See full diff in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 913aa03f78..4ed71bf73f 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 913aa03f78cf5b85b03c5efc5a8666b45f48d514 +Subproject commit 4ed71bf73fe51292c52676849b8462ced86005fb