Skip to content

[TSP Migration][hybridkubernetes] TypeSpec migrated from swagger #34074

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

Merged
merged 28 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b160ad4
The first version of TSP
melina5656 Apr 17, 2025
a356c11
fix error and diff
melina5656 Apr 18, 2025
f7d8892
fix sdk diff
melina5656 Apr 21, 2025
f2956e6
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs …
May 7, 2025
0c5b6a3
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs …
May 9, 2025
a646a0c
update
May 9, 2025
11bd9d3
run prettier and compile
melina5656 May 12, 2025
bfd2f14
Merge branch 'main' into convert/hybridkubernetes
melina5656 May 12, 2025
a3c1515
Fix some issues
melina5656 May 12, 2025
edd5556
update
May 12, 2025
2390aa1
update
May 12, 2025
68fc963
update
melina5656 May 12, 2025
88dd673
add spell keyword
JiaqiZhang-Dev May 13, 2025
8deebfe
Merge branch 'main' into convert/hybridkubernetes
melina5656 May 23, 2025
6c3e78f
Delete conditionalClientFlatten
melina5656 Jun 6, 2025
2551e2b
update
mcgallan Jun 6, 2025
2d908e6
update
mcgallan Jun 10, 2025
b27bbd3
update
welovej Jun 10, 2025
1f4159c
Merge remote-tracking branch 'upstream/main' into convert/hybridkuber…
mcgallan Jun 19, 2025
8457d83
update
mcgallan Jun 19, 2025
05b4df5
Merge remote-tracking branch 'upstream/main' into convert/hybridkuber…
mcgallan Jun 30, 2025
f2bf9a5
update
mcgallan Jun 30, 2025
9c98890
update
Jul 3, 2025
c540551
Merge branch 'main' into convert/hybridkubernetes
pshao25 Jul 4, 2025
20ff47b
fix namespace issue
ArcturusZhang Jul 4, 2025
98fce3a
fix resource detection
ArcturusZhang Jul 4, 2025
59f1103
format
ArcturusZhang Jul 4, 2025
8e8fd41
Merge branch 'main' into convert/hybridkubernetes
pshao25 Jul 4, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
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.Kubernetes;
/**
* Represents a connected cluster.
*/
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@Azure.ResourceManager.Private.armResourceInternal(ConnectedClusterProperties)
@TypeSpec.Http.Private.includeInapplicableMetadataInPayload(false)
@subscriptionResource
model ConnectedCluster extends Foundations.TrackedResource {
...ResourceNameParameter<
Resource = ConnectedCluster,
KeyName = "clusterName",
SegmentName = "connectedClusters",
NamePattern = ""
>;

/**
* The identity of the connected cluster.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
identity: ConnectedClusterIdentity;

/**
* The kind of connected cluster.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
kind?: ConnectedClusterKind;

/**
* Properties of the connected cluster.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(false)
properties: ConnectedClusterProperties;
}

@armResourceOperations
interface ConnectedClusters {
/**
* Returns the properties of the specified connected cluster, including name, identity, properties, and additional cluster details.
*/
get is ArmResourceRead<
ConnectedCluster,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
>;

/**
* API to register a new Kubernetes cluster and create or replace a connected cluster tracked resource in Azure Resource Manager (ARM).
*/
createOrReplace is ArmResourceCreateOrReplaceAsync<
ConnectedCluster,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
>;

/**
* API to update certain properties of the connected cluster resource
*/
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchSync<
ConnectedCluster,
PatchModel = ConnectedClusterPatch,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
>;

/**
* Delete a connected cluster, removing the tracked resource in Azure Resource Manager (ARM).
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
delete is ArmResourceDeleteWithoutOkAsync<
ConnectedCluster,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* API to enumerate registered connected K8s clusters under a Resource Group
*/
listByResourceGroup is ArmResourceListByParent<
ConnectedCluster,
Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
Response = ArmResponse<ConnectedClusterList>
>;

/**
* API to enumerate registered connected K8s clusters under a Subscription
*/
listBySubscription is ArmListBySubscription<
ConnectedCluster,
Response = ArmResponse<ConnectedClusterList>
>;

/**
* Gets cluster user credentials of the connected cluster with a specified resource group and name.
*/
listClusterUserCredential is ArmResourceActionSync<
ConnectedCluster,
ListClusterUserCredentialProperties,
ArmResponse<CredentialResults>,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
>;
}

