-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[TSP Migration][NetworkFunction] TypeSpec migrated from swagger #39756
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
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
80dd1cd
compile
mcgallan 1ee9bf8
update
mcgallan a5a7198
update
mcgallan 9c2a4a4
update
mcgallan c6ac237
update
mcgallan e67bee8
update example
mcgallan 8e022a3
fix example error
mcgallan bbf73ac
update
mcgallan 6e85170
update
mcgallan 3701ef4
update
mcgallan 8d93067
update
mcgallan 26b825c
delete
mcgallan 81db752
fix
mcgallan cc86224
prettier check
mcgallan cc73c7c
Merge branch 'Convert-NetworkFunction' of https://github.com/mcgallan…
mcgallan 4562d95
fix diff
mcgallan 8a74329
Merge branch 'main' into Convert-NetworkFunction
mcgallan 1899030
Fix diff
mcgallan c06b1f7
fix
mcgallan d6c63ce
update client name
v-jiaodi 98d30f1
Merge branch 'Convert-NetworkFunction' of https://github.com/mcgallan…
v-jiaodi 6a5f719
Update client.tsp
ChenxiJiang333 3ee6976
Rename service from 'Microsoft networkfunction' to 'Azure Traffic Col…
v-huizhu2 78c2efd
Merge branch 'main' into Convert-NetworkFunction
pshao25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
specification/networkfunction/NetworkFunction.Management/AzureTrafficCollector.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| 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.NetworkFunction; | ||
| /** | ||
| * Azure Traffic Collector resource. | ||
| */ | ||
| model AzureTrafficCollector | ||
| is Azure.ResourceManager.ProxyResource<AzureTrafficCollectorPropertiesFormat> { | ||
| ...ResourceNameParameter< | ||
| Resource = AzureTrafficCollector, | ||
| KeyName = "azureTrafficCollectorName", | ||
| SegmentName = "azureTrafficCollectors", | ||
| NamePattern = "" | ||
| >; | ||
|
|
||
| /** | ||
| * Resource location. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| location: string; | ||
|
|
||
| /** | ||
| * Resource tags. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| tags?: Record<string>; | ||
|
|
||
| /** | ||
| * A unique read-only string that changes whenever the resource is updated. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @visibility(Lifecycle.Read) | ||
| etag?: string; | ||
| } | ||
|
|
||
| @armResourceOperations | ||
| interface AzureTrafficCollectors { | ||
| /** | ||
| * Gets the specified Azure Traffic Collector in a specified resource group | ||
| */ | ||
| get is ArmResourceRead<AzureTrafficCollector, Error = CloudError>; | ||
|
|
||
| /** | ||
| * Creates or updates a Azure Traffic Collector resource | ||
| */ | ||
| createOrUpdate is ArmResourceCreateOrReplaceAsync< | ||
| AzureTrafficCollector, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Updates the specified Azure Traffic Collector tags. | ||
| */ | ||
| @patch(#{ implicitOptionality: false }) | ||
| updateTags is ArmCustomPatchSync< | ||
| AzureTrafficCollector, | ||
| PatchModel = TagsObject, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Deletes a specified Azure Traffic Collector resource. | ||
| */ | ||
| #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< | ||
| AzureTrafficCollector, | ||
| Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Return list of Azure Traffic Collectors in a Resource Group | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| list is ArmResourceListByParent<AzureTrafficCollector, Error = CloudError>; | ||
|
|
||
| /** | ||
| * Return list of Azure Traffic Collectors in a subscription | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| azureTrafficCollectorsBySubscriptionList is ArmListBySubscription< | ||
| AzureTrafficCollector, | ||
| Error = CloudError | ||
| >; | ||
| } | ||
|
|
||
| @@doc(AzureTrafficCollector.name, "Azure Traffic Collector name"); | ||
| @@doc(AzureTrafficCollector.properties, | ||
| "Properties of the Azure Traffic Collector." | ||
| ); | ||
| @@doc(AzureTrafficCollectors.createOrUpdate::parameters.resource, | ||
| "The parameters to provide for the created Azure Traffic Collector." | ||
| ); | ||
| @@doc(AzureTrafficCollectors.updateTags::parameters.properties, | ||
| "Parameters supplied to update Azure Traffic Collector tags." | ||
| ); | ||
96 changes: 96 additions & 0 deletions
96
specification/networkfunction/NetworkFunction.Management/CollectorPolicy.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import "@azure-tools/typespec-azure-core"; | ||
| import "@azure-tools/typespec-azure-resource-manager"; | ||
| import "@typespec/openapi"; | ||
| import "@typespec/rest"; | ||
| import "./models.tsp"; | ||
| import "./AzureTrafficCollector.tsp"; | ||
|
|
||
| using TypeSpec.Rest; | ||
| using Azure.ResourceManager; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.OpenAPI; | ||
|
|
||
| namespace Microsoft.NetworkFunction; | ||
| /** | ||
| * Collector policy resource. | ||
| */ | ||
| @parentResource(AzureTrafficCollector) | ||
| model CollectorPolicy | ||
| is Azure.ResourceManager.ProxyResource<CollectorPolicyPropertiesFormat> { | ||
| ...ResourceNameParameter< | ||
| Resource = CollectorPolicy, | ||
| KeyName = "collectorPolicyName", | ||
| SegmentName = "collectorPolicies", | ||
| NamePattern = "" | ||
| >; | ||
|
|
||
| /** | ||
| * Resource location. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| location: string; | ||
|
|
||
| /** | ||
| * Resource tags. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| tags?: Record<string>; | ||
|
|
||
| /** | ||
| * A unique read-only string that changes whenever the resource is updated. | ||
| */ | ||
| #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @visibility(Lifecycle.Read) | ||
| etag?: string; | ||
| } | ||
|
|
||
| @armResourceOperations | ||
| interface CollectorPolicies { | ||
| /** | ||
| * Gets the collector policy in a specified Traffic Collector | ||
| */ | ||
| get is ArmResourceRead<CollectorPolicy, Error = CloudError>; | ||
|
|
||
| /** | ||
| * Creates or updates a Collector Policy resource | ||
| */ | ||
| createOrUpdate is ArmResourceCreateOrReplaceAsync< | ||
| CollectorPolicy, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Updates the specified Collector Policy tags. | ||
| */ | ||
| @patch(#{ implicitOptionality: false }) | ||
| updateTags is ArmCustomPatchSync< | ||
| CollectorPolicy, | ||
| PatchModel = TagsObject, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Deletes a specified Collector Policy resource. | ||
| */ | ||
| #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< | ||
| CollectorPolicy, | ||
| Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse, | ||
| Error = CloudError | ||
| >; | ||
|
|
||
| /** | ||
| * Return list of Collector policies in a Azure Traffic Collector | ||
| */ | ||
| list is ArmResourceListByParent<CollectorPolicy, Error = CloudError>; | ||
| } | ||
|
|
||
| @@doc(CollectorPolicy.name, "Collector Policy Name"); | ||
| @@doc(CollectorPolicy.properties, "Properties of the Collector Policy."); | ||
| @@doc(CollectorPolicies.createOrUpdate::parameters.resource, | ||
| "The parameters to provide for the created Collector Policy." | ||
| ); | ||
| @@Azure.ClientGenerator.Core.clientName(CollectorPolicies.updateTags::parameters.properties, | ||
| "parameters" | ||
| ); |
31 changes: 31 additions & 0 deletions
31
specification/networkfunction/NetworkFunction.Management/back-compatible.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
| using Microsoft.NetworkFunction; | ||
|
|
||
| @@clientName(AzureTrafficCollectors.createOrUpdate::parameters.resource, | ||
| "parameters" | ||
| ); | ||
| @@clientName(AzureTrafficCollectors.updateTags::parameters.properties, | ||
| "parameters" | ||
| ); | ||
| @@clientLocation(AzureTrafficCollectors.list, | ||
| "AzureTrafficCollectorsByResourceGroup" | ||
| ); | ||
| @@clientLocation(AzureTrafficCollectors.azureTrafficCollectorsBySubscriptionList, | ||
| "AzureTrafficCollectorsBySubscription" | ||
| ); | ||
| @@clientName(AzureTrafficCollectors.azureTrafficCollectorsBySubscriptionList, | ||
| "List" | ||
| ); | ||
| #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @@Legacy.flattenProperty(AzureTrafficCollector.properties); | ||
|
|
||
| @@clientName(CollectorPolicies.createOrUpdate::parameters.resource, | ||
| "parameters" | ||
| ); | ||
| #suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
| @@Legacy.flattenProperty(CollectorPolicy.properties); | ||
|
|
||
| @@clientLocation(Operations.list, "NetworkFunction"); | ||
| @@clientName(Operations.list, "ListOperations"); |
11 changes: 11 additions & 0 deletions
11
specification/networkfunction/NetworkFunction.Management/client.tsp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
| import "./main.tsp"; | ||
|
|
||
| using Azure.ClientGenerator.Core; | ||
|
|
||
| @@clientName(Microsoft.NetworkFunction, | ||
| "AzureTrafficCollectorClient", | ||
| "javascript" | ||
| ); | ||
|
|
||
| @@clientName(Microsoft.NetworkFunction, "TrafficCollectorMgmtClient", "python"); |
51 changes: 51 additions & 0 deletions
51
...kfunction/NetworkFunction.Management/examples/2022-11-01/AzureTrafficCollectorCreate.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2022-11-01", | ||
| "azureTrafficCollectorName": "atc", | ||
| "parameters": { | ||
| "location": "West US", | ||
| "properties": {}, | ||
| "tags": { | ||
| "key1": "value1" | ||
| } | ||
| }, | ||
| "resourceGroupName": "rg1", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "atc", | ||
| "type": "Microsoft.NetworkFunction/azureTrafficCollectors", | ||
| "etag": "w/\\00000000-0000-0000-0000-000000000000\\", | ||
| "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc", | ||
| "location": "West US", | ||
| "properties": { | ||
| "collectorPolicies": [], | ||
| "provisioningState": "Succeeded" | ||
| }, | ||
| "tags": { | ||
| "key1": "value1" | ||
| } | ||
| } | ||
| }, | ||
| "201": { | ||
| "body": { | ||
| "name": "atc", | ||
| "type": "Microsoft.NetworkFunction/azureTrafficCollectors", | ||
| "etag": "w/\\00000000-0000-0000-0000-000000000000\\", | ||
| "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc", | ||
| "location": "West US", | ||
| "properties": { | ||
| "collectorPolicies": [], | ||
| "provisioningState": "Succeeded" | ||
| }, | ||
| "tags": { | ||
| "key1": "value1" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "AzureTrafficCollectors_CreateOrUpdate", | ||
| "title": "Create a traffic collector" | ||
| } |
19 changes: 19 additions & 0 deletions
19
...kfunction/NetworkFunction.Management/examples/2022-11-01/AzureTrafficCollectorDelete.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2022-11-01", | ||
| "azureTrafficCollectorName": "atc", | ||
| "resourceGroupName": "rg1", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": {}, | ||
| "202": { | ||
| "headers": { | ||
| "Location": "https://management.azure.com/subscriptions/subid/providers/Microsoft.NetworkFunction/locations/westus/operationStatuses/testStatus?api-version=2022-11-01" | ||
| } | ||
| }, | ||
| "204": {} | ||
| }, | ||
| "operationId": "AzureTrafficCollectors_Delete", | ||
| "title": "Delete Traffic Collector" | ||
| } |
28 changes: 28 additions & 0 deletions
28
...workfunction/NetworkFunction.Management/examples/2022-11-01/AzureTrafficCollectorGet.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2022-11-01", | ||
| "azureTrafficCollectorName": "atc", | ||
| "resourceGroupName": "rg1", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "atc", | ||
| "type": "Microsoft.NetworkFunction/azureTrafficCollectors", | ||
| "etag": "w/\\00000000-0000-0000-0000-000000000000\\", | ||
| "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc", | ||
| "location": "West US", | ||
| "properties": { | ||
| "collectorPolicies": [], | ||
| "provisioningState": "Succeeded" | ||
| }, | ||
| "tags": { | ||
| "key1": "value1" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "AzureTrafficCollectors_Get", | ||
| "title": "Get Traffic Collector" | ||
| } |
35 changes: 35 additions & 0 deletions
35
...ction/NetworkFunction.Management/examples/2022-11-01/AzureTrafficCollectorUpdateTags.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "parameters": { | ||
| "api-version": "2022-11-01", | ||
| "azureTrafficCollectorName": "atc", | ||
| "parameters": { | ||
| "tags": { | ||
| "key1": "value1", | ||
| "key2": "value2" | ||
| } | ||
| }, | ||
| "resourceGroupName": "rg1", | ||
| "subscriptionId": "subid" | ||
| }, | ||
| "responses": { | ||
| "200": { | ||
| "body": { | ||
| "name": "atc", | ||
| "type": "Microsoft.NetworkFunction/azureTrafficCollectors", | ||
| "etag": "w/\\00000000-0000-0000-0000-000000000000\\", | ||
| "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.NetworkFunction/azureTrafficCollectors/atc", | ||
| "location": "West US", | ||
| "properties": { | ||
| "collectorPolicies": [], | ||
| "provisioningState": "Succeeded" | ||
| }, | ||
| "tags": { | ||
| "key1": "value1", | ||
| "key2": "value2" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "operationId": "AzureTrafficCollectors_UpdateTags", | ||
| "title": "Update Traffic Collector tags" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.