Skip to content

Commit 5c3e400

Browse files
authored
[Quantum] ARM Typespec Migration for Azure Quantum (#32339)
Initial typespec migration
1 parent 81330ee commit 5c3e400

28 files changed

+2071
-620
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "./models.tsp";
6+
7+
using TypeSpec.Rest;
8+
using Azure.ResourceManager;
9+
using TypeSpec.Http;
10+
using TypeSpec.OpenAPI;
11+
12+
namespace Microsoft.Quantum;
13+
/**
14+
* The resource proxy definition object for Quantum Workspace.
15+
*/
16+
model QuantumWorkspace
17+
is Azure.ResourceManager.TrackedResource<WorkspaceResourceProperties> {
18+
...ResourceNameParameter<
19+
Resource = QuantumWorkspace,
20+
KeyName = "workspaceName",
21+
SegmentName = "workspaces",
22+
NamePattern = "^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$"
23+
>;
24+
...Azure.ResourceManager.ManagedServiceIdentityProperty;
25+
}
26+
27+
@armResourceOperations
28+
interface Workspaces {
29+
/**
30+
* Check the availability of the resource name for the given location.
31+
*/
32+
checkNameAvailability is checkLocalNameAvailability;
33+
34+
/**
35+
* Returns the Workspace resource associated with the given name.
36+
*/
37+
get is ArmResourceRead<QuantumWorkspace>;
38+
39+
/**
40+
* Creates or updates a Workspace resource.
41+
*/
42+
createOrUpdate is ArmResourceCreateOrReplaceAsync<QuantumWorkspace>;
43+
44+
/**
45+
* Updates an existing Workspace's tags.
46+
*/
47+
@parameterVisibility
48+
updateTags is ArmCustomPatchSync<QuantumWorkspace, PatchModel = TagsObject>;
49+
50+
/**
51+
* Deletes a Workspace resource.
52+
*/
53+
delete is ArmResourceDeleteWithoutOkAsync<QuantumWorkspace>;
54+
55+
/**
56+
* Gets the list of Workspaces within a resource group.
57+
*/
58+
listByResourceGroup is ArmResourceListByParent<QuantumWorkspace>;
59+
60+
/**
61+
* Gets the list of Workspaces within a Subscription.
62+
*/
63+
listBySubscription is ArmListBySubscription<QuantumWorkspace>;
64+
65+
/**
66+
* Get the keys to use with the Quantum APIs. A key is used to authenticate and authorize access to the Quantum REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration.
67+
*/
68+
listKeys is ArmResourceActionSync<
69+
QuantumWorkspace,
70+
void,
71+
ArmResponse<ListKeysResult>
72+
>;
73+
74+
/**
75+
* Regenerate either the primary or secondary key for use with the Quantum APIs. The old key will stop working immediately.
76+
*/
77+
@action("regenerateKey")
78+
regenerateKeys is ArmResourceActionSync<
79+
QuantumWorkspace,
80+
ApiKeys,
81+
NoContentResponse
82+
>;
83+
}
84+
85+
@@doc(QuantumWorkspace.name, "The name of the quantum workspace resource.");
86+
@@doc(QuantumWorkspace.properties,
87+
"Gets or sets the properties. Define quantum workspace's specific properties."
88+
);
89+
@@doc(Workspaces.createOrUpdate::parameters.resource, "Workspace details.");
90+
@@doc(Workspaces.updateTags::parameters.properties,
91+
"Parameters supplied to update tags."
92+
);
93+
@@doc(Workspaces.regenerateKeys::parameters.body,
94+
"Which key to regenerate: primary or secondary."
95+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"operationId": "Workspaces_ListKeys",
3+
"title": "Workspaces_ListKeys",
4+
"parameters": {
5+
"subscriptionId": "00000000-1111-2222-3333-444444444444",
6+
"api-version": "2023-11-13-preview",
7+
"resourceGroupName": "quantumResourcegroup",
8+
"workspaceName": "quantumworkspace1"
9+
},
10+
"responses": {
11+
"200": {
12+
"body": {
13+
"apiKeyEnabled": true,
14+
"primaryKey": {
15+
"createdAt": "2023-11-13T23:06:09.147165Z",
16+
"key": "<primaryKey>"
17+
},
18+
"secondaryKey": {
19+
"createdAt": "2023-11-13T23:06:09.147165Z",
20+
"key": "<secondaryKey>"
21+
},
22+
"primaryConnectionString": "<primaryConnectionString>",
23+
"secondaryConnectionString": "<secondaryConnectionString>"
24+
}
25+
}
26+
}
27+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"operationId": "Offerings_List",
3+
"title": "Offerings_List",
4+
"parameters": {
5+
"subscriptionId": "1C4B2828-7D49-494F-933D-061373BE28C2",
6+
"api-version": "2023-11-13-preview",
7+
"locationName": "westus2"
8+
},
9+
"responses": {
10+
"200": {
11+
"body": {
12+
"value": [
13+
{
14+
"id": "QIO",
15+
"name": "Quantum Inspired Optimization",
16+
"properties": {
17+
"description": "Provide Quantum Inspired Optimization solvers",
18+
"targets": [
19+
{
20+
"name": "CPU annealer",
21+
"id": "p1",
22+
"description": "CPU annealer algorithm"
23+
}
24+
],
25+
"skus": [
26+
{
27+
"name": "Standard",
28+
"id": "Standard",
29+
"version": "1.0",
30+
"description": "Provider CPU and FPGA QIO based solver.",
31+
"restrictedAccessUri": "https://endpoint",
32+
"autoAdd": true,
33+
"targets": [
34+
"p1"
35+
],
36+
"quotaDimensions": [
37+
{
38+
"id": "quota1",
39+
"scope": "Workspace"
40+
}
41+
],
42+
"pricingDetails": [
43+
{
44+
"id": "price",
45+
"value": "200 dollars"
46+
},
47+
{
48+
"id": "rate",
49+
"value": "10 hours/month"
50+
}
51+
]
52+
}
53+
],
54+
"quotaDimensions": [
55+
{
56+
"id": "job-count",
57+
"scope": "Workspace",
58+
"period": "Monthly",
59+
"quota": 30,
60+
"name": "Job count",
61+
"description": "The number of jobs you may submit per month",
62+
"unit": "job",
63+
"unitPlural": "jobs"
64+
},
65+
{
66+
"id": "job-hour",
67+
"scope": "Subscription",
68+
"period": "Monthly",
69+
"quota": 1000,
70+
"name": "Job hours",
71+
"description": "The number of hours of solver time you may use per month",
72+
"unit": "hour",
73+
"unitPlural": "hours"
74+
}
75+
],
76+
"pricingDimensions": [
77+
{
78+
"id": "price",
79+
"name": "Pricing"
80+
},
81+
{
82+
"id": "rate",
83+
"name": "Minimum monthly rate"
84+
}
85+
]
86+
}
87+
}
88+
]
89+
}
90+
}
91+
}
92+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"operationId": "Operations_List",
3+
"title": "Operations_List",
4+
"parameters": {
5+
"api-version": "2023-11-13-preview"
6+
},
7+
"responses": {
8+
"200": {
9+
"body": {
10+
"value": [
11+
{
12+
"name": "Microsoft.Quantum/Locations/Offerings/Read",
13+
"isDataAction": false,
14+
"display": {
15+
"provider": "Microsoft.Quantum",
16+
"resource": "Workspaces",
17+
"operation": "Read quantum workspace's available providers",
18+
"description": "Read providers supported"
19+
}
20+
}
21+
]
22+
}
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"operationId": "Workspaces_CheckNameAvailability",
3+
"title": "Workspaces_CheckNameAvailability",
4+
"parameters": {
5+
"subscriptionId": "00000000-1111-2222-3333-444444444444",
6+
"api-version": "2023-11-13-preview",
7+
"location": "westus2",
8+
"body": {
9+
"name": "sample-workspace-name",
10+
"type": "Microsoft.Quantum/Workspaces"
11+
}
12+
},
13+
"responses": {
14+
"200": {
15+
"body": {
16+
"nameAvailable": false,
17+
"reason": "AlreadyExists",
18+
"message": "Resource name already exists"
19+
}
20+
}
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"operationId": "Workspaces_Delete",
3+
"title": "Workspaces_Delete",
4+
"parameters": {
5+
"workspaceName": "quantumworkspace1",
6+
"resourceGroupName": "quantumResourcegroup",
7+
"subscriptionId": "00000000-1111-2222-3333-444444444444",
8+
"api-version": "2023-11-13-preview"
9+
},
10+
"responses": {
11+
"202": {
12+
"headers": {
13+
"Location": "https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/quantumResourcegroup/providers/Microsoft.Quantum/locations/eastus/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2023-11-13-preview"
14+
},
15+
"description": "Workspace delete request accepted."
16+
},
17+
"204": {
18+
"headers": {
19+
"Location": "https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/quantumResourcegroup/providers/Microsoft.Quantum/locations/eastus/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2023-11-13-preview"
20+
},
21+
"description": "Workspace does not exist."
22+
}
23+
}
24+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"operationId": "Workspaces_Get",
3+
"title": "Workspaces_Get",
4+
"parameters": {
5+
"workspaceName": "quantumworkspace1",
6+
"resourceGroupName": "quantumResourcegroup",
7+
"subscriptionId": "00000000-1111-2222-3333-444444444444",
8+
"api-version": "2023-11-13-preview"
9+
},
10+
"responses": {
11+
"200": {
12+
"body": {
13+
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/quantumResourcegroup/providers/Microsoft.Quantum/Workspaces/quantumworkspace1",
14+
"name": "quantumworkspace1",
15+
"type": "Microsoft.Quantum/Workspaces",
16+
"properties": {
17+
"providers": [
18+
{
19+
"providerId": "Honeywell",
20+
"providerSku": "Basic",
21+
"applicationName": "quantumworkspace1-h1",
22+
"instanceUri": "https://h1.endpoint.com",
23+
"provisioningState": "Succeeded",
24+
"resourceUsageId": "00000000-1111-2222-3333-444444444444"
25+
},
26+
{
27+
"providerId": "IonQ",
28+
"provisioningState": "Succeeded",
29+
"applicationName": "quantumworkspace1-i1",
30+
"instanceUri": "https://i1.endpoint.com",
31+
"providerSku": "Basic",
32+
"resourceUsageId": "00000000-1111-2222-3333-444444444444"
33+
},
34+
{
35+
"providerId": "OneQBit",
36+
"provisioningState": "Succeeded",
37+
"applicationName": "quantumworkspace1-o1",
38+
"instanceUri": "https://o1.endpoint.com",
39+
"providerSku": "Basic",
40+
"resourceUsageId": "00000000-1111-2222-3333-444444444444"
41+
}
42+
],
43+
"provisioningState": "Succeeded",
44+
"usable": "Yes",
45+
"storageAccount": "/subscriptions/1C4B2828-7D49-494F-933D-061373BE28C2/resourceGroups/quantumResourcegroup/providers/Microsoft.Storage/storageAccounts/testStorageAccount",
46+
"endpointUri": "https://quantumworkspace1.westus.quantum.azure.com",
47+
"apiKeyEnabled": true
48+
},
49+
"location": "West US",
50+
"tags": {
51+
"department": "MightyMight",
52+
"company": "Contoso"
53+
},
54+
"identity": {
55+
"type": "SystemAssigned",
56+
"principalId": "00000000-1111-2222-3333-444444444444",
57+
"tenantId": "00000000-1111-2222-3333-444444444444"
58+
},
59+
"systemData": {
60+
"createdBy": "user1",
61+
"createdByType": "User",
62+
"createdAt": "2020-01-01T17:18:19.1234567Z",
63+
"lastModifiedBy": "user2",
64+
"lastModifiedByType": "User",
65+
"lastModifiedAt": "2020-01-02T17:18:19.1234567Z"
66+
}
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)