Skip to content

Commit 660fbc3

Browse files
melina5656danieljurek
authored andcommitted
[TSP Migration][hybridkubernetes] TypeSpec migrated from swagger (#34074)
1 parent 7776ca8 commit 660fbc3

File tree

39 files changed

+3327
-1162
lines changed

39 files changed

+3327
-1162
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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.Kubernetes;
13+
/**
14+
* Represents a connected cluster.
15+
*/
16+
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
17+
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
18+
@Azure.ResourceManager.Private.armResourceInternal(ConnectedClusterProperties)
19+
@TypeSpec.Http.Private.includeInapplicableMetadataInPayload(false)
20+
@subscriptionResource
21+
model ConnectedCluster extends Foundations.TrackedResource {
22+
...ResourceNameParameter<
23+
Resource = ConnectedCluster,
24+
KeyName = "clusterName",
25+
SegmentName = "connectedClusters",
26+
NamePattern = ""
27+
>;
28+
29+
/**
30+
* The identity of the connected cluster.
31+
*/
32+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
33+
identity: ConnectedClusterIdentity;
34+
35+
/**
36+
* The kind of connected cluster.
37+
*/
38+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
39+
kind?: ConnectedClusterKind;
40+
41+
/**
42+
* Properties of the connected cluster.
43+
*/
44+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
45+
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(false)
46+
properties: ConnectedClusterProperties;
47+
}
48+
49+
@armResourceOperations
50+
interface ConnectedClusters {
51+
/**
52+
* Returns the properties of the specified connected cluster, including name, identity, properties, and additional cluster details.
53+
*/
54+
get is ArmResourceRead<
55+
ConnectedCluster,
56+
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
57+
>;
58+
59+
/**
60+
* API to register a new Kubernetes cluster and create or replace a connected cluster tracked resource in Azure Resource Manager (ARM).
61+
*/
62+
createOrReplace is ArmResourceCreateOrReplaceAsync<
63+
ConnectedCluster,
64+
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
65+
>;
66+
67+
/**
68+
* API to update certain properties of the connected cluster resource
69+
*/
70+
@patch(#{ implicitOptionality: false })
71+
update is ArmCustomPatchSync<
72+
ConnectedCluster,
73+
PatchModel = ConnectedClusterPatch,
74+
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
75+
>;
76+
77+
/**
78+
* Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM).
79+
*/
80+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
81+
delete is ArmResourceDeleteWithoutOkAsync<
82+
ConnectedCluster,
83+
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
84+
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
85+
>;
86+
87+
/**
88+
* API to enumerate registered connected K8s clusters under a Resource Group
89+
*/
90+
listByResourceGroup is ArmResourceListByParent<
91+
ConnectedCluster,
92+
Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
93+
Response = ArmResponse<ConnectedClusterList>
94+
>;
95+
96+
/**
97+
* API to enumerate registered connected K8s clusters under a Subscription
98+
*/
99+
listBySubscription is ArmListBySubscription<
100+
ConnectedCluster,
101+
Response = ArmResponse<ConnectedClusterList>
102+
>;
103+
104+
/**
105+
* Gets cluster user credentials of the connected cluster with a specified resource group and name.
106+
*/
107+
listClusterUserCredential is ArmResourceActionSync<
108+
ConnectedCluster,
109+
ListClusterUserCredentialProperties,
110+
ArmResponse<CredentialResults>,
111+
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
112+
>;
113+
}
114+
115+
@@doc(ConnectedCluster.name,
116+
"The name of the Kubernetes cluster on which get is called."
117+
);
118+
@@doc(ConnectedCluster.properties,
119+
"Describes the connected cluster resource properties."
120+
);
121+
@@doc(ConnectedClusters.createOrReplace::parameters.resource,
122+
"Parameters supplied to Create a Connected Cluster."
123+
);
124+
@@doc(ConnectedClusters.update::parameters.properties,
125+
"Parameters supplied to update Connected Cluster."
126+
);
127+
@@doc(ConnectedClusters.listClusterUserCredential::parameters.body,
128+
"ListClusterUserCredential properties"
129+
);
130+
@@summary(ConnectedClusters.listBySubscription,
131+
"Lists all connected clusters in the given Subscription"
132+
);
133+
@@summary(ConnectedClusters.get,
134+
"Get the properties of the specified connected cluster."
135+
);
136+
@@summary(ConnectedClusters.createOrReplace,
137+
"Register a new Kubernetes cluster with Azure Resource Manager."
138+
);
139+
@@summary(ConnectedClusters.update, "Updates a connected cluster.");
140+
@@summary(ConnectedClusters.delete, "Delete a connected cluster.");
141+
@@summary(ConnectedClusters.listClusterUserCredential,
142+
"Gets cluster user credentials of a connected cluster"
143+
);
144+
@@summary(ConnectedClusters.listByResourceGroup,
145+
"Lists all connected clusters in the given Resource Group"
146+
);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.Kubernetes;
5+
6+
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
7+
@@flattenProperty(ConnectedClusterPatch.properties);
8+
9+
@@clientName(ConnectedClusters.createOrReplace::parameters.resource,
10+
"ConnectedCluster"
11+
);
12+
@@clientName(ConnectedClusters.update::parameters.properties,
13+
"ConnectedClusterPatch"
14+
);
15+
@@clientName(ConnectedClusters.listClusterUserCredential::parameters.body,
16+
"Properties"
17+
);
18+
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
19+
@@flattenProperty(ConnectedCluster.properties);
20+
21+
@@scope(Operations.list, "!csharp");
22+
23+
// @@clientLocation decorators for operations with @operationId
24+
@@clientLocation(Operations.list, Operations);
25+
@@clientName(Operations.list, "Get");
26+
@@clientLocation(ConnectedClusters.get, "ConnectedCluster", "!csharp");
27+
@@clientLocation(ConnectedClusters.createOrReplace,
28+
"ConnectedCluster",
29+
"!csharp"
30+
);
31+
@@clientLocation(ConnectedClusters.update, "ConnectedCluster", "!csharp");
32+
@@clientLocation(ConnectedClusters.delete, "ConnectedCluster", "!csharp");
33+
@@clientLocation(ConnectedClusters.listByResourceGroup,
34+
"ConnectedCluster",
35+
"!csharp"
36+
);
37+
@@clientLocation(ConnectedClusters.listBySubscription,
38+
"ConnectedCluster",
39+
"!csharp"
40+
);
41+
@@clientLocation(ConnectedClusters.listClusterUserCredential,
42+
"ConnectedCluster",
43+
"!csharp"
44+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"parameters": {
3+
"Properties": {
4+
"authenticationMethod": "AAD",
5+
"clientProxy": true
6+
},
7+
"api-version": "2024-12-01-preview",
8+
"clusterName": "testCluster",
9+
"resourceGroupName": "k8sc-rg",
10+
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
11+
},
12+
"responses": {
13+
"200": {
14+
"body": {
15+
"hybridConnectionConfig": {
16+
"expirationTime": 1631196183,
17+
"hybridConnectionName": "microsoft.kubernetes/connectedclusters/229dc73f7b07196c79a93d4362d9c7fc4ed34df3e95290d27c56cec2dbb82865/1631185383340987904",
18+
"relay": "azgnrelay-ph0-l1",
19+
"relayTid": "33e01921-4d64-4f8c-a055-5bdaffd5e33d",
20+
"relayType": "byor",
21+
"token": "SharedAccessSignature 123456789034675890pbduwegiavifkuw647o02423bbhfouseb"
22+
},
23+
"kubeconfigs": [
24+
{
25+
"name": "credentialName1",
26+
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
27+
}
28+
]
29+
}
30+
}
31+
},
32+
"operationId": "ConnectedCluster_ListClusterUserCredential",
33+
"title": "ListClusterUserCredentialExample"
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"parameters": {
3+
"Properties": {
4+
"authenticationMethod": "Token",
5+
"clientProxy": true
6+
},
7+
"api-version": "2024-12-01-preview",
8+
"clusterName": "testCluster",
9+
"resourceGroupName": "k8sc-rg",
10+
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
11+
},
12+
"responses": {
13+
"200": {
14+
"body": {
15+
"hybridConnectionConfig": {
16+
"expirationTime": 1631196183,
17+
"hybridConnectionName": "microsoft.kubernetes/connectedclusters/229dc73f7b07196c79a93d4362d9c7fc4ed34df3e95290d27c56cec2dbb82865/1631185383340987904",
18+
"relay": "azgnrelay-ph0-l1",
19+
"relayTid": "33e01921-4d64-4f8c-a055-5bdaffd5e33d",
20+
"relayType": "byor",
21+
"token": "SharedAccessSignature 123456789034675890pbduwegiavifkuw647o02423bbhfouseb"
22+
},
23+
"kubeconfigs": [
24+
{
25+
"name": "credentialName1",
26+
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
27+
}
28+
]
29+
}
30+
}
31+
},
32+
"operationId": "ConnectedCluster_ListClusterUserCredential",
33+
"title": "ListClusterUserCredentialNonAadExample"
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"parameters": {
3+
"Properties": {
4+
"authenticationMethod": "AAD",
5+
"clientProxy": false
6+
},
7+
"api-version": "2024-12-01-preview",
8+
"clusterName": "testCluster",
9+
"resourceGroupName": "k8sc-rg",
10+
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
11+
},
12+
"responses": {
13+
"200": {
14+
"body": {
15+
"kubeconfigs": [
16+
{
17+
"name": "credentialName1",
18+
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
19+
}
20+
]
21+
}
22+
}
23+
},
24+
"operationId": "ConnectedCluster_ListClusterUserCredential",
25+
"title": "ListClusterUserCredentialCSPExample"
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"parameters": {
3+
"Properties": {
4+
"authenticationMethod": "Token",
5+
"clientProxy": false
6+
},
7+
"api-version": "2024-12-01-preview",
8+
"clusterName": "testCluster",
9+
"resourceGroupName": "k8sc-rg",
10+
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
11+
},
12+
"responses": {
13+
"200": {
14+
"body": {
15+
"kubeconfigs": [
16+
{
17+
"name": "credentialName1",
18+
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
19+
}
20+
]
21+
}
22+
}
23+
},
24+
"operationId": "ConnectedCluster_ListClusterUserCredential",
25+
"title": "ListClusterUserCredentialNonAadCSPExample"
26+
}

0 commit comments

Comments
 (0)