Skip to content
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

[TSP Migration][HybridConnectivity] TypeSpec migrated from swagger #31699

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
37f1bac
first version for hybrid connectivity typespec
pshao25 Nov 27, 2024
6c7a23a
update config
pshao25 Nov 28, 2024
c07c6d1
Fix diff
melina5656 Nov 29, 2024
4684eca
update
melina5656 Nov 29, 2024
095b30c
Update tspconfig.yaml
melina5656 Nov 29, 2024
25b7ab3
Update tspconfig.yaml
weidongxu-microsoft Nov 29, 2024
2e50a1d
Merge branch 'main' into migration/hybridconnectivity
pshao25 Nov 29, 2024
abea92b
Merge branch 'migration/hybridconnectivity' of https://github.com/Azu…
pshao25 Nov 29, 2024
5503794
update
pshao25 Nov 29, 2024
5bf5ffc
Update tspconfig.yaml
weidongxu-microsoft Nov 29, 2024
63af2ec
Update tspconfig.yaml
weidongxu-microsoft Nov 29, 2024
b1a6826
A trial
pshao25 Nov 29, 2024
902ebc3
Merge branch 'migration/hybridconnectivity' of https://github.com/Azu…
pshao25 Nov 29, 2024
614fd7c
Update tspconfig.yaml
kazrael2119 Nov 29, 2024
6df7c94
update
melina5656 Dec 2, 2024
c7b7a74
Merge branch 'migration/hybridconnectivity' of https://github.com/Azu…
melina5656 Dec 2, 2024
967aed2
Update tspconfig.yaml
msyyc Dec 2, 2024
2627f31
Update readme.md
msyyc Dec 2, 2024
a5530e9
Update tspconfig.yaml
tadelesh Dec 3, 2024
3906624
Update client.tsp
tadelesh Dec 3, 2024
eeb6955
Update client.tsp
msyyc Dec 3, 2024
b96926b
Update client.tsp
msyyc Dec 4, 2024
89fc7fb
update example
pshao25 Dec 4, 2024
bd36d26
Merge branch 'migration/hybridconnectivity' of https://github.com/Azu…
pshao25 Dec 4, 2024
7b73f48
update
melina5656 Dec 5, 2024
cf7e9cb
Update client.tsp
kazrael2119 Dec 6, 2024
34ce344
update
melina5656 Dec 10, 2024
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,160 @@
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.HybridConnectivity;
/**
* The endpoint for the target resource.
*/
model EndpointResource
is Azure.ResourceManager.ExtensionResource<EndpointProperties> {
...ResourceNameParameter<
Resource = EndpointResource,
KeyName = "endpointName",
SegmentName = "endpoints",
NamePattern = ""
>;
}

@armResourceOperations
interface EndpointResources {
/**
* Gets the endpoint to the resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("Endpoints_Get")
get is ArmResourceRead<
EndpointResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* Create or update the endpoint to the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes"
@operationId("Endpoints_CreateOrUpdate")
createOrUpdate is ArmResourceCreateOrReplaceSync<
EndpointResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters,
Response = ArmResourceUpdatedResponse<EndpointResource>
>;

/**
* Update the endpoint to the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@parameterVisibility
@operationId("Endpoints_Update")
update is ArmCustomPatchSync<
EndpointResource,
EndpointResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* Deletes the endpoint access to the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-core/no-response-body" "For backward compatibility"
@operationId("Endpoints_Delete")
delete is ArmResourceDeleteSync<
EndpointResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* List of endpoints to the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("Endpoints_List")
list is ArmResourceListByParent<
EndpointResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters,
Response = EndpointsList
>;

/**
* Gets the endpoint access credentials to the resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-core/casing-style" "The name of the body starts with a capital letter"
@operationId("Endpoints_ListCredentials")
listCredentials is ArmResourceActionSync<
EndpointResource,
{
/**
* Object of type ListCredentialsRequest
*/
@bodyRoot ListCredentialsRequest?: ListCredentialsRequest;
},
EndpointAccessResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters,
Parameters = {
/**
* The is how long the endpoint access token is valid (in seconds).
*/
@maxValue(10800)
@minValue(600)
@query("expiresin")
expiresin?: int64 = 10800;
}
>;

