Skip to content

Commit a4b29f6

Browse files
mcgallanpshao25v-jiaodiweidongxu-microsoftmsyyc
authored andcommitted
Convert ResourceConnector swagger to Tsp (Azure#37141)
* convert and compile * recompile * update * update * update * Delete package-lock.json * fix comment * update * format * update description and summary * delete * resolve breaking for js * Add client.tsp to mitigate TypeSpec migration breaks - fix SshKey -> SSHKey breaking change * Fix client.tsp imports and finalize TypeSpec migration break mitigation * client.tsp for java * merge * add config for python * Resolve conflicts * Resolve conflict * add flatten on parameter patchableAppliance * remove csharp config --------- Co-authored-by: Pan Shao <97225342+pshao25@users.noreply.github.com> Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: Weidong Xu <weidxu@microsoft.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> Co-authored-by: Tong Xu (MSFT) <v-xuto@microsoft.com>
1 parent 8652bbb commit a4b29f6

31 files changed

+2206
-495
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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.ResourceConnector;
13+
/**
14+
* Appliances definition.
15+
*/
16+
model Appliance is Azure.ResourceManager.TrackedResource<ApplianceProperties> {
17+
...ResourceNameParameter<
18+
Resource = Appliance,
19+
KeyName = "resourceName",
20+
SegmentName = "appliances",
21+
NamePattern = "^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$"
22+
>;
23+
24+
/**
25+
* Identity for the resource.
26+
*/
27+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
28+
identity?: Identity;
29+
}
30+
31+
@armResourceOperations
32+
interface Appliances {
33+
/**
34+
* Gets the details of an Appliance with a specified resource group and name.
35+
*/
36+
@summary("Gets an Appliance.")
37+
get is ArmResourceRead<Appliance>;
38+
39+
/**
40+
* Creates or updates an Appliance in the specified Subscription and Resource Group.
41+
*/
42+
@summary("Creates or updates an Appliance.")
43+
createOrUpdate is ArmResourceCreateOrReplaceAsync<Appliance>;
44+
45+
/**
46+
* Updates an Appliance with the specified Resource Name in the specified Resource Group and Subscription.
47+
*/
48+
@patch(#{ implicitOptionality: false })
49+
@summary("Updates an Appliance.")
50+
update is ArmCustomPatchSync<Appliance, PatchModel = PatchableAppliance>;
51+
52+
/**
53+
* Deletes an Appliance with the specified Resource Name, Resource Group, and Subscription Id.
54+
*/
55+
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
56+
@summary("Deletes an Appliance.")
57+
delete is ArmResourceDeleteWithoutOkAsync<
58+
Appliance,
59+
LroHeaders = ArmAsyncOperationHeader &
60+
Azure.Core.Foundations.RetryAfterHeader
61+
>;
62+
63+
/**
64+
65+
* Gets a list of Appliances in the specified subscription and resource group. The operation returns properties of each Appliance.
66+
67+
*/
68+
@summary("Gets a list of Appliances in the specified subscription and resource group.")
69+
listByResourceGroup is ArmResourceListByParent<
70+
Appliance,
71+
Response = ApplianceListResult
72+
>;
73+
74+
/**
75+
76+
* Gets a list of Appliances in the specified subscription. The operation returns properties of each Appliance
77+
78+
*/
79+
@summary("Gets a list of Appliances in a subscription.")
80+
listBySubscription is ArmListBySubscription<
81+
Appliance,
82+
Response = ApplianceListResult
83+
>;
84+
85+
/**
86+
* Returns the cluster user credentials for the dedicated appliance.
87+
*/
88+
@summary("Returns the cluster user credential.")
89+
listClusterUserCredential is ArmResourceActionSync<
90+
Appliance,
91+
void,
92+
ArmResponse<ApplianceListCredentialResults>
93+
>;
94+
95+
/**
96+
* Returns the cluster customer credentials for the dedicated appliance.
97+
*/
98+
@action("listkeys")
99+
@summary("Gets the management config.")
100+
listKeys is ArmResourceActionSync<
101+
Appliance,
102+
void,
103+
ArmResponse<ApplianceListKeysResults>,
104+
Parameters = {
105+
/**
106+
* This sets the type of artifact being returned, when empty no artifact endpoint is returned.
107+
*/
108+
@query("artifactType")
109+
artifactType?: string;
110+
}
111+
>;
112+
113+
/**
114+
* Gets the upgrade graph of an Appliance with a specified resource group and name and specific release train.
115+
*/
116+
@get
117+
@summary("Gets an Appliance upgrade graph.")
118+
getUpgradeGraph is ArmResourceRead<
119+
Appliance,
120+
Parameters = {
121+
/**
122+
* Upgrade graph version, ex - stable
123+
*/
124+
@path
125+
@key
126+
@segment("upgradeGraphs")
127+
upgradeGraph: string;
128+
},
129+
Response = ArmResponse<UpgradeGraph>
130+
>;
131+
}
132+
133+
@@maxLength(Appliance.name, 63);
134+
@@minLength(Appliance.name, 1);
135+
@@doc(Appliance.name, "Appliances name.");
136+
@@doc(Appliance.properties, "The set of properties specific to an Appliance");
137+
@@doc(Appliances.createOrUpdate::parameters.resource,
138+
"Parameters supplied to create or update an Appliance."
139+
);
140+
@@doc(Appliances.update::parameters.properties,
141+
"The updatable fields of an existing Appliance."
142+
);
143+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(Appliances.update::parameters.properties
144+
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.ResourceConnector;
5+
6+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
7+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(ApplianceOperation.display);
8+
9+
@@clientName(Appliances.createOrUpdate::parameters.resource, "parameters");
10+
@@clientName(Appliances.update::parameters.properties, "parameters");
11+
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(Appliance.properties);
12+
13+
@@clientLocation(AppliancesOperationGroup.getTelemetryConfig, Appliances);
14+
@@clientLocation(Operations.list, Appliances);
15+
@@clientName(Operations.list, "ListOperations");
16+
17+
@@clientName(PatchableAppliance, "patchableAppliance");
18+
@@clientName(ApplianceOperation, "applianceOperation");
19+
@@clientName(ApplianceOperationsList, "applianceOperationsList");
20+
@@clientName(ApplianceProperties, "applianceProperties");
21+
@@clientName(Appliance, "appliance");
22+
@@clientName(ApplianceListResult, "applianceListResult");
23+
@@clientName(ApplianceListCredentialResults, "applianceListCredentialResults");
24+
@@clientName(ApplianceListKeysResults, "applianceListKeysResults");
25+
@@clientName(ApplianceGetTelemetryConfigResult,
26+
"applianceGetTelemetryConfigResult"
27+
);
28+
@@clientName(ApplianceOperationValueDisplay, "applianceOperationValueDisplay");
29+
@@clientName(ApplianceCredentialKubeconfig, "applianceCredentialKubeconfig");
30+
@@clientName(AppliancePropertiesInfrastructureConfig,
31+
"appliancePropertiesInfrastructureConfig"
32+
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
import "./main.tsp";
3+
4+
using Azure.ClientGenerator.Core;
5+
using Microsoft.ResourceConnector;
6+
7+
@@clientName(Microsoft.ResourceConnector,
8+
"ResourceConnectorManagementClient",
9+
"javascript"
10+
);
11+
@@clientName(Microsoft.ResourceConnector,
12+
"ResourceConnectorMgmtClient",
13+
"python"
14+
);
15+
16+
@@clientName(Microsoft.ResourceConnector.SSHKey, "SshKey", "java");
17+
18+
// Fix property name case changes to maintain backward compatibility
19+
@@clientName(Microsoft.ResourceConnector.SSHKey.expirationTimeStamp,
20+
"expirationTimestamp",
21+
"java"
22+
);
23+
@@clientName(Microsoft.ResourceConnector.SSHKey.creationTimeStamp,
24+
"creationTimestamp",
25+
"java"
26+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-10-27",
4+
"identity": {
5+
"type": "SystemAssigned"
6+
},
7+
"parameters": {
8+
"location": "West US",
9+
"properties": {
10+
"distro": "AKSEdge",
11+
"infrastructureConfig": {
12+
"provider": "VMWare"
13+
}
14+
}
15+
},
16+
"resourceGroupName": "testresourcegroup",
17+
"resourceName": "appliance01",
18+
"subscriptionId": "11111111-2222-3333-4444-555555555555"
19+
},
20+
"responses": {
21+
"200": {
22+
"body": {
23+
"name": "appliance01",
24+
"type": "Microsoft.ResourceConnector/appliances",
25+
"id": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ResourceConnector/appliances/appliance01",
26+
"identity": {
27+
"type": "SystemAssigned",
28+
"principalId": "11111111-1111-1111-1111-111111111111",
29+
"tenantId": "111111-1111-1111-1111-111111111111"
30+
},
31+
"location": "West US",
32+
"properties": {
33+
"distro": "AKSEdge",
34+
"infrastructureConfig": {
35+
"provider": "VMWare"
36+
},
37+
"provisioningState": "Updating",
38+
"publicKey": "xxxxxxxx",
39+
"status": "Running",
40+
"version": "1.0.1"
41+
},
42+
"systemData": {
43+
"createdAt": "2020-04-24T18:53:29.0928001Z",
44+
"createdBy": "string",
45+
"createdByType": "Application",
46+
"lastModifiedAt": "2020-04-24T18:53:29.0928001Z",
47+
"lastModifiedBy": "string",
48+
"lastModifiedByType": "Application"
49+
}
50+
}
51+
},
52+
"201": {
53+
"body": {
54+
"name": "appliance01",
55+
"type": "Microsoft.ResourceConnector/appliances",
56+
"id": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ResourceConnector/appliances/appliance01",
57+
"identity": {
58+
"type": "SystemAssigned",
59+
"principalId": "11111111-1111-1111-1111-111111111111",
60+
"tenantId": "111111-1111-1111-1111-111111111111"
61+
},
62+
"location": "West US",
63+
"properties": {
64+
"distro": "AKSEdge",
65+
"infrastructureConfig": {
66+
"provider": "VMWare"
67+
},
68+
"provisioningState": "Creating",
69+
"status": "WaitingForHeartbeat"
70+
},
71+
"systemData": {
72+
"createdAt": "2020-04-24T18:53:29.0928001Z",
73+
"createdBy": "string",
74+
"createdByType": "Application",
75+
"lastModifiedAt": "2020-04-24T18:53:29.0928001Z",
76+
"lastModifiedBy": "string",
77+
"lastModifiedByType": "Application"
78+
}
79+
}
80+
}
81+
},
82+
"operationId": "Appliances_CreateOrUpdate",
83+
"title": "Create/Update Appliance"
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-10-27",
4+
"resourceGroupName": "testresourcegroup",
5+
"resourceName": "appliance01",
6+
"subscriptionId": "11111111-2222-3333-4444-555555555555"
7+
},
8+
"responses": {
9+
"202": {
10+
"headers": {
11+
"Azure-AsyncOperation": "https://management.azure.com/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ResourceConnector/locations/eastus/operationResults/00000000-0000-0000-0000-000000000000/default?api-version=2022-10-27",
12+
"Location": "https://management.azure.com/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ResourceConnector/locations/eastus/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2022-10-27"
13+
}
14+
},
15+
"204": {
16+
"headers": {
17+
"Azure-AsyncOperation": "https://management.azure.com/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ResourceConnector/locations/eastus/operationResults/00000000-0000-0000-0000-000000000000/default?api-version=2022-10-27"
18+
}
19+
}
20+
},
21+
"operationId": "Appliances_Delete",
22+
"title": "Delete Appliance"
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-10-27",
4+
"resourceGroupName": "testresourcegroup",
5+
"resourceName": "appliance01",
6+
"subscriptionId": "11111111-2222-3333-4444-555555555555"
7+
},
8+
"responses": {
9+
"200": {
10+
"body": {
11+
"name": "appliance01",
12+
"type": "Microsoft.ResourceConnector/appliances",
13+
"id": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ResourceConnector/appliances/appliance01",
14+
"identity": {
15+
"type": "SystemAssigned",
16+
"principalId": "11111111-1111-1111-1111-111111111111",
17+
"tenantId": "111111-1111-1111-1111-111111111111"
18+
},
19+
"location": "West US",
20+
"properties": {
21+
"distro": "AKSEdge",
22+
"infrastructureConfig": {
23+
"provider": "VMWare"
24+
},
25+
"provisioningState": "Succeeded",
26+
"publicKey": "xxxxxxxx",
27+
"status": "Running",
28+
"version": "1.0.1"
29+
},
30+
"systemData": {
31+
"createdAt": "2020-04-24T18:53:29.0928001Z",
32+
"createdBy": "string",
33+
"createdByType": "Application",
34+
"lastModifiedAt": "2020-04-24T18:53:29.0928001Z",
35+
"lastModifiedBy": "string",
36+
"lastModifiedByType": "Application"
37+
}
38+
}
39+
}
40+
},
41+
"operationId": "Appliances_Get",
42+
"title": "Get Appliance"
43+
}

0 commit comments

Comments
 (0)