-
Notifications
You must be signed in to change notification settings - Fork 5.5k
RecommenderRP TypeSpec Conversion for version 20250605 #36039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
2fecf94
816611c
42308ee
78aed1a
c933176
61b6c9f
c0c4b1a
055981d
ed41c7b
c66da6f
e6806ad
eedbd18
5172023
1a16c11
a08e32b
6c589eb
5819dd8
7b7d922
cfc05d2
478fdee
d6fc738
72310cb
aa54174
3624032
65e7ae7
de73fb0
bf28f18
eb0e718
7734bd3
5d32435
0f3ca9c
08bd8f5
425dac5
5d4c177
dc63870
dd10a77
fe2b398
6d02962
29d016e
deaad00
3a3e716
7781955
b261898
a8ec7f5
83dd219
6f05e4e
a3dc356
11f0535
c1d27d7
be9a4b4
332ee4b
ad5aeee
6054f4e
2022712
99d7620
f3359a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "@typespec/openapi"; | ||
| import "@typespec/rest"; | ||
| import "./models.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.OpenAPI; | ||
|
|
||
| namespace Microsoft.Compute; | ||
| /** | ||
| * Contains metadata of a diagnostic type | ||
| */ | ||
| @singleton("spot") | ||
| @subscriptionResource | ||
| @parentResource(SubscriptionLocationResource) | ||
| model ComputeDiagnosticBase | ||
| is Azure.ResourceManager.ProxyResource<DiagnosticProperties> { | ||
| ...ResourceNameParameter< | ||
| Resource = ComputeDiagnosticBase, | ||
| KeyName = "placementScore", | ||
| SegmentName = "placementScores", | ||
| NamePattern = "" | ||
| >; | ||
| } | ||
|
|
||
| @armResourceOperations | ||
| interface ComputeDiagnosticBases { | ||
| /** | ||
| * Gets Spot Placement Scores metadata. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @operationId("SpotPlacementScores_Get") | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| get is ArmResourceRead< | ||
| ComputeDiagnosticBase, | ||
| BaseParameters = Azure.ResourceManager.Foundations.SubscriptionBaseParameters | ||
| >; | ||
|
|
||
| /** | ||
| * Generates placement scores for Spot VM skus. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @action("generate") | ||
| @operationId("SpotPlacementScores_Post") | ||
| post is ArmResourceActionSync< | ||
| ComputeDiagnosticBase, | ||
| SpotPlacementScoresInput, | ||
| ArmResponse<SpotPlacementScoresResponse>, | ||
| BaseParameters = Azure.ResourceManager.Foundations.SubscriptionBaseParameters | ||
| >; | ||
| } | ||
|
|
||
| @@doc(ComputeDiagnosticBase.name, ""); | ||
| @@doc(ComputeDiagnosticBase.properties, | ||
| "Contains additional properties of a diagnostic" | ||
| ); | ||
| @@doc(ComputeDiagnosticBases.post::parameters.body, | ||
| "SpotPlacementScores object supplied in the body of the Post spot placement scores operation." | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
| using Microsoft.Compute; | ||
|
|
||
| @@clientName(ComputeDiagnosticBases.post::parameters.body, | ||
| "spotPlacementScoresInput" | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the same example file under two different directories. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gary-x-li the examples under RecommenderRP folder are for TypeSpec, but the examples within each RecommenderRP/{version-status} folder is for swagger, the original intention is that we will have some canonical expression of the example in TypeSpec, but the design has not yet been finalized yet. |
||
| "parameters": { | ||
| "api-version": "2025-06-05", | ||
| "location": "eastus", | ||
| "spotPlacementScoresInput": { | ||
| "availabilityZones": true, | ||
| "desiredCount": 1, | ||
| "desiredLocations": [ | ||
| "eastus", | ||
| "eastus2" | ||
| ], | ||
| "desiredSizes": [ | ||
| { | ||
| "sku": "Standard_D2_v2" | ||
| } | ||
| ] | ||
| }, | ||
| "subscriptionId": "00000000-0000-0000-0000-000000000000" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "availabilityZones": true, | ||
| "desiredCount": 1, | ||
| "desiredLocations": [ | ||
| "eastus", | ||
| "eastus2" | ||
| ], | ||
| "desiredSizes": [ | ||
| { | ||
| "sku": "Standard_D2_v2" | ||
| } | ||
| ], | ||
| "placementScores": [ | ||
| { | ||
| "availabilityZone": "1", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus", | ||
| "score": "High", | ||
| "sku": "Standard_D2_v2" | ||
| }, | ||
| { | ||
| "availabilityZone": "2", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus", | ||
| "score": "High", | ||
| "sku": "Standard_D2_v2" | ||
| }, | ||
| { | ||
| "availabilityZone": "3", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus", | ||
| "score": "High", | ||
| "sku": "Standard_D2_v2" | ||
| }, | ||
| { | ||
| "availabilityZone": "1", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus2", | ||
| "score": "DataNotFoundOrStale", | ||
| "sku": "Standard_D2_v2" | ||
| }, | ||
| { | ||
| "availabilityZone": "2", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus2", | ||
| "score": "High", | ||
| "sku": "Standard_D2_v2" | ||
| }, | ||
| { | ||
| "availabilityZone": "3", | ||
| "isQuotaAvailable": true, | ||
| "region": "eastus2", | ||
| "score": "High", | ||
| "sku": "Standard_D2_v2" | ||
| } | ||
| ] | ||
| }, | ||
| "headers": { | ||
| "location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus/placementScores/spot/generate?api-version=2025-06-05", | ||
| "x-ms-request-id": "57b891ab-1fb7-4f5a-b002-71eb6854961f" | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "SpotPlacementScores_Post", | ||
| "title": "Returns spot VM placement scores for given configurations." | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2025-06-05", | ||
| "location": "eastus", | ||
| "subscriptionId": "00000000-0000-0000-0000-000000000000" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "spotPlacementScores", | ||
| "type": "Microsoft.Compute/placementScores", | ||
| "id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/placementScores/spot?api-version=2025-06-05", | ||
| "properties": { | ||
| "supportedResourceTypes": [ | ||
| "Microsoft.Compute/virtualMachines" | ||
| ] | ||
| } | ||
| }, | ||
| "headers": { | ||
| "x-ms-request-id": "27b7c568-16ec-46f3-bcf1-5bea3f2529b1" | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "SpotPlacementScores_Get", | ||
| "title": "Gets the metadata of Spot Placement Scores." | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS | ||
| * Generated by package: @autorest/openapi-to-typespec | ||
| * Parameters used: | ||
| * isFullCompatible: true | ||
| * guessResourceKey: false | ||
| * Version: 0.10.14 | ||
| * Date: 2025-07-18T08:45:04.778Z | ||
| */ | ||
| import "@typespec/rest"; | ||
| import "@typespec/versioning"; | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "./models.tsp"; | ||
Elina-L marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import "./ComputeDiagnosticBase.tsp"; | ||
| import "./back-compatible.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using TypeSpec.Http; | ||
| using Azure.ResourceManager.Foundations; | ||
| using Azure.Core; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Versioning; | ||
| /** | ||
| * Azure Compute Recommender Client | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @armProviderNamespace | ||
| @service(#{ title: "AzureComputeRecommenderManagementClient" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5) | ||
| namespace Microsoft.Compute; | ||
|
|
||
| /** | ||
| * The available API versions. | ||
| */ | ||
| enum Versions { | ||
| /** | ||
| * The 2025-06-05 API version. | ||
| */ | ||
| @useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1) | ||
| @useDependency(Azure.Core.Versions.v1_0_Preview_1) | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| v2025_06_05: "2025-06-05", | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| 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; | ||
|
|
||
| namespace Microsoft.Compute; | ||
|
|
||
| /** | ||
| * Contains additional properties of a diagnostic | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| model DiagnosticProperties { | ||
| /** | ||
| * Describes what are the supported resource types for a diagnostic. | ||
| */ | ||
| supportedResourceTypes?: string[]; | ||
| } | ||
|
|
||
| /** | ||
| * Common fields that are returned in the response for all Azure Resource Manager resources | ||
| */ | ||
| model Resource { | ||
pshao25 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /** | ||
| * Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" | ||
| */ | ||
| @visibility(Lifecycle.Read) | ||
| id?: Azure.Core.armResourceIdentifier; | ||
|
|
||
| /** | ||
| * The name of the resource | ||
| */ | ||
| @visibility(Lifecycle.Read) | ||
| name?: string; | ||
|
|
||
| /** | ||
| * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" | ||
| */ | ||
| @visibility(Lifecycle.Read) | ||
| type?: string; | ||
|
|
||
| /** | ||
| * Azure Resource Manager metadata containing createdBy and modifiedBy information. | ||
| */ | ||
| @visibility(Lifecycle.Read) | ||
| systemData?: SystemData; | ||
| } | ||
|
|
||
| /** | ||
| * SpotPlacementScores API Input. | ||
| */ | ||
| model SpotPlacementScoresInput { | ||
| /** | ||
| * The desired regions | ||
| */ | ||
| desiredLocations?: string[]; | ||
|
|
||
| /** | ||
| * The desired virtual machine SKU sizes. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| desiredSizes?: ResourceSize[]; | ||
|
|
||
| /** | ||
| * Desired instance count per region/zone based on the scope. | ||
| */ | ||
| desiredCount?: int32; | ||
|
|
||
| /** | ||
| * Defines if the scope is zonal or regional. | ||
| */ | ||
| availabilityZones?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * SpotPlacementRecommender API response. | ||
| */ | ||
| model ResourceSize { | ||
| /** | ||
| * The resource's CRP virtual machine SKU size. | ||
| */ | ||
| sku?: string; | ||
| } | ||
|
|
||
| /** | ||
| * SpotPlacementScores API response. | ||
| */ | ||
| model SpotPlacementScoresResponse { | ||
| /** | ||
| * The desired regions | ||
| */ | ||
| desiredLocations?: string[]; | ||
|
|
||
| /** | ||
| * The desired virtual machine SKU sizes. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| desiredSizes?: ResourceSize[]; | ||
|
|
||
| /** | ||
| * Desired instance count per region/zone based on the scope. | ||
| */ | ||
| desiredCount?: int32; | ||
|
|
||
| /** | ||
| * Defines if the scope is zonal or regional. | ||
| */ | ||
| availabilityZones?: boolean; | ||
|
|
||
| /** | ||
| * A placement score indicating the likelihood of successfully allocating the specified Spot VM(s), as well as the expected lifetimes of the Spot VM(s) after allocation. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
Elina-L marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| placementScores?: PlacementScore[]; | ||
| } | ||
|
|
||
| /** | ||
| * The spot placement score for sku/region/zone combination. | ||
| */ | ||
| model PlacementScore { | ||
| /** | ||
| * The resource's CRP virtual machine SKU size. | ||
| */ | ||
| sku?: string; | ||
|
|
||
| /** | ||
| * The region. | ||
| */ | ||
| region?: string; | ||
|
|
||
| /** | ||
| * The availability zone. | ||
| */ | ||
| availabilityZone?: string; | ||
|
|
||
| /** | ||
| * A placement score indicating the likelihood of successfully allocating the specified Spot VM(s), as well as the expected lifetimes of the Spot VM(s) after allocation. | ||
| */ | ||
| score?: string; | ||
|
|
||
| /** | ||
| * Whether the desired quota is available. | ||
| */ | ||
| isQuotaAvailable?: boolean; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could we rename this file to routes.tsp? The casing doesnt match the other files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't. This file contains resource operations.