/**
* Gets the ingress gateway endpoint credentials
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-core/casing-style" "The name of the body starts with a capital letter"
@operationId("Endpoints_ListIngressGatewayCredentials")
listIngressGatewayCredentials is ArmResourceActionSync<
EndpointResource,
void,
IngressGatewayResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters,
Parameters = {
/**
* The is how long the endpoint access token is valid (in seconds).
*/
@maxValue(10800)
@minValue(600)
@query("expiresin")
expiresin?: int64 = 10800;
}
>;

/**
* Fetches the managed proxy details
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("Endpoints_ListManagedProxyDetails")
listManagedProxyDetails is ArmResourceActionSync<
EndpointResource,
ManagedProxyRequest,
ManagedProxyResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;
}

@@doc(EndpointResource.name, "The endpoint name.");
@@doc(EndpointResource.properties, "The endpoint properties.");
@@doc(EndpointResources.createOrUpdate::parameters.resource,
"Endpoint details"
);
@@doc(EndpointResources.update::parameters.properties, "Endpoint details");
@@doc(EndpointResources.listManagedProxyDetails::parameters.body,
"Object of type ManagedProxyRequest"
);
@@doc(EndpointResources.listIngressGatewayCredentials,
"Gets the ingress gateway endpoint credentials "
);
@@doc(EndpointResources.listManagedProxyDetails,
"Fetches the managed proxy details "
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./EndpointResource.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.HybridConnectivity;
/**
* The service configuration details associated with the target resource.
*/
@parentResource(EndpointResource)
model ServiceConfigurationResource
is Azure.ResourceManager.ExtensionResource<ServiceConfigurationProperties> {
...ResourceNameParameter<
Resource = ServiceConfigurationResource,
KeyName = "serviceConfigurationName",
SegmentName = "serviceConfigurations",
NamePattern = ""
>;
}

