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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
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"
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance"
@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" "For backward compatibility"
identity: ConnectedClusterIdentity;

/**
* The kind of connected cluster.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"
kind?: ConnectedClusterKind;

/**
* Properties of the connected cluster.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "For backward compatibility"
@Azure.ResourceManager.Private.conditionalClientFlatten
@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.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ConnectedCluster_Get")
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).
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ConnectedCluster_CreateOrReplace")
createOrReplace is ArmResourceCreateOrReplaceAsync<
ConnectedCluster,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters
>;

/**
* API to update certain properties of the connected cluster resource
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@patch(#{ implicitOptionality: false })
@operationId("ConnectedCluster_Update")
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-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
@operationId("ConnectedCluster_Delete")
delete is ArmResourceDeleteWithoutOkAsync<
ConnectedCluster,
BaseParameters = Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
>;

/**
* API to enumerate registered connected K8s clusters under a Resource Group
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ConnectedCluster_ListByResourceGroup")
listByResourceGroup is ArmResourceListByParent<
ConnectedCluster,
Azure.ResourceManager.Foundations.ResourceGroupBaseParameters,
Response = ArmResponse<ConnectedClusterList>
>;

/**
* API to enumerate registered connected K8s clusters under a Subscription
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ConnectedCluster_ListBySubscription")
listBySubscription is ArmListBySubscription<
ConnectedCluster,
Response = ArmResponse<ConnectedClusterList>
>;

/**
* Gets cluster user credentials of the connected cluster with a specified resource group and name.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ConnectedCluster_ListClusterUserCredential")
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,21 @@
import "@azure-tools/typespec-client-generator-core";

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

#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(ConnectedClusterPatch.properties);

@@clientName(ConnectedClusters.createOrReplace::parameters.resource,
"ConnectedCluster"
);
@@clientName(ConnectedClusters.update::parameters.properties,
"ConnectedClusterPatch"
);
@@clientName(ConnectedClusters.listClusterUserCredential::parameters.body,
"Properties"
);
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(ConnectedCluster.properties);

@@scope(Operations.list, "!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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"parameters": {
"ConnectedCluster": {
"identity": {
"type": "None"
},
"kind": "AWS",
"location": "East US",
"properties": {
"agentPublicKeyCertificate": "",
"distribution": "eks",
"infrastructure": "aws"
},
"tags": {}
},
"api-version": "2024-12-01-preview",
"clusterName": "testCluster",
"resourceGroupName": "k8sc-rg",
"subscriptionId": "1bfbb5d0-917e-4346-9026-1d3b344417f5"
},
"responses": {
"200": {
"body": {
"name": "connectedCluster1",
"type": "Microsoft.Kubernetes/connectedClusters",
"id": "/subscriptions/1bfbb5d0-917e-4346-9026-1d3b344417f5/resourceGroups/akkeshar/providers/Microsoft.Kubernetes/connectedClusters/connectedCluster1",
"identity": {
"type": "None"
},
"kind": "AWS",
"location": "East US",
"properties": {
"aadProfile": {},
"agentPublicKeyCertificate": "",
"arcAgentProfile": {},
"azureHybridBenefit": "NotApplicable",
"connectivityStatus": "AgentNotInstalled",
"distribution": "eks",
"infrastructure": "aws",
"privateLinkState": "Disabled",
"provisioningState": "Succeeded"
},
"systemData": {
"createdAt": "2020-12-17T07:06:33.9173186Z",
"createdBy": "[email protected]",
"createdByType": "User",
"lastModifiedAt": "2020-12-17T07:06:33.9173186Z",
"lastModifiedBy": "[email protected]",
"lastModifiedByType": "User"
},
"tags": {}
}
},
"201": {
"body": {
"name": "connectedCluster1",
"type": "Microsoft.Kubernetes/connectedClusters",
"id": "/subscriptions/1bfbb5d0-917e-4346-9026-1d3b344417f5/resourceGroups/akkeshar/providers/Microsoft.Kubernetes/connectedClusters/connectedCluster1",
"identity": {
"type": "None"
},
"location": "East US",
"properties": {
"aadProfile": {},
"agentPublicKeyCertificate": "",
"arcAgentProfile": {},
"azureHybridBenefit": "NotApplicable",
"connectivityStatus": "AgentNotInstalled",
"distribution": "eks",
"infrastructure": "aws",
"privateLinkState": "Disabled",
"provisioningState": "Succeeded"
},
"systemData": {
"createdAt": "2020-12-17T07:06:33.9173186Z",
"createdBy": "[email protected]",
"createdByType": "User",
"lastModifiedAt": "2020-12-17T07:06:33.9173186Z",
"lastModifiedBy": "[email protected]",
"lastModifiedByType": "User"
},
"tags": {}
}
}
},
"operationId": "ConnectedCluster_CreateOrReplace",
"title": "CreateClusterAgentless_KindAWSExample"
}
Loading
Loading