@@doc(ConnectedCluster.name,
"The name of the Kubernetes cluster on which get is called."
);
@@doc(ConnectedCluster.properties,
"Describes the connected cluster resource properties."
);
@@doc(ConnectedClusters.createOrReplace::parameters.resource,
"Parameters supplied to Create a Connected Cluster."
);
@@doc(ConnectedClusters.update::parameters.properties,
"Parameters supplied to update Connected Cluster."
);
@@doc(ConnectedClusters.listClusterUserCredential::parameters.body,
"ListClusterUserCredential properties"
);
@@summary(ConnectedClusters.listBySubscription,
"Lists all connected clusters in the given Subscription"
);
@@summary(ConnectedClusters.get,
"Get the properties of the specified connected cluster."
);
@@summary(ConnectedClusters.createOrReplace,
"Register a new Kubernetes cluster with Azure Resource Manager."
);
@@summary(ConnectedClusters.update, "Updates a connected cluster.");
@@summary(ConnectedClusters.delete, "Delete a connected cluster.");
@@summary(ConnectedClusters.listClusterUserCredential,
"Gets cluster user credentials of a connected cluster"
);
@@summary(ConnectedClusters.listByResourceGroup,
"Lists all connected clusters in the given Resource Group"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using Microsoft.Kubernetes;

#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(ConnectedClusterPatch.properties);

@@clientName(ConnectedClusters.createOrReplace::parameters.resource,
"ConnectedCluster"
);
@@clientName(ConnectedClusters.update::parameters.properties,
"ConnectedClusterPatch"
);
@@clientName(ConnectedClusters.listClusterUserCredential::parameters.body,
"Properties"
);
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(ConnectedCluster.properties);

@@scope(Operations.list, "!csharp");

// @@clientLocation decorators for operations with @operationId
@@clientLocation(Operations.list, Operations);
@@clientName(Operations.list, "Get");
@@clientLocation(ConnectedClusters.get, "ConnectedCluster", "!csharp");
@@clientLocation(ConnectedClusters.createOrReplace,
"ConnectedCluster",
"!csharp"
);
@@clientLocation(ConnectedClusters.update, "ConnectedCluster", "!csharp");
@@clientLocation(ConnectedClusters.delete, "ConnectedCluster", "!csharp");
@@clientLocation(ConnectedClusters.listByResourceGroup,
"ConnectedCluster",
"!csharp"
);
@@clientLocation(ConnectedClusters.listBySubscription,
"ConnectedCluster",
"!csharp"
);
@@clientLocation(ConnectedClusters.listClusterUserCredential,
"ConnectedCluster",
"!csharp"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parameters": {
"Properties": {
"authenticationMethod": "AAD",
"clientProxy": true
},
"api-version": "2024-12-01-preview",
"clusterName": "testCluster",
"resourceGroupName": "k8sc-rg",
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
},
"responses": {
"200": {
"body": {
"hybridConnectionConfig": {
"expirationTime": 1631196183,
"hybridConnectionName": "microsoft.kubernetes/connectedclusters/229dc73f7b07196c79a93d4362d9c7fc4ed34df3e95290d27c56cec2dbb82865/1631185383340987904",
"relay": "azgnrelay-ph0-l1",
"relayTid": "33e01921-4d64-4f8c-a055-5bdaffd5e33d",
"relayType": "byor",
"token": "SharedAccessSignature 123456789034675890pbduwegiavifkuw647o02423bbhfouseb"
},
"kubeconfigs": [
{
"name": "credentialName1",
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
}
]
}
}
},
"operationId": "ConnectedCluster_ListClusterUserCredential",
"title": "ListClusterUserCredentialExample"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parameters": {
"Properties": {
"authenticationMethod": "Token",
"clientProxy": true
},
"api-version": "2024-12-01-preview",
"clusterName": "testCluster",
"resourceGroupName": "k8sc-rg",
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
},
"responses": {
"200": {
"body": {
"hybridConnectionConfig": {
"expirationTime": 1631196183,
"hybridConnectionName": "microsoft.kubernetes/connectedclusters/229dc73f7b07196c79a93d4362d9c7fc4ed34df3e95290d27c56cec2dbb82865/1631185383340987904",
"relay": "azgnrelay-ph0-l1",
"relayTid": "33e01921-4d64-4f8c-a055-5bdaffd5e33d",
"relayType": "byor",
"token": "SharedAccessSignature 123456789034675890pbduwegiavifkuw647o02423bbhfouseb"
},
"kubeconfigs": [
{
"name": "credentialName1",
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
}
]
}
}
},
"operationId": "ConnectedCluster_ListClusterUserCredential",
"title": "ListClusterUserCredentialNonAadExample"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parameters": {
"Properties": {
"authenticationMethod": "AAD",
"clientProxy": false
},
"api-version": "2024-12-01-preview",
"clusterName": "testCluster",
"resourceGroupName": "k8sc-rg",
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
},
"responses": {
"200": {
"body": {
"kubeconfigs": [
{
"name": "credentialName1",
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
}
]
}
}
},
"operationId": "ConnectedCluster_ListClusterUserCredential",
"title": "ListClusterUserCredentialCSPExample"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"parameters": {
"Properties": {
"authenticationMethod": "Token",
"clientProxy": false
},
"api-version": "2024-12-01-preview",
"clusterName": "testCluster",
"resourceGroupName": "k8sc-rg",
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
},
"responses": {
"200": {
"body": {
"kubeconfigs": [
{
"name": "credentialName1",
"value": "WVhCcFZtVnljMmx2YmpvZ2RqRU5DbU5zZFhOMFpYSnpPZzBLTFNCamJIVnpkR1Z5T2cwS0lDQWdJR05sY25ScFptbGpZWFJsTFdGMWRHaHZjbWwwZVMxa1lYUmhPaUJNVXpCMFRGTXhRMUpWWkVwVWFVSkVVbFpLVlZOVldrcFJNRVpWVWxNd2RFeFRNSFJEYXpGS1UxVldOR1ZyVGtSUldFVnlXakJHTTFOVlNrSmFNR3hTVlRKMGRWZHNXblphZWtwMVZtcEtWbU5ZWkV0amJsWllUVEZDU0dWclJrOVJiV1J5WTFkb2NtRlZZelZrZWtKRFVWWkdlbEpyUmtWUlZUUkxWRlpHZW1Rd1RsSlhWVkpYVlZaR1JWSllaRXRoYkdWc1NsRXdiSEZSVlRWRFdqSjBlR0ZIZEhCU2Vtd3pUVVZLUWxWVlZrZFJWVVpRVVRCR2JrOUZSazVUVld4RVVUSmtURkV3Um01U1ZVVXdWMWhDTlVOc1VtdFVNVkpTVTFkTmRtVnNhRVJsUjNoVFpXdFZNRg=="
}
]
}
}
},
"operationId": "ConnectedCluster_ListClusterUserCredential",
"title": "ListClusterUserCredentialNonAadCSPExample"
}
Loading
Loading