Skip to content

Commit 00266ca

Browse files
mcgallanv-jiaodiChenxiJiang333v-huizhu2pshao25
authored
[TSP Migration][NetworkFunction] TypeSpec migrated from swagger (#39756)
* compile * update * update * update * update * update example * fix example error * update * update * update * update * delete * fix * prettier check * fix diff * Fix diff * fix * update client name * Update client.tsp * Rename service from 'Microsoft networkfunction' to 'Azure Traffic Collector' --------- Co-authored-by: Jiao Di (MSFT) <v-jiaodi@microsoft.com> Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Co-authored-by: v-huizhu2 <v-huizhu2@microsoft.com> Co-authored-by: Pan Shao <97225342+pshao25@users.noreply.github.com>
1 parent 96e89b5 commit 00266ca

32 files changed

Lines changed: 2065 additions & 702 deletions
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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.NetworkFunction;
13+
/**
14+
* Azure Traffic Collector resource.
15+
*/
16+
model AzureTrafficCollector
17+
is Azure.ResourceManager.ProxyResource<AzureTrafficCollectorPropertiesFormat> {
18+
...ResourceNameParameter<
19+
Resource = AzureTrafficCollector,
20+
KeyName = "azureTrafficCollectorName",
21+
SegmentName = "azureTrafficCollectors",
22+
NamePattern = ""
23+
>;
24+
25+
/**
26+
* Resource location.
27+
*/
28+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
29+
location: string;
30+
31+
/**
32+
* Resource tags.
33+
*/
34+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
35+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
36+
tags?: Record<string>;
37+
38+
/**
39+
* A unique read-only string that changes whenever the resource is updated.
40+
*/
41+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
42+
@visibility(Lifecycle.Read)
43+
etag?: string;
44+
}
45+
46+
@armResourceOperations
47+
interface AzureTrafficCollectors {
48+
/**
49+
* Gets the specified Azure Traffic Collector in a specified resource group
50+
*/
51+
get is ArmResourceRead<AzureTrafficCollector, Error = CloudError>;
52+
53+
/**
54+
* Creates or updates a Azure Traffic Collector resource
55+
*/
56+
createOrUpdate is ArmResourceCreateOrReplaceAsync<
57+
AzureTrafficCollector,
58+
Error = CloudError
59+
>;
60+
61+
/**
62+
* Updates the specified Azure Traffic Collector tags.
63+
*/
64+
@patch(#{ implicitOptionality: false })
65+
updateTags is ArmCustomPatchSync<
66+
AzureTrafficCollector,
67+
PatchModel = TagsObject,
68+
Error = CloudError
69+
>;
70+
71+
/**
72+
* Deletes a specified Azure Traffic Collector resource.
73+
*/
74+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
75+
delete is ArmResourceDeleteWithoutOkAsync<
76+
AzureTrafficCollector,
77+
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse,
78+
Error = CloudError
79+
>;
80+
81+
/**
82+
* Return list of Azure Traffic Collectors in a Resource Group
83+
*/
84+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
85+
list is ArmResourceListByParent<AzureTrafficCollector, Error = CloudError>;
86+
87+
/**
88+
* Return list of Azure Traffic Collectors in a subscription
89+
*/
90+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
91+
azureTrafficCollectorsBySubscriptionList is ArmListBySubscription<
92+
AzureTrafficCollector,
93+
Error = CloudError
94+
>;
95+
}
96+
97+
@@doc(AzureTrafficCollector.name, "Azure Traffic Collector name");
98+
@@doc(AzureTrafficCollector.properties,
99+
"Properties of the Azure Traffic Collector."
100+
);
101+
@@doc(AzureTrafficCollectors.createOrUpdate::parameters.resource,
102+
"The parameters to provide for the created Azure Traffic Collector."
103+
);
104+
@@doc(AzureTrafficCollectors.updateTags::parameters.properties,
105+
"Parameters supplied to update Azure Traffic Collector tags."
106+
);
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
import "./AzureTrafficCollector.tsp";
7+
8+
using TypeSpec.Rest;
9+
using Azure.ResourceManager;
10+
using TypeSpec.Http;
11+
using TypeSpec.OpenAPI;
12+
13+
namespace Microsoft.NetworkFunction;
14+
/**
15+
* Collector policy resource.
16+
*/
17+
@parentResource(AzureTrafficCollector)
18+
model CollectorPolicy
19+
is Azure.ResourceManager.ProxyResource<CollectorPolicyPropertiesFormat> {
20+
...ResourceNameParameter<
21+
Resource = CollectorPolicy,
22+
KeyName = "collectorPolicyName",
23+
SegmentName = "collectorPolicies",
24+
NamePattern = ""
25+
>;
26+
27+
/**
28+
* Resource location.
29+
*/
30+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
31+
location: string;
32+
33+
/**
34+
* Resource tags.
35+
*/
36+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
37+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
38+
tags?: Record<string>;
39+
40+
/**
41+
* A unique read-only string that changes whenever the resource is updated.
42+
*/
43+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
44+
@visibility(Lifecycle.Read)
45+
etag?: string;
46+
}
47+
48+
@armResourceOperations
49+
interface CollectorPolicies {
50+
/**
51+
* Gets the collector policy in a specified Traffic Collector
52+
*/
53+
get is ArmResourceRead<CollectorPolicy, Error = CloudError>;
54+
55+
/**
56+
* Creates or updates a Collector Policy resource
57+
*/
58+
createOrUpdate is ArmResourceCreateOrReplaceAsync<
59+
CollectorPolicy,
60+
Error = CloudError
61+
>;
62+
63+
/**
64+
* Updates the specified Collector Policy tags.
65+
*/
66+
@patch(#{ implicitOptionality: false })
67+
updateTags is ArmCustomPatchSync<
68+
CollectorPolicy,
69+
PatchModel = TagsObject,
70+
Error = CloudError
71+
>;
72+
73+
/**
74+
* Deletes a specified Collector Policy resource.
75+
*/
76+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
77+
delete is ArmResourceDeleteWithoutOkAsync<
78+
CollectorPolicy,
79+
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse,
80+
Error = CloudError
81+
>;
82+
83+
/**
84+
* Return list of Collector policies in a Azure Traffic Collector
85+
*/
86+
list is ArmResourceListByParent<CollectorPolicy, Error = CloudError>;
87+
}
88+
89+
@@doc(CollectorPolicy.name, "Collector Policy Name");
90+
@@doc(CollectorPolicy.properties, "Properties of the Collector Policy.");
91+
@@doc(CollectorPolicies.createOrUpdate::parameters.resource,
92+
"The parameters to provide for the created Collector Policy."
93+
);
94+
@@Azure.ClientGenerator.Core.clientName(CollectorPolicies.updateTags::parameters.properties,
95+
"parameters"
96+
);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.NetworkFunction;
5+
6+
@@clientName(AzureTrafficCollectors.createOrUpdate::parameters.resource,
7+
"parameters"
8+
);
9+
@@clientName(AzureTrafficCollectors.updateTags::parameters.properties,
10+
"parameters"
11+
);
12+
@@clientLocation(AzureTrafficCollectors.list,
13+
"AzureTrafficCollectorsByResourceGroup"
14+
);
15+
@@clientLocation(AzureTrafficCollectors.azureTrafficCollectorsBySubscriptionList,
16+
"AzureTrafficCollectorsBySubscription"
17+
);
18+
@@clientName(AzureTrafficCollectors.azureTrafficCollectorsBySubscriptionList,
19+
"List"
20+
);
21+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
22+
@@Legacy.flattenProperty(AzureTrafficCollector.properties);
23+
24+
@@clientName(CollectorPolicies.createOrUpdate::parameters.resource,
25+
"parameters"
26+
);
27+
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
28+
@@Legacy.flattenProperty(CollectorPolicy.properties);
29+
30+
@@clientLocation(Operations.list, "NetworkFunction");
31+
@@clientName(Operations.list, "ListOperations");
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
import "./main.tsp";
3+
4+
using Azure.ClientGenerator.Core;
5+
6+
@@clientName(Microsoft.NetworkFunction,
7+
"AzureTrafficCollectorClient",
8+
"javascript"
9+
);
10+
11+
@@clientName(Microsoft.NetworkFunction, "TrafficCollectorMgmtClient", "python");
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-11-01",
4+
"azureTrafficCollectorName": "atc",
5+
"parameters": {
6+
"location": "West US",
7+
"properties": {},
8+
"tags": {
9+
"key1": "value1"
10+
}
11+
},
12+
"resourceGroupName": "rg1",
13+
"subscriptionId": "subid"
14+
},
15+
"responses": {
16+
"200": {
17+
"body": {
18+
"name": "atc",
19+
"type": "Microsoft.NetworkFunction/azureTrafficCollectors",
20+
"etag": "w/\\00000000-0000-0000-0000-000000000000\\",
21+
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc",
22+
"location": "West US",
23+
"properties": {
24+
"collectorPolicies": [],
25+
"provisioningState": "Succeeded"
26+
},
27+
"tags": {
28+
"key1": "value1"
29+
}
30+
}
31+
},
32+
"201": {
33+
"body": {
34+
"name": "atc",
35+
"type": "Microsoft.NetworkFunction/azureTrafficCollectors",
36+
"etag": "w/\\00000000-0000-0000-0000-000000000000\\",
37+
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc",
38+
"location": "West US",
39+
"properties": {
40+
"collectorPolicies": [],
41+
"provisioningState": "Succeeded"
42+
},
43+
"tags": {
44+
"key1": "value1"
45+
}
46+
}
47+
}
48+
},
49+
"operationId": "AzureTrafficCollectors_CreateOrUpdate",
50+
"title": "Create a traffic collector"
51+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-11-01",
4+
"azureTrafficCollectorName": "atc",
5+
"resourceGroupName": "rg1",
6+
"subscriptionId": "subid"
7+
},
8+
"responses": {
9+
"200": {},
10+
"202": {
11+
"headers": {
12+
"Location": "https://management.azure.com/subscriptions/subid/providers/Microsoft.NetworkFunction/locations/westus/operationStatuses/testStatus?api-version=2022-11-01"
13+
}
14+
},
15+
"204": {}
16+
},
17+
"operationId": "AzureTrafficCollectors_Delete",
18+
"title": "Delete Traffic Collector"
19+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-11-01",
4+
"azureTrafficCollectorName": "atc",
5+
"resourceGroupName": "rg1",
6+
"subscriptionId": "subid"
7+
},
8+
"responses": {
9+
"200": {
10+
"body": {
11+
"name": "atc",
12+
"type": "Microsoft.NetworkFunction/azureTrafficCollectors",
13+
"etag": "w/\\00000000-0000-0000-0000-000000000000\\",
14+
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc",
15+
"location": "West US",
16+
"properties": {
17+
"collectorPolicies": [],
18+
"provisioningState": "Succeeded"
19+
},
20+
"tags": {
21+
"key1": "value1"
22+
}
23+
}
24+
}
25+
},
26+
"operationId": "AzureTrafficCollectors_Get",
27+
"title": "Get Traffic Collector"
28+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"parameters": {
3+
"api-version": "2022-11-01",
4+
"azureTrafficCollectorName": "atc",
5+
"parameters": {
6+
"tags": {
7+
"key1": "value1",
8+
"key2": "value2"
9+
}
10+
},
11+
"resourceGroupName": "rg1",
12+
"subscriptionId": "subid"
13+
},
14+
"responses": {
15+
"200": {
16+
"body": {
17+
"name": "atc",
18+
"type": "Microsoft.NetworkFunction/azureTrafficCollectors",
19+
"etag": "w/\\00000000-0000-0000-0000-000000000000\\",
20+
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc",
21+
"location": "West US",
22+
"properties": {
23+
"collectorPolicies": [],
24+
"provisioningState": "Succeeded"
25+
},
26+
"tags": {
27+
"key1": "value1",
28+
"key2": "value2"
29+
}
30+
}
31+
}
32+
},
33+
"operationId": "AzureTrafficCollectors_UpdateTags",
34+
"title": "Update Traffic Collector tags"
35+
}

0 commit comments

Comments
 (0)