From 6f3b652c3705373f2d320e549b42f9293d81a9a5 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 3 Jul 2023 15:45:59 +0800 Subject: [PATCH 01/22] New RP: Microsoft.AzureTerraform (ver=2023-07-01-preview) --- .../examples/ExportTerraform.json | 22 ++ .../preview/2023-07-01-preview/export.json | 296 ++++++++++++++++++ .../terraform/resource-manager/readme.md | 63 ++++ 3 files changed, 381 insertions(+) create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json create mode 100644 specification/terraform/resource-manager/readme.md diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json new file mode 100644 index 000000000000..c2ca06f36569 --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json @@ -0,0 +1,22 @@ +{ + "title": "ExportTerraform", + "operationId": "ExportTerraform", + "parameters": { + "api-version": "2023-07-01-preview", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "exportParameter": { + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "type": "ExportResourceGroupParameter", + "resourceGroupName": "rg1" + } + }, + "responses": { + "200": { + "body": { + "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", + "errors": null, + "skippedResources": null + } + } + } +} \ No newline at end of file diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json new file mode 100644 index 000000000000..cf06f0e4ba25 --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -0,0 +1,296 @@ +{ + "swagger": "2.0", + "info": { + "title": "AzureTerraformResourceProviderClient", + "description": "The Azure Terraform management API provides a RESTful set of web services that used to manage your Azure Terraform resources.", + "version": "2023-07-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { + "post": { + "tags": [ + "ExportTerraform" + ], + "operationId": "ExportTerraform", + "description": "Exports the Terraform configuration used for the specified scope.", + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ExportParameter" + } + ], + "responses": { + "200": { + "description": "OK - Returns the template.", + "schema": { + "$ref": "#/definitions/ExportResult" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/CloudError" + } + } + }, + "x-ms-examples": { + "ExportTerraform": { + "$ref": "./examples/ExportTerraform.json" + } + } + } + } + }, + "definitions": { + "ExportResourceParameter": { + "allOf": [ + { + "$ref": "#/definitions/BaseExportParameter" + } + ], + "description": "Export parameter for a single resource", + "required": [ + "resourceId" + ], + "properties": { + "resourceId": { + "description": "The id of the resource to be exported", + "type": "string" + }, + "name": { + "description": "The Terraform resource name", + "type": "string", + "default": "res-0" + } + }, + "type": "object", + "x-ms-discriminator-value": "Resource" + }, + "ExportResourceGroupParameter": { + "allOf": [ + { + "$ref": "#/definitions/BaseExportParameter" + } + ], + "description": "Export parameter for a resource group", + "required": [ + "resourceGroupName" + ], + "properties": { + "resourceGroupName": { + "description": "The name of the resource group to be exported", + "type": "string" + }, + "namePattern": { + "description": "The pattern of the Terraform resources", + "type": "string", + "default": "res-" + } + }, + "type": "object", + "x-ms-discriminator-value": "ResourceGroup" + }, + "ExportQueryParameter": { + "allOf": [ + { + "$ref": "#/definitions/BaseExportParameter" + } + ], + "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", + "required": [ + "query" + ], + "properties": { + "query": { + "description": "The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`", + "type": "string" + }, + "namePattern": { + "description": "The pattern of the Terraform resources", + "type": "string", + "default": "res-" + }, + "recursive": { + "description": "Whether to recursively list child resources of the query result", + "type": "boolean", + "default": false + } + }, + "type": "object", + "x-ms-discriminator-value": "Query" + }, + "BaseExportParameter": { + "description": "The base export parameter", + "discriminator": "type", + "required": [ + "subscriptionId", + "type" + ], + "properties": { + "subscriptionId": { + "description": "The id of the subscription where the target resources reside in", + "type": "string" + }, + "environment": { + "description": "The cloud environment", + "type": "string", + "enum": [ + "public", + "china", + "usgovernment" + ], + "default": "public" + }, + "type": { + "$ref": "#/definitions/Type", + "description": "The parameter type" + }, + "fullProperties": { + "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", + "type": "boolean", + "default": false + }, + "parallelism": { + "description": " Limit the number of parallel operations, i.e., resource discovery, import", + "type": "integer", + "default": 10 + } + }, + "type": "object" + }, + "Type": { + "description": "The parameter type", + "type": "string", + "enum": [ + "ExportResourceParameter", + "ExportResourceGroupParameter", + "ExportQueryParameter" + ] + }, + "ExportResult": { + "description": "The Terraform export result", + "properties": { + "configuration": { + "type": "object", + "description": "The Terraform configuration content" + }, + "skippedResources": { + "description": "A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform", + "type": "array", + "items": { + "type": "string" + } + }, + "errors": { + "description": "A list of errors derived during exporting each resource", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "CloudError": { + "x-ms-external": true, + "properties": { + "error": { + "$ref": "#/definitions/ErrorResponse" + } + }, + "description": "An error response for a resource management request" + }, + "ErrorResponse": { + "title": "Error Response", + "description": "Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)", + "type": "object", + "properties": { + "code": { + "readOnly": true, + "type": "string", + "description": "The error code." + }, + "message": { + "readOnly": true, + "type": "string", + "description": "The error message." + }, + "target": { + "readOnly": true, + "type": "string", + "description": "The error target." + }, + "details": { + "readOnly": true, + "type": "array", + "items": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-identifiers": [ + "message", + "target" + ], + "description": "The error details." + } + } + } + }, + "parameters": { + "ExportParameter": { + "description": "The export parameter", + "in": "body", + "name": "exportParameter", + "required": true, + "schema": { + "$ref": "#/definitions/BaseExportParameter" + }, + "x-ms-parameter-location": "method" + }, + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Client Api Version." + } + } +} \ No newline at end of file diff --git a/specification/terraform/resource-manager/readme.md b/specification/terraform/resource-manager/readme.md new file mode 100644 index 000000000000..8634a0d157d6 --- /dev/null +++ b/specification/terraform/resource-manager/readme.md @@ -0,0 +1,63 @@ +# AzureTerraform + +> see https://aka.ms/autorest + +This is the AutoRest configuration file for AzureTerraform. + +## Getting Started + +To build the SDKs for AzureTerraform, simply install AutoRest via `npm` (`npm install -g autorest`) and then run: + +> `autorest readme.md` + +To see additional help and options, run: + +> `autorest --help` + +For other options on installation see [Installing AutoRest](https://aka.ms/autorest/install) on the AutoRest github page. + +--- + +## Configuration + +### Basic Information + +These are the global settings for the AzureTerraform API. + +``` yaml +title: AzureTerraformManagementClient +description: AzureTerraform Client +openapi-type: arm +tag: package-2023-07 +``` + + +### Tag: package-2023-07-01-preview + +These settings apply only when `--tag=package-2023-07-01-preview` is specified on the command line. + +```yaml $(tag) == 'package-2023-07-01-preview' +input-file: + - Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +``` + +--- + +# Code Generation + +## Swagger to SDK + +This section describes what SDK should be generated by the automatic system. +This is not used by Autorest itself. + +``` yaml $(swagger-to-sdk) +swagger-to-sdk: + - repo: azure-sdk-for-net + - repo: azure-sdk-for-net-track2 + - repo: azure-sdk-for-python-track2 + - repo: azure-sdk-for-java + - repo: azure-sdk-for-go + - repo: azure-sdk-for-js + - repo: azure-sdk-for-node + - repo: azure-powershell +``` From 2d66db07dfff663f3f8e457dc7b187a8350772ec Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 3 Jul 2023 16:11:14 +0800 Subject: [PATCH 02/22] prettier --- .../examples/ExportTerraform.json | 40 +- .../preview/2023-07-01-preview/export.json | 552 +++++++++--------- 2 files changed, 296 insertions(+), 296 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json index c2ca06f36569..cb00633dbb35 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json @@ -1,22 +1,22 @@ { - "title": "ExportTerraform", - "operationId": "ExportTerraform", - "parameters": { - "api-version": "2023-07-01-preview", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "exportParameter": { - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "type": "ExportResourceGroupParameter", - "resourceGroupName": "rg1" - } - }, - "responses": { - "200": { - "body": { - "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", - "errors": null, - "skippedResources": null - } - } + "title": "ExportTerraform", + "operationId": "ExportTerraform", + "parameters": { + "api-version": "2023-07-01-preview", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "exportParameter": { + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "type": "ExportResourceGroupParameter", + "resourceGroupName": "rg1" } -} \ No newline at end of file + }, + "responses": { + "200": { + "body": { + "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", + "errors": null, + "skippedResources": null + } + } + } +} diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index cf06f0e4ba25..c625f8707cba 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -1,296 +1,296 @@ { - "swagger": "2.0", - "info": { - "title": "AzureTerraformResourceProviderClient", - "description": "The Azure Terraform management API provides a RESTful set of web services that used to manage your Azure Terraform resources.", - "version": "2023-07-01-preview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ + "swagger": "2.0", + "info": { + "title": "AzureTerraformResourceProviderClient", + "description": "The Azure Terraform management API provides a RESTful set of web services that used to manage your Azure Terraform resources.", + "version": "2023-07-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { + "post": { + "tags": [ + "ExportTerraform" + ], + "operationId": "ExportTerraform", + "description": "Exports the Terraform configuration used for the specified scope.", + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ExportParameter" + } + ], + "responses": { + "200": { + "description": "OK - Returns the template.", + "schema": { + "$ref": "#/definitions/ExportResult" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/CloudError" + } + } + }, + "x-ms-examples": { + "ExportTerraform": { + "$ref": "./examples/ExportTerraform.json" + } + } + } + } + }, + "definitions": { + "ExportResourceParameter": { + "allOf": [ { - "azure_auth": [ - "user_impersonation" - ] + "$ref": "#/definitions/BaseExportParameter" } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", - "scopes": { - "user_impersonation": "impersonate your user account" - } + ], + "description": "Export parameter for a single resource", + "required": [ + "resourceId" + ], + "properties": { + "resourceId": { + "description": "The id of the resource to be exported", + "type": "string" + }, + "name": { + "description": "The Terraform resource name", + "type": "string", + "default": "res-0" } + }, + "type": "object", + "x-ms-discriminator-value": "Resource" }, - "paths": { - "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { - "post": { - "tags": [ - "ExportTerraform" - ], - "operationId": "ExportTerraform", - "description": "Exports the Terraform configuration used for the specified scope.", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "$ref": "#/parameters/ExportParameter" - } - ], - "responses": { - "200": { - "description": "OK - Returns the template.", - "schema": { - "$ref": "#/definitions/ExportResult" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - }, - "x-ms-examples": { - "ExportTerraform": { - "$ref": "./examples/ExportTerraform.json" - } - } - } + "ExportResourceGroupParameter": { + "allOf": [ + { + "$ref": "#/definitions/BaseExportParameter" + } + ], + "description": "Export parameter for a resource group", + "required": [ + "resourceGroupName" + ], + "properties": { + "resourceGroupName": { + "description": "The name of the resource group to be exported", + "type": "string" + }, + "namePattern": { + "description": "The pattern of the Terraform resources", + "type": "string", + "default": "res-" } + }, + "type": "object", + "x-ms-discriminator-value": "ResourceGroup" }, - "definitions": { - "ExportResourceParameter": { - "allOf": [ - { - "$ref": "#/definitions/BaseExportParameter" - } - ], - "description": "Export parameter for a single resource", - "required": [ - "resourceId" - ], - "properties": { - "resourceId": { - "description": "The id of the resource to be exported", - "type": "string" - }, - "name": { - "description": "The Terraform resource name", - "type": "string", - "default": "res-0" - } - }, - "type": "object", - "x-ms-discriminator-value": "Resource" + "ExportQueryParameter": { + "allOf": [ + { + "$ref": "#/definitions/BaseExportParameter" + } + ], + "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", + "required": [ + "query" + ], + "properties": { + "query": { + "description": "The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`", + "type": "string" }, - "ExportResourceGroupParameter": { - "allOf": [ - { - "$ref": "#/definitions/BaseExportParameter" - } - ], - "description": "Export parameter for a resource group", - "required": [ - "resourceGroupName" - ], - "properties": { - "resourceGroupName": { - "description": "The name of the resource group to be exported", - "type": "string" - }, - "namePattern": { - "description": "The pattern of the Terraform resources", - "type": "string", - "default": "res-" - } - }, - "type": "object", - "x-ms-discriminator-value": "ResourceGroup" + "namePattern": { + "description": "The pattern of the Terraform resources", + "type": "string", + "default": "res-" }, - "ExportQueryParameter": { - "allOf": [ - { - "$ref": "#/definitions/BaseExportParameter" - } - ], - "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", - "required": [ - "query" - ], - "properties": { - "query": { - "description": "The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`", - "type": "string" - }, - "namePattern": { - "description": "The pattern of the Terraform resources", - "type": "string", - "default": "res-" - }, - "recursive": { - "description": "Whether to recursively list child resources of the query result", - "type": "boolean", - "default": false - } - }, - "type": "object", - "x-ms-discriminator-value": "Query" + "recursive": { + "description": "Whether to recursively list child resources of the query result", + "type": "boolean", + "default": false + } + }, + "type": "object", + "x-ms-discriminator-value": "Query" + }, + "BaseExportParameter": { + "description": "The base export parameter", + "discriminator": "type", + "required": [ + "subscriptionId", + "type" + ], + "properties": { + "subscriptionId": { + "description": "The id of the subscription where the target resources reside in", + "type": "string" }, - "BaseExportParameter": { - "description": "The base export parameter", - "discriminator": "type", - "required": [ - "subscriptionId", - "type" - ], - "properties": { - "subscriptionId": { - "description": "The id of the subscription where the target resources reside in", - "type": "string" - }, - "environment": { - "description": "The cloud environment", - "type": "string", - "enum": [ - "public", - "china", - "usgovernment" - ], - "default": "public" - }, - "type": { - "$ref": "#/definitions/Type", - "description": "The parameter type" - }, - "fullProperties": { - "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", - "type": "boolean", - "default": false - }, - "parallelism": { - "description": " Limit the number of parallel operations, i.e., resource discovery, import", - "type": "integer", - "default": 10 - } - }, - "type": "object" + "environment": { + "description": "The cloud environment", + "type": "string", + "enum": [ + "public", + "china", + "usgovernment" + ], + "default": "public" }, - "Type": { - "description": "The parameter type", - "type": "string", - "enum": [ - "ExportResourceParameter", - "ExportResourceGroupParameter", - "ExportQueryParameter" - ] + "type": { + "$ref": "#/definitions/Type", + "description": "The parameter type" }, - "ExportResult": { - "description": "The Terraform export result", - "properties": { - "configuration": { - "type": "object", - "description": "The Terraform configuration content" - }, - "skippedResources": { - "description": "A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform", - "type": "array", - "items": { - "type": "string" - } - }, - "errors": { - "description": "A list of errors derived during exporting each resource", - "type": "array", - "items": { - "type": "string" - } - } - } + "fullProperties": { + "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", + "type": "boolean", + "default": false }, - "CloudError": { - "x-ms-external": true, - "properties": { - "error": { - "$ref": "#/definitions/ErrorResponse" - } - }, - "description": "An error response for a resource management request" + "parallelism": { + "description": " Limit the number of parallel operations, i.e., resource discovery, import", + "type": "integer", + "default": 10 + } + }, + "type": "object" + }, + "Type": { + "description": "The parameter type", + "type": "string", + "enum": [ + "ExportResourceParameter", + "ExportResourceGroupParameter", + "ExportQueryParameter" + ] + }, + "ExportResult": { + "description": "The Terraform export result", + "properties": { + "configuration": { + "type": "object", + "description": "The Terraform configuration content" }, - "ErrorResponse": { - "title": "Error Response", - "description": "Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)", - "type": "object", - "properties": { - "code": { - "readOnly": true, - "type": "string", - "description": "The error code." - }, - "message": { - "readOnly": true, - "type": "string", - "description": "The error message." - }, - "target": { - "readOnly": true, - "type": "string", - "description": "The error target." - }, - "details": { - "readOnly": true, - "type": "array", - "items": { - "$ref": "#/definitions/ErrorResponse" - }, - "x-ms-identifiers": [ - "message", - "target" - ], - "description": "The error details." - } - } + "skippedResources": { + "description": "A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform", + "type": "array", + "items": { + "type": "string" + } + }, + "errors": { + "description": "A list of errors derived during exporting each resource", + "type": "array", + "items": { + "type": "string" + } } + } }, - "parameters": { - "ExportParameter": { - "description": "The export parameter", - "in": "body", - "name": "exportParameter", - "required": true, - "schema": { - "$ref": "#/definitions/BaseExportParameter" - }, - "x-ms-parameter-location": "method" + "CloudError": { + "x-ms-external": true, + "properties": { + "error": { + "$ref": "#/definitions/ErrorResponse" + } + }, + "description": "An error response for a resource management request" + }, + "ErrorResponse": { + "title": "Error Response", + "description": "Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)", + "type": "object", + "properties": { + "code": { + "readOnly": true, + "type": "string", + "description": "The error code." }, - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." + "message": { + "readOnly": true, + "type": "string", + "description": "The error message." }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client Api Version." + "target": { + "readOnly": true, + "type": "string", + "description": "The error target." + }, + "details": { + "readOnly": true, + "type": "array", + "items": { + "$ref": "#/definitions/ErrorResponse" + }, + "x-ms-identifiers": [ + "message", + "target" + ], + "description": "The error details." } + } + } + }, + "parameters": { + "ExportParameter": { + "description": "The export parameter", + "in": "body", + "name": "exportParameter", + "required": true, + "schema": { + "$ref": "#/definitions/BaseExportParameter" + }, + "x-ms-parameter-location": "method" + }, + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Client Api Version." } -} \ No newline at end of file + } +} From 0ccc732d3fe0dab7b394b50391dd3a9c1e9351d8 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 3 Jul 2023 16:12:43 +0800 Subject: [PATCH 03/22] remove x-ms-discriminator-value --- .../preview/2023-07-01-preview/export.json | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index c625f8707cba..dbc2cfc32242 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -96,8 +96,7 @@ "default": "res-0" } }, - "type": "object", - "x-ms-discriminator-value": "Resource" + "type": "object" }, "ExportResourceGroupParameter": { "allOf": [ @@ -120,8 +119,7 @@ "default": "res-" } }, - "type": "object", - "x-ms-discriminator-value": "ResourceGroup" + "type": "object" }, "ExportQueryParameter": { "allOf": [ @@ -149,8 +147,7 @@ "default": false } }, - "type": "object", - "x-ms-discriminator-value": "Query" + "type": "object" }, "BaseExportParameter": { "description": "The base export parameter", From 946a7b3ece88607e6a29f6562eb75515cbcbcf33 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 3 Jul 2023 16:35:16 +0800 Subject: [PATCH 04/22] readme.md: add `openapi-subtype` --- specification/terraform/resource-manager/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specification/terraform/resource-manager/readme.md b/specification/terraform/resource-manager/readme.md index 8634a0d157d6..6b21e382c0d3 100644 --- a/specification/terraform/resource-manager/readme.md +++ b/specification/terraform/resource-manager/readme.md @@ -28,6 +28,7 @@ These are the global settings for the AzureTerraform API. title: AzureTerraformManagementClient description: AzureTerraform Client openapi-type: arm +openapi-subtype: providerHub tag: package-2023-07 ``` From 00c322559a2f193a772895cebc0d7de24c0484b2 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 3 Jul 2023 16:44:53 +0800 Subject: [PATCH 05/22] Fix LintDiff failure --- .../preview/2023-07-01-preview/export.json | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index dbc2cfc32242..a2bec83e7f4e 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -43,10 +43,10 @@ "description": "Exports the Terraform configuration used for the specified scope.", "parameters": [ { - "$ref": "#/parameters/ApiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter" }, { "$ref": "#/parameters/ExportParameter" @@ -169,6 +169,10 @@ "china", "usgovernment" ], + "x-ms-enum": { + "name": "environment", + "modelAsString": true + }, "default": "public" }, "type": { @@ -183,6 +187,7 @@ "parallelism": { "description": " Limit the number of parallel operations, i.e., resource discovery, import", "type": "integer", + "format": "int64", "default": 10 } }, @@ -195,9 +200,14 @@ "ExportResourceParameter", "ExportResourceGroupParameter", "ExportQueryParameter" - ] + ], + "x-ms-enum": { + "name": "parameterType", + "modelAsString": true + } }, "ExportResult": { + "type": "object", "description": "The Terraform export result", "properties": { "configuration": { @@ -222,6 +232,7 @@ }, "CloudError": { "x-ms-external": true, + "type": "object", "properties": { "error": { "$ref": "#/definitions/ErrorResponse" @@ -274,20 +285,6 @@ "$ref": "#/definitions/BaseExportParameter" }, "x-ms-parameter-location": "method" - }, - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call." - }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "Client Api Version." } } } From 3024e9eef0b2b7e19526859e539515790796fcaf Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 14 Jul 2023 10:40:32 +0800 Subject: [PATCH 06/22] Result configuration type change from object to string --- .../preview/2023-07-01-preview/export.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index a2bec83e7f4e..665cdfff1cad 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -211,7 +211,7 @@ "description": "The Terraform export result", "properties": { "configuration": { - "type": "object", + "type": "string", "description": "The Terraform configuration content" }, "skippedResources": { From 864168bdd80f08c5ce515d4088058fc1845b3ee6 Mon Sep 17 00:00:00 2001 From: magodo Date: Wed, 26 Jul 2023 11:04:07 +0800 Subject: [PATCH 07/22] Remove properties: `subscriptionId` and `environment` --- .../examples/ExportTerraform.json | 1 - .../preview/2023-07-01-preview/export.json | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json index cb00633dbb35..e0540419e290 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json @@ -5,7 +5,6 @@ "api-version": "2023-07-01-preview", "subscriptionId": "00000000-0000-0000-0000-000000000000", "exportParameter": { - "subscriptionId": "00000000-0000-0000-0000-000000000000", "type": "ExportResourceGroupParameter", "resourceGroupName": "rg1" } diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 665cdfff1cad..0ca00a5e6141 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -157,24 +157,6 @@ "type" ], "properties": { - "subscriptionId": { - "description": "The id of the subscription where the target resources reside in", - "type": "string" - }, - "environment": { - "description": "The cloud environment", - "type": "string", - "enum": [ - "public", - "china", - "usgovernment" - ], - "x-ms-enum": { - "name": "environment", - "modelAsString": true - }, - "default": "public" - }, "type": { "$ref": "#/definitions/Type", "description": "The parameter type" From 92ad09617c4913bd3a83dee1952f150206178dc8 Mon Sep 17 00:00:00 2001 From: magodo Date: Wed, 26 Jul 2023 11:04:49 +0800 Subject: [PATCH 08/22] Change `errors` from list of string to list of `ErrorResponse` --- .../preview/2023-07-01-preview/export.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 0ca00a5e6141..0c8d70bf6036 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -207,7 +207,8 @@ "description": "A list of errors derived during exporting each resource", "type": "array", "items": { - "type": "string" + "type": "object", + "$ref": "#/definitions/ErrorResponse" } } } From df284eaecb0072f38f5efaf4043ca3f453760ed9 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 7 Aug 2023 10:08:49 +0800 Subject: [PATCH 09/22] Add operations endpoint --- .../examples/ListOperations.json | 34 ++++++++ .../preview/2023-07-01-preview/export.json | 81 ++++++++++++++++++- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json new file mode 100644 index 000000000000..8627365bdd24 --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json @@ -0,0 +1,34 @@ +{ + "title": "List Operations", + "operationId": "ListOperations", + "parameters": { + "subscriptionId": "12345678-1234-1234-12345678abc", + "api-version": "2023-07-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Microsoft.AzureTerraform/operations/read", + "display": { + "provider": "Microsoft AzureTerraform", + "resource": "Azure Terraform Resource Provider", + "operation": "ListOperations", + "description": "Lists all of the available RP operations." + } + }, + { + "name": "Microsoft.AzureTerraform/exportTerraform/action", + "display": { + "provider": "Microsoft AzureTerraform", + "resource": "Azure Terraform Resource Provider", + "operation": "ExportTerraform", + "description": "Exports the Terraform configuration used for the specified scope." + } + } + ] + } + } + } +} diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 0c8d70bf6036..cdc9884ea5a9 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -34,6 +34,37 @@ } }, "paths": { + "/providers/Microsoft.AzureTerraform/operations": { + "get": { + "tags": [ + "Operations" + ], + "description": "Lists all of the available RP operations.", + "operationId": "ListOperations", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "OK. The request has succeeded.", + "schema": { + "$ref": "#/definitions/OperationListResult" + } + }, + "default": { + "description": "Resource Provider error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/ErrorResponse" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { "post": { "tags": [ @@ -209,7 +240,8 @@ "items": { "type": "object", "$ref": "#/definitions/ErrorResponse" - } + }, + "x-ms-identifiers": [] } } }, @@ -256,6 +288,53 @@ "description": "The error details." } } + }, + "Operation": { + "description": "REST API operation", + "type": "object", + "properties": { + "name": { + "description": "Operation name: {provider}/{resource}/{operation}", + "type": "string" + }, + "display": { + "description": "The object that represents the operation.", + "properties": { + "provider": { + "description": "Service provider: Microsoft.AzureTerraform", + "type": "string" + }, + "resource": { + "description": "Resource on which the operation is performed: Profile, endpoint, etc.", + "type": "string" + }, + "operation": { + "description": "Name of the operation for display purposes", + "type": "string" + }, + "description": { + "description": "Description of the operation for display purposes", + "type": "string" + } + } + } + } + }, + "OperationListResult": { + "description": "Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results.", + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/Operation" + }, + "description": "List of Resource Provider operations supported by the Resource Provider resource provider." + }, + "nextLink": { + "type": "string", + "description": "URL to get the next set of operation list results if there are any." + } + } } }, "parameters": { From 539d7f9b08a89941bdf934b082c491078b9981d8 Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 7 Aug 2023 13:36:25 +0800 Subject: [PATCH 10/22] Update --- .../examples/ListOperations.json | 2 +- .../preview/2023-07-01-preview/export.json | 106 ++---------------- 2 files changed, 11 insertions(+), 97 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json index 8627365bdd24..a6b59fe985fe 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json @@ -1,6 +1,6 @@ { "title": "List Operations", - "operationId": "ListOperations", + "operationId": "Operations_List", "parameters": { "subscriptionId": "12345678-1234-1234-12345678abc", "api-version": "2023-07-01-preview" diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index cdc9884ea5a9..3e070fd9cbf3 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -40,7 +40,7 @@ "Operations" ], "description": "Lists all of the available RP operations.", - "operationId": "ListOperations", + "operationId": "Operations_List", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" @@ -50,18 +50,23 @@ "200": { "description": "OK. The request has succeeded.", "schema": { - "$ref": "#/definitions/OperationListResult" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/OperationListResult" } }, "default": { "description": "Resource Provider error response describing why the operation failed.", "schema": { - "$ref": "#/definitions/ErrorResponse" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } }, "x-ms-pageable": { "nextLinkName": "nextLink" + }, + "x-ms-examples": { + "Get a list of operations for a resource provider": { + "$ref": "./examples/ListOperations.json" + } } } }, @@ -93,7 +98,7 @@ "default": { "description": "Error response describing why the operation failed.", "schema": { - "$ref": "#/definitions/CloudError" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } }, @@ -239,102 +244,11 @@ "type": "array", "items": { "type": "object", - "$ref": "#/definitions/ErrorResponse" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorDetail" }, "x-ms-identifiers": [] } } - }, - "CloudError": { - "x-ms-external": true, - "type": "object", - "properties": { - "error": { - "$ref": "#/definitions/ErrorResponse" - } - }, - "description": "An error response for a resource management request" - }, - "ErrorResponse": { - "title": "Error Response", - "description": "Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)", - "type": "object", - "properties": { - "code": { - "readOnly": true, - "type": "string", - "description": "The error code." - }, - "message": { - "readOnly": true, - "type": "string", - "description": "The error message." - }, - "target": { - "readOnly": true, - "type": "string", - "description": "The error target." - }, - "details": { - "readOnly": true, - "type": "array", - "items": { - "$ref": "#/definitions/ErrorResponse" - }, - "x-ms-identifiers": [ - "message", - "target" - ], - "description": "The error details." - } - } - }, - "Operation": { - "description": "REST API operation", - "type": "object", - "properties": { - "name": { - "description": "Operation name: {provider}/{resource}/{operation}", - "type": "string" - }, - "display": { - "description": "The object that represents the operation.", - "properties": { - "provider": { - "description": "Service provider: Microsoft.AzureTerraform", - "type": "string" - }, - "resource": { - "description": "Resource on which the operation is performed: Profile, endpoint, etc.", - "type": "string" - }, - "operation": { - "description": "Name of the operation for display purposes", - "type": "string" - }, - "description": { - "description": "Description of the operation for display purposes", - "type": "string" - } - } - } - } - }, - "OperationListResult": { - "description": "Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results.", - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/Operation" - }, - "description": "List of Resource Provider operations supported by the Resource Provider resource provider." - }, - "nextLink": { - "type": "string", - "description": "URL to get the next set of operation list results if there are any." - } - } } }, "parameters": { From 16d534eccb8d4f4d8f1fd19dd5f94aee11c5f54b Mon Sep 17 00:00:00 2001 From: magodo Date: Mon, 7 Aug 2023 16:34:48 +0800 Subject: [PATCH 11/22] Update --- .../preview/2023-07-01-preview/export.json | 1 - 1 file changed, 1 deletion(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 3e070fd9cbf3..cb2224572a9d 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -189,7 +189,6 @@ "description": "The base export parameter", "discriminator": "type", "required": [ - "subscriptionId", "type" ], "properties": { From 2a9358780144b56c70ee83ef4bde2d9c7a98da2a Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 22 Feb 2024 17:08:58 +0800 Subject: [PATCH 12/22] AzureTerraform RP: Sync the MS version with the private version --- .../preview/2023-07-01-preview/export.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index cb2224572a9d..7f52bd1ed161 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -196,6 +196,15 @@ "$ref": "#/definitions/Type", "description": "The parameter type" }, + "targetProvider": { + "description": "The target Azure Terraform Provider", + "type": "string", + "enum": [ + "azurerm", + "azapi" + ], + "default": "azurerm" + }, "fullProperties": { "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", "type": "boolean", From 6e52be1e73b9d26020b6c35c6aa629e5852f461e Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 12 Jul 2024 15:01:26 +0800 Subject: [PATCH 13/22] Terraform: Change `exportEerraform` endpoint to LRO (#18782) * terraform: Modify the `exportTerraform` RT to be LRO * Update * prettier * spell * CI validation * More CI issue fixes * typo * Add readme.go.md * typo * prettier * suppression * Update suppression --- cSpell.json | 7 + .../examples/ExportTerraform.json | 9 +- .../examples/GetOperationStatus.json | 36 +++++ .../preview/2023-07-01-preview/export.json | 135 +++++++++++++++++- .../terraform/resource-manager/readme.go.md | 11 ++ .../terraform/resource-manager/readme.md | 2 +- specification/terraform/suppressions.yaml | 3 + 7 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json create mode 100644 specification/terraform/resource-manager/readme.go.md create mode 100644 specification/terraform/suppressions.yaml diff --git a/cSpell.json b/cSpell.json index fd37bd220726..aa61ba47c5eb 100644 --- a/cSpell.json +++ b/cSpell.json @@ -1404,6 +1404,13 @@ "sfmc", "sfmc's" ] + }, + { + "filename": "**/specification/terraform/resource-manager/Microsoft.AzureTerraform/**/*.json", + "words": [ + "azurerm", + "azapi" + ] } ], "enableFiletypes": [ diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json index e0540419e290..4029ff48714d 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json @@ -10,11 +10,10 @@ } }, "responses": { - "200": { - "body": { - "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", - "errors": null, - "skippedResources": null + "202": { + "headers": { + "Azure-AsyncOperation": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview" } } } diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json new file mode 100644 index 000000000000..ca03505b1edc --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json @@ -0,0 +1,36 @@ +{ + "parameters": { + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "operationId": "00000000-0000-0000-0000-000000000000", + "api-version": "2023-07-01-preview" + }, + "responses": { + "200": { + "headers": {}, + "body": { + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "name": "00000000-0000-0000-0000-000000000000", + "startTime": "2024-07-08T08:48:46.3160075Z", + "endTime": "2024-07-08T08:49:23.7083Z", + "status": "Succeeded", + "properties": { + "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", + "errors": null, + "skippedResources": null + } + } + }, + "202": { + "headers": { + "Azure-AsyncOperation": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview" + }, + "body": { + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "name": "00000000-0000-0000-0000-000000000000", + "startTime": "2024-07-08T08:48:46.3160075Z", + "status": "InProgress" + } + } + } +} diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 7f52bd1ed161..a4ce93940a4c 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -70,6 +70,66 @@ } } }, + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/operationStatuses/{operationId}": { + "get": { + "x-ms-examples": { + "Get specific operation status": { + "$ref": "./examples/GetOperationStatus.json" + } + }, + "tags": [ + "OperationStatuses" + ], + "operationId": "OperationStatuses_Get", + "description": "Get the status of a long running azure asynchronous operation.", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/OperationIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter" + } + ], + "responses": { + "200": { + "description": "Finalized operation status.", + "schema": { + "$ref": "#/definitions/OperationStatus" + } + }, + "202": { + "description": "InProgress operation status.", + "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, + "Azure-AsyncOperation": { + "type": "string", + "description": "The Azure-AsyncOperation 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." + } + }, + "schema": { + "$ref": "#/definitions/OperationStatus" + } + }, + "default": { + "description": "Error response returned if request was unsuccessful.", + "schema": { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" + } + } + } + } + }, "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { "post": { "tags": [ @@ -89,10 +149,22 @@ } ], "responses": { - "200": { - "description": "OK - Returns the template.", - "schema": { - "$ref": "#/definitions/ExportResult" + "202": { + "description": "Export request accepted.", + "headers": { + "Location": { + "type": "string", + "description": "The Location header contains the URL where the status of the long running operation can be checked." + }, + "Azure-AsyncOperation": { + "type": "string", + "description": "The Azure-AsyncOperation 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." + } } }, "default": { @@ -106,7 +178,11 @@ "ExportTerraform": { "$ref": "./examples/ExportTerraform.json" } - } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation" + }, + "x-ms-long-running-operation": true } } }, @@ -203,7 +279,11 @@ "azurerm", "azapi" ], - "default": "azurerm" + "default": "azurerm", + "x-ms-enum": { + "name": "targetProvider", + "modelAsString": true + } }, "fullProperties": { "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", @@ -257,6 +337,49 @@ "x-ms-identifiers": [] } } + }, + "OperationStatus": { + "description": "The status of the LRO operation.", + "type": "object", + "allOf": [ + { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" + } + ], + "properties": { + "id": { + "type": "string", + "description": "The operation status resource Id." + }, + "name": { + "type": "string", + "description": "The operation name." + }, + "startTime": { + "type": "string", + "description": "The start time of the operation.", + "format": "date-time", + "readOnly": true + }, + "endTime": { + "type": "string", + "description": "The end time of the operation.", + "format": "date-time", + "readOnly": true + }, + "status": { + "type": "string", + "description": "The status of the operation." + }, + "percentComplete": { + "description": "The progress percentage of the operation, ranges from 0 to 100", + "type": "number", + "format": "double" + }, + "properties": { + "$ref": "#/definitions/ExportResult" + } + } } }, "parameters": { diff --git a/specification/terraform/resource-manager/readme.go.md b/specification/terraform/resource-manager/readme.go.md new file mode 100644 index 000000000000..33ea79404bdd --- /dev/null +++ b/specification/terraform/resource-manager/readme.go.md @@ -0,0 +1,11 @@ +## Go + +These settings apply only when `--go` is specified on the command line. + +```yaml $(go) && $(track2) +azure-arm: true +license-header: MICROSOFT_MIT_NO_VERSION +module-name: sdk/resourcemanager/terraform/armterraform +module: github.com/Azure/azure-sdk-for-go/$(module-name) +output-folder: $(go-sdk-folder)/$(module-name) +``` diff --git a/specification/terraform/resource-manager/readme.md b/specification/terraform/resource-manager/readme.md index 6b21e382c0d3..ef864856633b 100644 --- a/specification/terraform/resource-manager/readme.md +++ b/specification/terraform/resource-manager/readme.md @@ -29,7 +29,7 @@ title: AzureTerraformManagementClient description: AzureTerraform Client openapi-type: arm openapi-subtype: providerHub -tag: package-2023-07 +tag: package-2023-07-01-preview ``` diff --git a/specification/terraform/suppressions.yaml b/specification/terraform/suppressions.yaml new file mode 100644 index 000000000000..34ff898d3f10 --- /dev/null +++ b/specification/terraform/suppressions.yaml @@ -0,0 +1,3 @@ +- tool: TypeSpecRequirement + path: resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/**/*.json + reason: AzureTerraform service was onboarded before TypeSpec is required. We are bypassing the TypeSpec requirement for development, while will be supporting it in the public swagger repo. From 782510df688b67832b1d0a01a3a51c6e27edc4a4 Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 19 Jul 2024 17:02:29 +0800 Subject: [PATCH 14/22] AzureTerrform: Remove the parallelism property (#18909) --- .../preview/2023-07-01-preview/export.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index a4ce93940a4c..edba799f209d 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -289,12 +289,6 @@ "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", "type": "boolean", "default": false - }, - "parallelism": { - "description": " Limit the number of parallel operations, i.e., resource discovery, import", - "type": "integer", - "format": "int64", - "default": 10 } }, "type": "object" From fa992edc8c574bcd9f0f61f5627aa87c0ebee36d Mon Sep 17 00:00:00 2001 From: magodo Date: Wed, 14 Aug 2024 10:42:04 +0800 Subject: [PATCH 15/22] exportTerraform: Change resourceId -> resourceIds; Add `maskSensitive`; Change `fullConfig` defaults (#19178) * exportTerraform: Change resourceId -> resourceIds; Add `maskSensitive`; Change `fullConfig` defaults * rename * rename * rename --- .../examples/ExportTerraform.json | 2 +- .../preview/2023-07-01-preview/export.json | 55 ++++++++++++------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json index 4029ff48714d..18621ce01c36 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ExportTerraform.json @@ -5,7 +5,7 @@ "api-version": "2023-07-01-preview", "subscriptionId": "00000000-0000-0000-0000-000000000000", "exportParameter": { - "type": "ExportResourceGroupParameter", + "type": "ExportResourceGroup", "resourceGroupName": "rg1" } }, diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index edba799f209d..837a9114c4b3 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -187,33 +187,45 @@ } }, "definitions": { - "ExportResourceParameter": { + "ExportResource": { "allOf": [ { - "$ref": "#/definitions/BaseExportParameter" + "$ref": "#/definitions/BaseExportModel" } ], "description": "Export parameter for a single resource", "required": [ - "resourceId" + "resourceIds" ], "properties": { - "resourceId": { + "resourceIds": { "description": "The id of the resource to be exported", - "type": "string" + "type": "array", + "items": { + "type": "string" + } }, - "name": { - "description": "The Terraform resource name", + "resourceName": { + "description": "The Terraform resource name. Only works when `resourceIds` contains only one item.", "type": "string", "default": "res-0" + }, + "resourceType": { + "description": "The Terraform resource type. Only works when `resourceIds` contains only one item.", + "type": "string" + }, + "namePattern": { + "description": "The name pattern of the Terraform resources", + "type": "string", + "default": "res-" } }, "type": "object" }, - "ExportResourceGroupParameter": { + "ExportResourceGroup": { "allOf": [ { - "$ref": "#/definitions/BaseExportParameter" + "$ref": "#/definitions/BaseExportModel" } ], "description": "Export parameter for a resource group", @@ -226,17 +238,17 @@ "type": "string" }, "namePattern": { - "description": "The pattern of the Terraform resources", + "description": "The name pattern of the Terraform resources", "type": "string", "default": "res-" } }, "type": "object" }, - "ExportQueryParameter": { + "ExportQuery": { "allOf": [ { - "$ref": "#/definitions/BaseExportParameter" + "$ref": "#/definitions/BaseExportModel" } ], "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", @@ -249,7 +261,7 @@ "type": "string" }, "namePattern": { - "description": "The pattern of the Terraform resources", + "description": "The name pattern of the Terraform resources", "type": "string", "default": "res-" }, @@ -261,7 +273,7 @@ }, "type": "object" }, - "BaseExportParameter": { + "BaseExportModel": { "description": "The base export parameter", "discriminator": "type", "required": [ @@ -288,7 +300,12 @@ "fullProperties": { "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", "type": "boolean", - "default": false + "default": true + }, + "maskSensitive": { + "description": "Mask sensitive attributes in the Terraform configuration", + "type": "boolean", + "default": true } }, "type": "object" @@ -297,9 +314,9 @@ "description": "The parameter type", "type": "string", "enum": [ - "ExportResourceParameter", - "ExportResourceGroupParameter", - "ExportQueryParameter" + "ExportResource", + "ExportResourceGroup", + "ExportQuery" ], "x-ms-enum": { "name": "parameterType", @@ -383,7 +400,7 @@ "name": "exportParameter", "required": true, "schema": { - "$ref": "#/definitions/BaseExportParameter" + "$ref": "#/definitions/BaseExportModel" }, "x-ms-parameter-location": "method" } From 0acb1ac16aecd773bc5737e52755affc2ae49d54 Mon Sep 17 00:00:00 2001 From: magodo Date: Fri, 30 Aug 2024 20:28:45 +0800 Subject: [PATCH 16/22] Specify LRO model (#19401) --- .../preview/2023-07-01-preview/export.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 837a9114c4b3..f6f8d6132cf0 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -180,7 +180,8 @@ } }, "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation" + "final-state-via": "azure-async-operation", + "final-state-schema": "#/definitions/OperationStatus" }, "x-ms-long-running-operation": true } @@ -405,4 +406,4 @@ "x-ms-parameter-location": "method" } } -} +} \ No newline at end of file From f02db184d825eff89254146b5a15511996cf28dd Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 5 Sep 2024 11:01:29 +0800 Subject: [PATCH 17/22] Add up the `resourceId` in `OperationStatus` model (#19450) --- .../preview/2023-07-01-preview/export.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index f6f8d6132cf0..869ce1d4c7b6 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -136,7 +136,7 @@ "ExportTerraform" ], "operationId": "ExportTerraform", - "description": "Exports the Terraform configuration used for the specified scope.", + "description": "Exports the Terraform configuration of the specified resources.", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" @@ -194,7 +194,7 @@ "$ref": "#/definitions/BaseExportModel" } ], - "description": "Export parameter for a single resource", + "description": "Export parameter for individual resources", "required": [ "resourceIds" ], @@ -367,6 +367,11 @@ "type": "string", "description": "The operation name." }, + "resourceId": { + "type": "string", + "description": "The fully qualified resource ID of the resource for which the operation was performed", + "readOnly": true + }, "startTime": { "type": "string", "description": "The start time of the operation.", From d2b1a69bf22ea3fe18d845c785915918cffbe485 Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 5 Sep 2024 19:05:02 +0800 Subject: [PATCH 18/22] Add `uri` format (#19455) * Add format url * update --- .../preview/2023-07-01-preview/export.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 869ce1d4c7b6..6efa30df93b6 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -109,6 +109,7 @@ }, "Azure-AsyncOperation": { "type": "string", + "format": "uri", "description": "The Azure-AsyncOperation header contains the URL where the status of the long running operation can be checked." }, "Retry-After": { @@ -158,6 +159,7 @@ }, "Azure-AsyncOperation": { "type": "string", + "format": "uri", "description": "The Azure-AsyncOperation header contains the URL where the status of the long running operation can be checked." }, "Retry-After": { From 323d870c0dc1659a1294fa67b757bee6107509f2 Mon Sep 17 00:00:00 2001 From: Gerry Tan Date: Fri, 6 Sep 2024 16:14:34 +1000 Subject: [PATCH 19/22] TypeSpec for Microsoft.AzureTerraform (#19390) * TypeSpec for Microsoft.AzureTerraform * Sorted swagger file, and added typespec generated with tsp-client * revert export.json in prep of merging * Sorted export.json for easy diff on future typespec -> swagger * Rerun swagger -> typespec conversion after merging latest RPSaaSMaster, updated namespace * tsp compile for TypeSpec -> swagger * Refactored typescript to minimise swagger diff * Spread ErrorResponse into OperationStatus model * Fixed enums, use doc decorator * Update exportTerraform path desc * Update doc for ExportResource model * LintDiff fix: remove unnecessary auth * Add resourceId prop to OperationStatus model, fixed char casing so they're consistent throughout * Made resourceId read only * Check `Swagger BreakingChange`: minimise diff on x-ms-enum * TypeSpec Validation fix: rename dir and add missing @doc --- specification/terraform/.gitignore | 2 + .../2023-07-01-preview/ExportTerraform.json | 20 + .../GetOperationStatus.json | 38 ++ .../2023-07-01-preview/ListOperations.json | 34 ++ .../main.tsp | 36 ++ .../models.tsp | 160 +++++++ .../routes.tsp | 52 +++ .../tspconfig.yaml | 13 + .../examples/GetOperationStatus.json | 2 + .../examples/ListOperations.json | 2 +- .../preview/2023-07-01-preview/export.json | 398 +++++++++--------- 11 files changed, 564 insertions(+), 193 deletions(-) create mode 100644 specification/terraform/.gitignore create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ExportTerraform.json create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/GetOperationStatus.json create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ListOperations.json create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/main.tsp create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/models.tsp create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp create mode 100644 specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml diff --git a/specification/terraform/.gitignore b/specification/terraform/.gitignore new file mode 100644 index 000000000000..0ef53867b2ff --- /dev/null +++ b/specification/terraform/.gitignore @@ -0,0 +1,2 @@ +# Override the **/terraform/** rule set at the top level to avoid relevant files getting ignored +!**/*.json \ No newline at end of file diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ExportTerraform.json b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ExportTerraform.json new file mode 100644 index 000000000000..18621ce01c36 --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ExportTerraform.json @@ -0,0 +1,20 @@ +{ + "title": "ExportTerraform", + "operationId": "ExportTerraform", + "parameters": { + "api-version": "2023-07-01-preview", + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "exportParameter": { + "type": "ExportResourceGroup", + "resourceGroupName": "rg1" + } + }, + "responses": { + "202": { + "headers": { + "Azure-AsyncOperation": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview" + } + } + } +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/GetOperationStatus.json b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/GetOperationStatus.json new file mode 100644 index 000000000000..3291480e533b --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/GetOperationStatus.json @@ -0,0 +1,38 @@ +{ + "title": "Get specific operation status", + "operationId": "OperationStatuses_Get", + "parameters": { + "subscriptionId": "00000000-0000-0000-0000-000000000000", + "operationId": "00000000-0000-0000-0000-000000000000", + "api-version": "2023-07-01-preview" + }, + "responses": { + "200": { + "headers": {}, + "body": { + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "name": "00000000-0000-0000-0000-000000000000", + "startTime": "2024-07-08T08:48:46.3160075Z", + "endTime": "2024-07-08T08:49:23.7083Z", + "status": "Succeeded", + "properties": { + "configuration": "resource \"azurerm_resource_group\" \"res-0\" {\n location = \"westeurope\"\n name = \"rg1\"\n}", + "errors": null, + "skippedResources": null + } + } + }, + "202": { + "headers": { + "Azure-AsyncOperation": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview" + }, + "body": { + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzureTerraform/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2023-07-01-preview", + "name": "00000000-0000-0000-0000-000000000000", + "startTime": "2024-07-08T08:48:46.3160075Z", + "status": "InProgress" + } + } + } +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ListOperations.json b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ListOperations.json new file mode 100644 index 000000000000..909d21b67905 --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/examples/2023-07-01-preview/ListOperations.json @@ -0,0 +1,34 @@ +{ + "title": "Get a list of operations for a resource provider", + "operationId": "Operations_List", + "parameters": { + "subscriptionId": "12345678-1234-1234-12345678abc", + "api-version": "2023-07-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Microsoft.AzureTerraform/operations/read", + "display": { + "provider": "Microsoft AzureTerraform", + "resource": "Azure Terraform Resource Provider", + "operation": "ListOperations", + "description": "Lists all of the available RP operations." + } + }, + { + "name": "Microsoft.AzureTerraform/exportTerraform/action", + "display": { + "provider": "Microsoft AzureTerraform", + "resource": "Azure Terraform Resource Provider", + "operation": "ExportTerraform", + "description": "Exports the Terraform configuration used for the specified scope." + } + } + ] + } + } + } +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/main.tsp b/specification/terraform/Microsoft.AzureTerraform.Management/main.tsp new file mode 100644 index 000000000000..59725fbd66a4 --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/main.tsp @@ -0,0 +1,36 @@ +/** + * PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS + * Generated by package: @autorest/openapi-to-typespec + * Version: 0.9.0 + * Date: 2024-08-30T14:24:13.436Z + */ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "./models.tsp"; +import "./routes.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager.Foundations; +using Azure.Core; +using Azure.ResourceManager; +using TypeSpec.Versioning; + +@doc("The Azure Terraform management API provides a RESTful set of web services that used to manage your Azure Terraform resources.") +@armProviderNamespace +@service({ + title: "AzureTerraformResourceProviderClient", +}) +@versioned(Versions) +@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) +namespace Microsoft.AzureTerraform; + +@doc("The available API versions.") +enum Versions { + @doc("The 2023-07-01-preview API version.") + @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) + @useDependency(Azure.Core.Versions.v1_0_Preview_1) + v2023_07_01_preview: "2023-07-01-preview", +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp b/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp new file mode 100644 index 000000000000..d6af33f7f30c --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp @@ -0,0 +1,160 @@ +import "@typespec/rest"; +import "@typespec/http"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +namespace Microsoft.AzureTerraform; + +interface Operations extends Azure.ResourceManager.Operations {} + +@doc("The parameter type") +@extension( + "x-ms-enum", + { + name: "parameterType", + modelAsString: true, + } +) +union Type { + string, + ExportResource: "ExportResource", + ExportResourceGroup: "ExportResourceGroup", + ExportQuery: "ExportQuery", +} + +@doc("The target Azure Terraform Provider") +@extension( + "x-ms-enum", + { + name: "targetProvider", + modelAsString: true, + } +) +union targetProvider { + string, + + @doc("https://registry.terraform.io/providers/hashicorp/azurerm/latest") + azurerm: "azurerm", + + @doc("https://registry.terraform.io/providers/Azure/azapi/latest") + azapi: "azapi", +} + +@doc("The base export parameter") +@discriminator("type") +model BaseExportModel { + @doc("The parameter type") + type: Type; + + @doc("The target Azure Terraform Provider") + targetProvider?: targetProvider = targetProvider.azurerm; + + @doc("Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid") + fullProperties?: boolean = true; + + @doc("Mask sensitive attributes in the Terraform configuration") + maskSensitive?: boolean = true; +} + +@doc("Export parameter for resources queried by ARG (Azure Resource Graph)") +model ExportQuery extends BaseExportModel { + @doc("The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`") + query: string; + + @doc("The name pattern of the Terraform resources") + namePattern?: string = "res-"; + + @doc("Whether to recursively list child resources of the query result") + recursive?: boolean = false; + + @doc("The parameter type") + type: "ExportQuery"; +} + +@doc("Export parameter for individual resources.") +model ExportResource extends BaseExportModel { + @doc("The id of the resource to be exported") + resourceIds: string[]; + + @doc("The Terraform resource name. Only works when `resourceIds` contains only one item.") + resourceName?: string = "res-0"; + + @doc("The Terraform resource type. Only works when `resourceIds` contains only one item.") + resourceType?: string; + + @doc("The name pattern of the Terraform resources") + namePattern?: string = "res-"; + + @doc("The parameter type") + type: "ExportResource"; +} + +@doc("Export parameter for a resource group") +model ExportResourceGroup extends BaseExportModel { + @doc("The name of the resource group to be exported") + resourceGroupName: string; + + @doc("The name pattern of the Terraform resources") + namePattern?: string = "res-"; + + @doc("The parameter type") + type: "ExportResourceGroup"; +} + +@doc("The status of the LRO operation.") +model OperationStatus { + @doc("The operation status resource id.") + id?: string; + + @doc("The fully qualified resource id of the resource for which the operation was performed.") + @visibility("read") + resourceId?: string; + + @doc("The operation name.") + name?: string; + + @doc("The start time of the operation.") + @visibility("read") + startTime?: utcDateTime; + + @doc("The end time of the operation.") + @visibility("read") + endTime?: utcDateTime; + + @doc("The status of the operation.") + status?: string; + + @doc("The progress percentage of the operation, ranges from 0 to 100") + percentComplete?: float64; + + @doc("The Terraform export result") + properties?: ExportResult; + + ...ErrorResponse; +} + +model InProgressOperationStatus + is ArmAcceptedResponse< + "InProgress operation status", + ArmCombinedLroHeaders & Azure.Core.Foundations.RetryAfterHeader + > { + ...OperationStatus; +} + +@doc("The Terraform export result") +model ExportResult { + @doc("The Terraform configuration content") + configuration?: string; + + @doc("A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform") + skippedResources?: string[]; + + @doc("A list of errors derived during exporting each resource") + @extension("x-ms-identifiers", []) + errors?: ErrorDetail[]; +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp b/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp new file mode 100644 index 000000000000..189c3ad0d109 --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp @@ -0,0 +1,52 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "./models.tsp"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; +using OpenAPI; + +namespace Microsoft.AzureTerraform; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "Cannot use @armResourceOperations decorator here, the auto-generated routes do not match feature requirements" +@doc("Exports the Terraform configuration of the specified resource(s).") +@route("/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform") +@post +@tag("ExportTerraform") +@extension( + "x-ms-long-running-operation-options", + { + `final-state-via`: "azure-async-operation", + `final-state-schema`: "#/definitions/OperationStatus", + } +) +op exportTerraform( + ...ApiVersionParameter, + ...SubscriptionIdParameter, + + @doc("The export parameter") + @body + @extension("x-ms-parameter-location", "method") + exportParameter: BaseExportModel, +): ArmAcceptedLroResponse< + "Export request accepted.", + ArmCombinedLroHeaders & Azure.Core.Foundations.RetryAfterHeader +> | ErrorResponse; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" "Cannot use @armResourceOperations decorator here, the auto-generated routes do not match feature requirements" +interface OperationStatuses { + #suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Body of 202 is not empty: not compatible with API requirements" + @doc("Get the status of a long running azure asynchronous operation.") + @route("/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/operationStatuses/{operationId}") + @get + @tag("OperationStatuses") + @armResourceRead(ArmResponse) + get( + ...OperationIdParameter, + ...ApiVersionParameter, + ...SubscriptionIdParameter, + ): OperationStatus | InProgressOperationStatus | ErrorResponse; +} diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml b/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml new file mode 100644 index 000000000000..d2b9d8be7ef9 --- /dev/null +++ b/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml @@ -0,0 +1,13 @@ +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + use-read-only-status-schema: true + omit-unreachable-types: true + emitter-output-dir: "{project-root}/.." + azure-resource-provider-folder: "resource-manager" + output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/export.json" + examples-directory: "{project-root}/examples" +linter: + extends: + - "@azure-tools/typespec-azure-rulesets/resource-manager" diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json index ca03505b1edc..3291480e533b 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/GetOperationStatus.json @@ -1,4 +1,6 @@ { + "title": "Get specific operation status", + "operationId": "OperationStatuses_Get", "parameters": { "subscriptionId": "00000000-0000-0000-0000-000000000000", "operationId": "00000000-0000-0000-0000-000000000000", diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json index a6b59fe985fe..909d21b67905 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/examples/ListOperations.json @@ -1,5 +1,5 @@ { - "title": "List Operations", + "title": "Get a list of operations for a resource provider", "operationId": "Operations_List", "parameters": { "subscriptionId": "12345678-1234-1234-12345678abc", diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 6efa30df93b6..1d38b0e44f14 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -2,17 +2,22 @@ "swagger": "2.0", "info": { "title": "AzureTerraformResourceProviderClient", + "version": "2023-07-01-preview", "description": "The Azure Terraform management API provides a RESTful set of web services that used to manage your Azure Terraform resources.", - "version": "2023-07-01-preview" + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] }, - "host": "management.azure.com", "schemes": [ "https" ], - "consumes": [ + "host": "management.azure.com", + "produces": [ "application/json" ], - "produces": [ + "consumes": [ "application/json" ], "security": [ @@ -25,22 +30,33 @@ "securityDefinitions": { "azure_auth": { "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "description": "Azure Active Directory OAuth2 Flow.", "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", "scopes": { "user_impersonation": "impersonate your user account" } } }, + "tags": [ + { + "name": "ExportTerraform" + }, + { + "name": "Operations" + }, + { + "name": "OperationStatuses" + } + ], "paths": { "/providers/Microsoft.AzureTerraform/operations": { "get": { + "operationId": "Operations_List", "tags": [ "Operations" ], - "description": "Lists all of the available RP operations.", - "operationId": "Operations_List", + "description": "List the operations for the provider", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" @@ -48,119 +64,131 @@ ], "responses": { "200": { - "description": "OK. The request has succeeded.", + "description": "Azure operation completed successfully.", "schema": { "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/OperationListResult" } }, "default": { - "description": "Resource Provider error response describing why the operation failed.", + "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - }, "x-ms-examples": { "Get a list of operations for a resource provider": { "$ref": "./examples/ListOperations.json" } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" } } }, - "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/operationStatuses/{operationId}": { - "get": { - "x-ms-examples": { - "Get specific operation status": { - "$ref": "./examples/GetOperationStatus.json" - } - }, + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { + "post": { + "operationId": "ExportTerraform", "tags": [ - "OperationStatuses" + "ExportTerraform" ], - "operationId": "OperationStatuses_Get", - "description": "Get the status of a long running azure asynchronous operation.", + "description": "Exports the Terraform configuration of the specified resource(s).", "parameters": [ - { - "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/OperationIdParameter" - }, { "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" }, { "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter" + }, + { + "name": "exportParameter", + "in": "body", + "description": "The export parameter", + "required": true, + "schema": { + "$ref": "#/definitions/BaseExportModel" + }, + "x-ms-parameter-location": "method" } ], "responses": { - "200": { - "description": "Finalized operation status.", - "schema": { - "$ref": "#/definitions/OperationStatus" - } - }, "202": { - "description": "InProgress operation status.", + "description": "Export request accepted.", "headers": { - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." - }, "Azure-AsyncOperation": { "type": "string", "format": "uri", - "description": "The Azure-AsyncOperation header contains the URL where the status of the long running operation can be checked." + "description": "A link to the status monitor" + }, + "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." } - }, - "schema": { - "$ref": "#/definitions/OperationStatus" } }, "default": { - "description": "Error response returned if request was unsuccessful.", + "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } - } + }, + "x-ms-examples": { + "ExportTerraform": { + "$ref": "./examples/ExportTerraform.json" + } + }, + "x-ms-long-running-operation-options": { + "final-state-via": "azure-async-operation", + "final-state-schema": "#/definitions/OperationStatus" + }, + "x-ms-long-running-operation": true } }, - "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform": { - "post": { + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/operationStatuses/{operationId}": { + "get": { + "operationId": "OperationStatuses_Get", "tags": [ - "ExportTerraform" + "OperationStatuses" ], - "operationId": "ExportTerraform", - "description": "Exports the Terraform configuration of the specified resources.", + "description": "Get the status of a long running azure asynchronous operation.", "parameters": [ { - "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/OperationIdParameter" }, { - "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "#/parameters/ExportParameter" + "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/SubscriptionIdParameter" } ], "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/OperationStatus" + } + }, "202": { - "description": "Export request accepted.", + "description": "The request has been accepted for processing, but processing has not yet completed.", + "schema": { + "$ref": "#/definitions/OperationStatus" + }, "headers": { - "Location": { - "type": "string", - "description": "The Location header contains the URL where the status of the long running operation can be checked." - }, "Azure-AsyncOperation": { "type": "string", "format": "uri", - "description": "The Azure-AsyncOperation header contains the URL where the status of the long running operation can be checked." + "description": "A link to the status monitor" + }, + "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", @@ -170,161 +198,146 @@ } }, "default": { - "description": "Error response describing why the operation failed.", + "description": "An unexpected error response.", "schema": { "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" } } }, "x-ms-examples": { - "ExportTerraform": { - "$ref": "./examples/ExportTerraform.json" + "Get specific operation status": { + "$ref": "./examples/GetOperationStatus.json" } - }, - "x-ms-long-running-operation-options": { - "final-state-via": "azure-async-operation", - "final-state-schema": "#/definitions/OperationStatus" - }, - "x-ms-long-running-operation": true + } } } }, "definitions": { - "ExportResource": { + "BaseExportModel": { + "type": "object", + "description": "The base export parameter", + "properties": { + "type": { + "$ref": "#/definitions/Type", + "description": "The parameter type" + }, + "targetProvider": { + "type": "string", + "description": "The target Azure Terraform Provider", + "default": "azurerm", + "enum": [ + "azurerm", + "azapi" + ], + "x-ms-enum": { + "name": "targetProvider", + "modelAsString": true + } + }, + "fullProperties": { + "type": "boolean", + "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", + "default": true + }, + "maskSensitive": { + "type": "boolean", + "description": "Mask sensitive attributes in the Terraform configuration", + "default": true + } + }, + "discriminator": "type", + "required": [ + "type" + ] + }, + "ExportQuery": { + "type": "object", + "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", + "properties": { + "query": { + "type": "string", + "description": "The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`" + }, + "namePattern": { + "type": "string", + "description": "The name pattern of the Terraform resources", + "default": "res-" + }, + "recursive": { + "type": "boolean", + "description": "Whether to recursively list child resources of the query result", + "default": false + } + }, + "required": [ + "query" + ], "allOf": [ { "$ref": "#/definitions/BaseExportModel" } ], - "description": "Export parameter for individual resources", - "required": [ - "resourceIds" - ], + "x-ms-discriminator-value": "ExportQuery" + }, + "ExportResource": { + "type": "object", + "description": "Export parameter for individual resources.", "properties": { "resourceIds": { - "description": "The id of the resource to be exported", "type": "array", + "description": "The id of the resource to be exported", "items": { "type": "string" } }, "resourceName": { - "description": "The Terraform resource name. Only works when `resourceIds` contains only one item.", "type": "string", + "description": "The Terraform resource name. Only works when `resourceIds` contains only one item.", "default": "res-0" }, "resourceType": { - "description": "The Terraform resource type. Only works when `resourceIds` contains only one item.", - "type": "string" + "type": "string", + "description": "The Terraform resource type. Only works when `resourceIds` contains only one item." }, "namePattern": { - "description": "The name pattern of the Terraform resources", "type": "string", + "description": "The name pattern of the Terraform resources", "default": "res-" } }, - "type": "object" - }, - "ExportResourceGroup": { + "required": [ + "resourceIds" + ], "allOf": [ { "$ref": "#/definitions/BaseExportModel" } ], + "x-ms-discriminator-value": "ExportResource" + }, + "ExportResourceGroup": { + "type": "object", "description": "Export parameter for a resource group", - "required": [ - "resourceGroupName" - ], "properties": { "resourceGroupName": { - "description": "The name of the resource group to be exported", - "type": "string" - }, - "namePattern": { - "description": "The name pattern of the Terraform resources", "type": "string", - "default": "res-" - } - }, - "type": "object" - }, - "ExportQuery": { - "allOf": [ - { - "$ref": "#/definitions/BaseExportModel" - } - ], - "description": "Export parameter for resources queried by ARG (Azure Resource Graph)", - "required": [ - "query" - ], - "properties": { - "query": { - "description": "The ARG where predicate. Note that you can combine multiple conditions in one `where` predicate, e.g. `resourceGroup =~ \"my-rg\" and type =~ \"microsoft.network/virtualnetworks\"`", - "type": "string" + "description": "The name of the resource group to be exported" }, "namePattern": { - "description": "The name pattern of the Terraform resources", "type": "string", + "description": "The name pattern of the Terraform resources", "default": "res-" - }, - "recursive": { - "description": "Whether to recursively list child resources of the query result", - "type": "boolean", - "default": false } }, - "type": "object" - }, - "BaseExportModel": { - "description": "The base export parameter", - "discriminator": "type", "required": [ - "type" + "resourceGroupName" ], - "properties": { - "type": { - "$ref": "#/definitions/Type", - "description": "The parameter type" - }, - "targetProvider": { - "description": "The target Azure Terraform Provider", - "type": "string", - "enum": [ - "azurerm", - "azapi" - ], - "default": "azurerm", - "x-ms-enum": { - "name": "targetProvider", - "modelAsString": true - } - }, - "fullProperties": { - "description": "Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid", - "type": "boolean", - "default": true - }, - "maskSensitive": { - "description": "Mask sensitive attributes in the Terraform configuration", - "type": "boolean", - "default": true + "allOf": [ + { + "$ref": "#/definitions/BaseExportModel" } - }, - "type": "object" - }, - "Type": { - "description": "The parameter type", - "type": "string", - "enum": [ - "ExportResource", - "ExportResourceGroup", - "ExportQuery" ], - "x-ms-enum": { - "name": "parameterType", - "modelAsString": true - } + "x-ms-discriminator-value": "ExportResourceGroup" }, "ExportResult": { "type": "object", @@ -335,17 +348,16 @@ "description": "The Terraform configuration content" }, "skippedResources": { - "description": "A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform", "type": "array", + "description": "A list of Azure resources which are not exported to Terraform due to there is no corresponding resources in Terraform", "items": { "type": "string" } }, "errors": { - "description": "A list of errors derived during exporting each resource", "type": "array", + "description": "A list of errors derived during exporting each resource", "items": { - "type": "object", "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorDetail" }, "x-ms-identifiers": [] @@ -353,37 +365,32 @@ } }, "OperationStatus": { - "description": "The status of the LRO operation.", "type": "object", - "allOf": [ - { - "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorResponse" - } - ], + "description": "The status of the LRO operation.", "properties": { "id": { "type": "string", - "description": "The operation status resource Id." - }, - "name": { - "type": "string", - "description": "The operation name." + "description": "The operation status resource id." }, "resourceId": { "type": "string", - "description": "The fully qualified resource ID of the resource for which the operation was performed", + "description": "The fully qualified resource id of the resource for which the operation was performed.", "readOnly": true }, + "name": { + "type": "string", + "description": "The operation name." + }, "startTime": { "type": "string", - "description": "The start time of the operation.", "format": "date-time", + "description": "The start time of the operation.", "readOnly": true }, "endTime": { "type": "string", - "description": "The end time of the operation.", "format": "date-time", + "description": "The end time of the operation.", "readOnly": true }, "status": { @@ -391,26 +398,33 @@ "description": "The status of the operation." }, "percentComplete": { - "description": "The progress percentage of the operation, ranges from 0 to 100", "type": "number", - "format": "double" + "format": "double", + "description": "The progress percentage of the operation, ranges from 0 to 100" }, "properties": { - "$ref": "#/definitions/ExportResult" + "$ref": "#/definitions/ExportResult", + "description": "The Terraform export result" + }, + "error": { + "$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ErrorDetail", + "description": "The error object." } } + }, + "Type": { + "type": "string", + "description": "The parameter type", + "enum": [ + "ExportResource", + "ExportResourceGroup", + "ExportQuery" + ], + "x-ms-enum": { + "name": "parameterType", + "modelAsString": true + } } }, - "parameters": { - "ExportParameter": { - "description": "The export parameter", - "in": "body", - "name": "exportParameter", - "required": true, - "schema": { - "$ref": "#/definitions/BaseExportModel" - }, - "x-ms-parameter-location": "method" - } - } -} \ No newline at end of file + "parameters": {} +} From 6759c0884209fe87d4e1027b0e4a963a2078a784 Mon Sep 17 00:00:00 2001 From: Gerry Tan Date: Thu, 19 Sep 2024 10:55:49 +1000 Subject: [PATCH 20/22] Upgrade/rp tsp 0.60 (#19551) -- applying only for specification/terraform --- .../models.tsp | 14 ------- .../routes.tsp | 2 +- .../tspconfig.yaml | 1 - .../preview/2023-07-01-preview/export.json | 37 ++++++++++++++++--- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp b/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp index d6af33f7f30c..797a3b91465a 100644 --- a/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp +++ b/specification/terraform/Microsoft.AzureTerraform.Management/models.tsp @@ -13,13 +13,6 @@ namespace Microsoft.AzureTerraform; interface Operations extends Azure.ResourceManager.Operations {} @doc("The parameter type") -@extension( - "x-ms-enum", - { - name: "parameterType", - modelAsString: true, - } -) union Type { string, ExportResource: "ExportResource", @@ -28,13 +21,6 @@ union Type { } @doc("The target Azure Terraform Provider") -@extension( - "x-ms-enum", - { - name: "targetProvider", - modelAsString: true, - } -) union targetProvider { string, diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp b/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp index 189c3ad0d109..0416b149ef42 100644 --- a/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp +++ b/specification/terraform/Microsoft.AzureTerraform.Management/routes.tsp @@ -12,6 +12,7 @@ using OpenAPI; namespace Microsoft.AzureTerraform; #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-operation" "Cannot use @armResourceOperations decorator here, the auto-generated routes do not match feature requirements" +#suppress "@azure-tools/typespec-azure-core/no-openapi" "TODO: migrate to LRO concepts DO NOT USE x-ms-long-running-operation-options" @doc("Exports the Terraform configuration of the specified resource(s).") @route("/subscriptions/{subscriptionId}/providers/Microsoft.AzureTerraform/exportTerraform") @post @@ -29,7 +30,6 @@ op exportTerraform( @doc("The export parameter") @body - @extension("x-ms-parameter-location", "method") exportParameter: BaseExportModel, ): ArmAcceptedLroResponse< "Export request accepted.", diff --git a/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml b/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml index d2b9d8be7ef9..2b37c676ebf5 100644 --- a/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml +++ b/specification/terraform/Microsoft.AzureTerraform.Management/tspconfig.yaml @@ -7,7 +7,6 @@ options: emitter-output-dir: "{project-root}/.." azure-resource-provider-folder: "resource-manager" output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/export.json" - examples-directory: "{project-root}/examples" linter: extends: - "@azure-tools/typespec-azure-rulesets/resource-manager" diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json index 1d38b0e44f14..0f610b1f872a 100644 --- a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/export.json @@ -107,8 +107,7 @@ "required": true, "schema": { "$ref": "#/definitions/BaseExportModel" - }, - "x-ms-parameter-location": "method" + } } ], "responses": { @@ -176,7 +175,7 @@ } }, "202": { - "description": "The request has been accepted for processing, but processing has not yet completed.", + "description": "InProgress operation status", "schema": { "$ref": "#/definitions/OperationStatus" }, @@ -231,7 +230,19 @@ ], "x-ms-enum": { "name": "targetProvider", - "modelAsString": true + "modelAsString": true, + "values": [ + { + "name": "azurerm", + "value": "azurerm", + "description": "https://registry.terraform.io/providers/hashicorp/azurerm/latest" + }, + { + "name": "azapi", + "value": "azapi", + "description": "https://registry.terraform.io/providers/Azure/azapi/latest" + } + ] } }, "fullProperties": { @@ -421,8 +432,22 @@ "ExportQuery" ], "x-ms-enum": { - "name": "parameterType", - "modelAsString": true + "name": "Type", + "modelAsString": true, + "values": [ + { + "name": "ExportResource", + "value": "ExportResource" + }, + { + "name": "ExportResourceGroup", + "value": "ExportResourceGroup" + }, + { + "name": "ExportQuery", + "value": "ExportQuery" + } + ] } } }, From c9af35b1496e1e0a9474753dccd2edf2ef107ac6 Mon Sep 17 00:00:00 2001 From: Gerry Tan Date: Thu, 19 Sep 2024 11:03:47 +1000 Subject: [PATCH 21/22] Revert accidental changes to cSpell.json while merging --- cSpell.json | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cSpell.json b/cSpell.json index 894ba11fece2..bb92a1426a69 100644 --- a/cSpell.json +++ b/cSpell.json @@ -150,12 +150,12 @@ ] }, { - "filename": "**/specification/billing/**/*.json", - "words": [ - "mosp", - "resellee", - "cnpj" - ] + "filename": "**/specification/billing/**/*.json", + "words": [ + "mosp", + "resellee", + "cnpj" + ] }, { "filename": "**/specification/compute/resource-manager/Microsoft.ContainerService/preview/2015-11-01-preview/containerService.json", @@ -311,32 +311,32 @@ "freemium" ] }, - { + { "filename": "**/specification/sql/resource-manager/Microsoft.Sql/preview/**/ManagedInstances.json", "words": [ "freemium" ] }, - { + { "filename": "**/specification/sql/resource-manager/Microsoft.Sql/preview/**/ServerTrustCertificates.json", "words": [ "freemium" ] }, - { + { "filename": "**/specification/sql/resource-manager/Microsoft.Sql/preview/**/ManagedInstanceDtcs.json", "words": [ "msdtcdns", "msdtc's" ] }, - { + { "filename": "**/specification/sql/resource-manager/Microsoft.Sql/preview/**/TimeZones.json", "words": [ "freemium" ] }, - { + { "filename": "**/specification/sql/resource-manager/Microsoft.Sql/preview/**/ElasticPools.json", "words": [ "PRMS" @@ -1440,4 +1440,5 @@ "ignoreWords": [ "trafficcontrollerspec" ] + } From 5706484aaa31c5ea45e091a2efc1bb1dc1c84ae4 Mon Sep 17 00:00:00 2001 From: Gerry Tan Date: Thu, 19 Sep 2024 15:40:49 +1000 Subject: [PATCH 22/22] Added tf files used for armstrong testing --- .../Microsoft.AzureTerraform/main.tf | 120 ++++++++++++++++++ .../main.tf | 42 ++++++ 2 files changed, 162 insertions(+) create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform/main.tf create mode 100644 specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform_operations/main.tf diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform/main.tf b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform/main.tf new file mode 100644 index 000000000000..a9fca7f02bcb --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform/main.tf @@ -0,0 +1,120 @@ +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } +} + +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + key_vault { + purge_soft_delete_on_destroy = false + purge_soft_deleted_keys_on_destroy = false + } + } + subscription_id = jsondecode(data.azapi_resource.subscription.output).subscriptionId +} + +provider "azapi" { + skip_provider_registration = false +} + +variable "resource_name" { + type = string + default = "acctest5125" +} + +variable "location" { + type = string + default = "westeurope" +} + +data "azapi_resource" "subscription" { + type = "Microsoft.Resources/subscriptions@2020-06-01" + response_export_values = ["*"] +} + +data "azapi_resource_id" "subscriptionScopeProvider" { + type = "Microsoft.Resources/providers@2020-06-01" + parent_id = data.azapi_resource.subscription.id + name = "Microsoft.AzureTerraform" +} + +resource "azurerm_resource_group" "test_rg" { + name = "${var.resource_name}_rg" + location = var.location +} + +resource "azurerm_virtual_network" "test_vn" { + name = "${var.resource_name}_vn" + address_space = ["10.0.0.0/16"] + location = var.location + resource_group_name = azurerm_resource_group.test_rg.name +} + +resource "azapi_resource_action" "exportTerraform_ExportResourceGroup" { + type = "Microsoft.AzureTerraform@2023-07-01-preview" + resource_id = data.azapi_resource_id.subscriptionScopeProvider.id + action = "exportTerraform" + method = "POST" + body = { + type = "ExportResourceGroup" + targetProvider = "azurerm" + fullProperties = true + maskSensitive = true + resourceGroupName = azurerm_resource_group.test_rg.name + namePattern = "res-" + } +} + +resource "azapi_resource_action" "exportTerraform_ExportResource_1" { + type = "Microsoft.AzureTerraform@2023-07-01-preview" + resource_id = data.azapi_resource_id.subscriptionScopeProvider.id + action = "exportTerraform" + method = "POST" + body = { + type = "ExportResource" + targetProvider = "azurerm" + fullProperties = true + maskSensitive = true + resourceIds = [azurerm_virtual_network.test_vn.id] + resourceType = "azurerm_virtual_network" + resourceName = "res-0" + } +} + +resource "azapi_resource_action" "exportTerraform_ExportResource_2" { + type = "Microsoft.AzureTerraform@2023-07-01-preview" + resource_id = data.azapi_resource_id.subscriptionScopeProvider.id + action = "exportTerraform" + method = "POST" + body = { + type = "ExportResource" + targetProvider = "azurerm" + fullProperties = true + maskSensitive = true + resourceIds = [azurerm_resource_group.test_rg.id] + resourceType = "azurerm_virtual_network" + namePattern = "res-" + } +} + +resource "azapi_resource_action" "exportTerraform_ExportQuery" { + type = "Microsoft.AzureTerraform@2023-07-01-preview" + resource_id = data.azapi_resource_id.subscriptionScopeProvider.id + action = "exportTerraform" + method = "POST" + body = { + type = "ExportQuery" + targetProvider = "azurerm" + fullProperties = true + maskSensitive = true + query = "resourceGroup =~ \"${azurerm_resource_group.test_rg.name}\"" + namePattern = "res-" + recursive = false + } +} diff --git a/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform_operations/main.tf b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform_operations/main.tf new file mode 100644 index 000000000000..2d697258dabe --- /dev/null +++ b/specification/terraform/resource-manager/Microsoft.AzureTerraform/preview/2023-07-01-preview/terraform/Microsoft.AzureTerraform_operations/main.tf @@ -0,0 +1,42 @@ +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } +} + +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = false + } + key_vault { + purge_soft_delete_on_destroy = false + purge_soft_deleted_keys_on_destroy = false + } + } + skip_provider_registration = true +} + +provider "azapi" { + skip_provider_registration = false +} + +variable "resource_name" { + type = string + default = "acctest2547" +} + +variable "location" { + type = string + default = "westeurope" +} + +// OperationId: Operations_List +// GET /providers/Microsoft.AzureTerraform/operations +data "azapi_resource_list" "listOperationsByTenant" { + type = "Microsoft.AzureTerraform/operations@2023-07-01-preview" + parent_id = "/" +} +