Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6f3b652
New RP: Microsoft.AzureTerraform (ver=2023-07-01-preview)
magodo Jul 3, 2023
2d66db0
prettier
magodo Jul 3, 2023
0ccc732
remove x-ms-discriminator-value
magodo Jul 3, 2023
946a7b3
readme.md: add `openapi-subtype`
magodo Jul 3, 2023
00c3225
Fix LintDiff failure
magodo Jul 3, 2023
3024e9e
Result configuration type change from object to string
magodo Jul 14, 2023
864168b
Remove properties: `subscriptionId` and `environment`
magodo Jul 26, 2023
92ad096
Change `errors` from list of string to list of `ErrorResponse`
magodo Jul 26, 2023
df284ea
Add operations endpoint
magodo Aug 7, 2023
539d7f9
Update
magodo Aug 7, 2023
16d534e
Update
magodo Aug 7, 2023
2a93587
AzureTerraform RP: Sync the MS version with the private version
magodo Feb 22, 2024
6e52be1
Terraform: Change `exportEerraform` endpoint to LRO (#18782)
magodo Jul 12, 2024
782510d
AzureTerrform: Remove the parallelism property (#18909)
magodo Jul 19, 2024
fa992ed
exportTerraform: Change resourceId -> resourceIds; Add `maskSensitive…
magodo Aug 14, 2024
0acb1ac
Specify LRO model (#19401)
magodo Aug 30, 2024
f02db18
Add up the `resourceId` in `OperationStatus` model (#19450)
magodo Sep 5, 2024
d2b1a69
Add `uri` format (#19455)
magodo Sep 5, 2024
323d870
TypeSpec for Microsoft.AzureTerraform (#19390)
gerrytan Sep 6, 2024
6759c08
Upgrade/rp tsp 0.60 (#19551) -- applying only for specification/terra…
gerrytan Sep 19, 2024
fff5539
Merge branch 'main' into 29255627-typespec-for-Microsoft.AzureTerraform
gerrytan Sep 19, 2024
c9af35b
Revert accidental changes to cSpell.json while merging
gerrytan Sep 19, 2024
5706484
Added tf files used for armstrong testing
gerrytan Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,13 @@
"sfmc's"
]
},
{
"filename": "**/specification/terraform/resource-manager/Microsoft.AzureTerraform/**/*.json",
"words": [
"azurerm",
"azapi"
]
},
{
"filename": "**/specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/**/*.json",
"words": [
Expand Down
2 changes: 2 additions & 0 deletions specification/terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Override the **/terraform/** rule set at the top level to avoid relevant files getting ignored
!**/*.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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."
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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",
}
146 changes: 146 additions & 0 deletions specification/terraform/Microsoft.AzureTerraform.Management/models.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
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")
union Type {
string,
ExportResource: "ExportResource",
ExportResourceGroup: "ExportResourceGroup",
ExportQuery: "ExportQuery",
}

@doc("The target Azure Terraform Provider")
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[];
}
Original file line number Diff line number Diff line change
@@ -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"
#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
@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
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<OperationStatus>)
get(
...OperationIdParameter,
...ApiVersionParameter,
...SubscriptionIdParameter,
): OperationStatus | InProgressOperationStatus | ErrorResponse;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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"
linter:
extends:
- "@azure-tools/typespec-azure-rulesets/resource-manager"
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
Loading