@armResourceOperations
interface ServiceConfigurationResources {
/**
* Gets the details about the service to the resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ServiceConfigurations_Get")
get is ArmResourceRead<
ServiceConfigurationResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* Create or update a service in serviceConfiguration for the endpoint resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ServiceConfigurations_CreateOrupdate")
createOrupdate is ArmResourceCreateOrReplaceSync<
ServiceConfigurationResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* Update the service details in the service configurations of the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@parameterVisibility
@operationId("ServiceConfigurations_Update")
update is ArmCustomPatchSync<
ServiceConfigurationResource,
ServiceConfigurationResourcePatch,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* Deletes the service details to the target resource.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
#suppress "@azure-tools/typespec-azure-core/no-response-body" "For backward compatibility"
@operationId("ServiceConfigurations_Delete")
delete is ArmResourceDeleteSync<
ServiceConfigurationResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters
>;

/**
* API to enumerate registered services in service configurations under a Endpoint Resource
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "non-standard operations"
@operationId("ServiceConfigurations_ListByEndpointResource")
listByEndpointResource is ArmResourceListByParent<
ServiceConfigurationResource,
Azure.ResourceManager.Foundations.ExtensionBaseParameters,
Response = ServiceConfigurationList
>;
}

@@doc(ServiceConfigurationResource.name, "The service name.");
@@doc(ServiceConfigurationResource.properties,
"The service configuration properties."
);
@@doc(ServiceConfigurationResources.createOrupdate::parameters.resource,
"Service details"
);
@@doc(ServiceConfigurationResources.update::parameters.properties,
"Service details"
);
@@summary(ServiceConfigurationResources.listByEndpointResource,
"Lists of all the services associated with endpoint resource."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import "@azure-tools/typespec-client-generator-core";
import "./main.tsp";

using Azure.ClientGenerator.Core;
namespace Microsoft.HybridConnectivity;

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

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

#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(IngressGatewayResource.relay);
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(IngressGatewayResource.ingress);

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

@@clientName(EndpointResources.createOrUpdate::parameters.resource,
"EndpointResource"
);
@@clientName(EndpointResources.listCredentials::parameters.body,
"ListCredentialsRequest"
);
@@clientName(EndpointResources.listManagedProxyDetails::parameters.body,
"ManagedProxyRequest"
);
@@clientName(ServiceConfigurationResources.update::parameters.properties,
"ServiceConfigurationResource"
);
@@clientName(EndpointResources.update::parameters.properties,
"EndpointResource"
);
@@clientName(ServiceConfigurationResources.createOrupdate::parameters.resource,
"ServiceConfigurationResource"
);
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
@@flattenProperty(ServiceConfigurationResource.properties);

@@clientName(EndpointResource, "HybridConnectivityEndpoint", "csharp");
@@clientName(ServiceConfigurationResource,
"HybridConnectivityServiceConfiguration",
"csharp"
);
@@clientName(IngressGatewayResource, "IngressGatewayAsset", "csharp");
@@clientName(EndpointAccessResource, "TargetResourceEndpointAccess", "csharp");
@@clientName(EndpointProperties,
"HybridConnectivityEndpointProperties",
"csharp"
);
@@clientName(ManagedProxyResource, "ManagedProxyAsset", "csharp");
@@clientName(ProvisioningState,
"HybridConnectivityProvisioningState",
"csharp"
);
@@clientName(ServiceName, "HybridConnectivityServiceName", "csharp");
@@clientName(Type, "HybridConnectivityEndpointType", "csharp");
@@clientName(EndpointProperties.type, "endpointType", "csharp");

@@clientName(ServiceConfigurationResources, "ServiceConfigurations", "go");
@@clientName(EndpointResources, "Endpoints", "go");

@@clientName(Microsoft.HybridConnectivity,
"HybridConnectivityMgmtClient",
"python"
);
@@clientName(ServiceConfigurationResources, "ServiceConfigurations", "python");
@@clientName(EndpointResources, "Endpoints", "python");

@@clientName(Microsoft.HybridConnectivity,
"HybridConnectivityManagementAPI",
"javascript"
);
@@clientName(ServiceConfigurationResources,
"ServiceConfigurations",
"javascript"
);
@@clientName(EndpointResources, "Endpoints", "javascript");
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{

Check failure on line 1 in specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsDeleteDefault.json

View check run for this annotation

Azure Pipelines / Swagger PrettierCheck

specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsDeleteDefault.json#L1

specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsDeleteDefault.json(1,1): error : Code style issues found, please run prettier. > npm install > npx prettier --write specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsDeleteDefault.json
"parameters": {
"api-version": "2023-03-15",
"endpointName": "default",
"resourceUri": "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"
},
"responses": {
"200": {},
"204": {}
},
"operationId": "Endpoints_Delete",
"title": "HybridConnectivityEndpointsDeleteDefault"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{

Check failure on line 1 in specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsGetCustom.json

View check run for this annotation

Azure Pipelines / Swagger PrettierCheck

specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsGetCustom.json#L1

specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsGetCustom.json(1,1): error : Code style issues found, please run prettier. > npm install > npx prettier --write specification/hybridconnectivity/HybridConnectivity.Management/examples/2023-03-15/EndpointsGetCustom.json
"parameters": {
"api-version": "2023-03-15",
"endpointName": "custom",
"resourceUri": "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"
},
"responses": {
"200": {
"body": {
"name": "custom",
"type": "Microsoft.HybridConnectivity/endpoints",
"id": "/subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine/providers/Microsoft.HybridConnectivity/endpoints/custom",
"properties": {
"type": "custom",
"resourceId": "/subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.Relay/namespaces/custom-relay-namespace"
}
}
}
},
"operationId": "Endpoints_Get",
"title": "HybridConnectivityEndpointsGetCustom"
}
Loading
Loading