-
Notifications
You must be signed in to change notification settings - Fork 5.1k
MPG migration SDK - TrafficManager #55412
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
ArthurMa1978
merged 15 commits into
Azure:main
from
mzhongl524:pr-traffic-manager-from-tsp
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2d4f210
Generate SDK code from TSP
mzhongl524 baf1a64
Merge remote-tracking branch 'upstream/main' into pr-traffic-manager-…
mzhongl524 6d567dc
regen (copilot cli fixed)
mzhongl524 be7f856
updated spec branch commit id
mzhongl524 03b09c8
fixed api diff and regen
mzhongl524 8ceaec7
Merge remote-tracking branch 'upstream/main' into pr-traffic-manager-…
mzhongl524 b75bbb8
fixed test
mzhongl524 99d5837
Update sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Az…
mzhongl524 02516ab
fixed test
mzhongl524 c1efe7f
Merge remote-tracking branch 'upstream/main' into pr-traffic-manager-…
mzhongl524 ce8c464
fixed api compat and regen
mzhongl524 36e8659
updated
mzhongl524 977a646
updated
mzhongl524 2dde98d
Merge remote-tracking branch 'upstream/main' into pr-traffic-manager-…
mzhongl524 ff7ba94
updated latest spec main commit id and regen
mzhongl524 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
144 changes: 126 additions & 18 deletions
144
.../Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net10.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
144 changes: 126 additions & 18 deletions
144
...r/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net8.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
144 changes: 126 additions & 18 deletions
144
...ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.netstandard2.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
3 changes: 3 additions & 0 deletions
3
sdk/trafficmanager/Azure.ResourceManager.TrafficManager/metadata.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,3 @@ | ||
| { | ||
| "apiVersion": "2022-04-01" | ||
| } |
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
18 changes: 18 additions & 0 deletions
18
...rceManager.TrafficManager/src/Customization/MockableTrafficManagerSubscriptionResource.cs
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,18 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.TypeSpec.Generator.Customizations; | ||
|
|
||
| namespace Azure.ResourceManager.TrafficManager.Mocking | ||
| { | ||
| [CodeGenSuppress("GetTrafficManagerUserMetrics")] | ||
| public partial class MockableTrafficManagerSubscriptionResource | ||
| { | ||
| /// <summary> Gets the TrafficManagerUserMetricsResource. </summary> | ||
| /// <returns> An object representing a <see cref="TrafficManagerUserMetricsResource"/>. </returns> | ||
| public virtual TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() | ||
| { | ||
| return GetCachedClient(client => new TrafficManagerUserMetricsResource(client, TrafficManagerUserMetricsResource.CreateResourceIdentifier(Id.SubscriptionId))); | ||
| } | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
....ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerTenantResource.cs
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,17 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.ComponentModel; | ||
|
|
||
| namespace Azure.ResourceManager.TrafficManager.Mocking | ||
| { | ||
| public partial class MockableTrafficManagerTenantResource | ||
| { | ||
| /// <summary> Gets the TrafficManagerGeographicHierarchyResource. </summary> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public virtual TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() | ||
| { | ||
| return GetTrafficManagerGeographicHierarchy(default).Value; | ||
| } | ||
| } | ||
| } |
66 changes: 0 additions & 66 deletions
66
...icManager/src/Customization/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs
This file was deleted.
Oops, something went wrong.
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
90 changes: 80 additions & 10 deletions
90
.../Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointResource.cs
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 |
|---|---|---|
| @@ -1,23 +1,93 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Globalization; | ||
| using System.ComponentModel; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Azure.Core; | ||
| using Azure.Core.Pipeline; | ||
| using Azure.ResourceManager.TrafficManager.Models; | ||
| using Microsoft.TypeSpec.Generator.Customizations; | ||
|
|
||
| namespace Azure.ResourceManager.TrafficManager | ||
| { | ||
| /// <summary> | ||
| /// Customizes validation of the resource name since default resource name of the TrafficManagerEndpoint has a template parameter baked in. | ||
| /// </summary> | ||
| public partial class TrafficManagerEndpointResource : ArmResource | ||
| public partial class TrafficManagerEndpointResource | ||
| { | ||
| internal static void ValidateResourceId(ResourceIdentifier id) | ||
| /// <summary> Generate the resource identifier for this resource. </summary> | ||
| /// <param name="subscriptionId"> The subscriptionId. </param> | ||
| /// <param name="resourceGroupName"> The resourceGroupName. </param> | ||
| /// <param name="profileName"> The profileName. </param> | ||
| /// <param name="endpointType"> The endpointType. </param> | ||
| /// <param name="endpointName"> The endpointName. </param> | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) | ||
| { | ||
| string expectedResourceType = ResourceType.ToString().Replace("{endpointType}", id.ResourceType.GetLastType()); | ||
| return CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, (TrafficManagerEndpointType)Enum.Parse(typeof(TrafficManagerEndpointType), endpointType, true), endpointName); | ||
| } | ||
|
|
||
| if (id.ResourceType != expectedResourceType) | ||
| throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, expectedResourceType), nameof(id)); | ||
| /// <summary> Deletes a Traffic Manager endpoint. </summary> | ||
| /// <param name="waitUntil"> Completion option. </param> | ||
| /// <param name="cancellationToken"> The cancellation token to use. </param> | ||
| public virtual async Task<ArmOperation> DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) | ||
| { | ||
| using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Delete"); | ||
| scope.Start(); | ||
| try | ||
| { | ||
| RequestContext context = new RequestContext | ||
| { | ||
| CancellationToken = cancellationToken | ||
| }; | ||
| HttpMessage message = _endpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, context); | ||
| Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); | ||
| Response<TrafficManagerDeleteOperationResult> response = Response.FromValue(TrafficManagerDeleteOperationResult.FromResponse(result), result); | ||
| RequestUriBuilder uri = message.Request.Uri; | ||
| RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
| var operation = new TrafficManagerArmOperation<TrafficManagerDeleteOperationResult>(response, rehydrationToken); | ||
| if (waitUntil == WaitUntil.Completed) | ||
| { | ||
| await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); | ||
| } | ||
| return new TrafficManagerNonGenericArmOperation(operation); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| scope.Failed(e); | ||
| throw; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> Deletes a Traffic Manager endpoint. </summary> | ||
| /// <param name="waitUntil"> Completion option. </param> | ||
| /// <param name="cancellationToken"> The cancellation token to use. </param> | ||
| public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) | ||
| { | ||
| using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Delete"); | ||
| scope.Start(); | ||
| try | ||
| { | ||
| RequestContext context = new RequestContext | ||
| { | ||
| CancellationToken = cancellationToken | ||
| }; | ||
| HttpMessage message = _endpointsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, context); | ||
| Response result = Pipeline.ProcessMessage(message, context); | ||
| Response<TrafficManagerDeleteOperationResult> response = Response.FromValue(TrafficManagerDeleteOperationResult.FromResponse(result), result); | ||
| RequestUriBuilder uri = message.Request.Uri; | ||
| RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
| var operation = new TrafficManagerArmOperation<TrafficManagerDeleteOperationResult>(response, rehydrationToken); | ||
| if (waitUntil == WaitUntil.Completed) | ||
| { | ||
| operation.WaitForCompletion(cancellationToken); | ||
| } | ||
| return new TrafficManagerNonGenericArmOperation(operation); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| scope.Failed(e); | ||
| throw; | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.