Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/trafficmanager/Azure.ResourceManager.TrafficManager",
"Tag": "net/trafficmanager/Azure.ResourceManager.TrafficManager_4f4863dbc7"
"Tag": "net/trafficmanager/Azure.ResourceManager.TrafficManager_f952b8a5f2"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"apiVersion": "2022-04-01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
<Description>Microsoft Azure Resource Manager client SDK for Azure resource provider Microsoft.Network TrafficManager.</Description>
<PackageTags>azure;management;arm;resource manager;trafficmanager</PackageTags>
<DisableEnhancedAnalysis>true</DisableEnhancedAnalysis>
<IncludeAutorestDependency>true</IncludeAutorestDependency>
</PropertyGroup>
</Project>
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)));
}
}
}
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;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Azure.ResourceManager.TrafficManager.Models;

namespace Azure.ResourceManager.TrafficManager
{
/// <summary>
/// The class to overcome issue with the TrafficManagerEndpoint Collection REST API where there is no REST API counterpart that GETs all
/// profile data resource. The all profile data resources are retrieved from the collection of endpoints attached to <see cref="TrafficManagerProfileData"/>.
/// The class to overcome issue with the TrafficManagerEndpointData Collection REST API where there is no REST API counterpart that GETs all
/// endpoint data resources. The all endpoint data resources are retrieved from the collection of endpoints attached to <see cref="TrafficManagerProfileData"/>.
/// </summary>
public partial class TrafficManagerEndpointCollection : ArmCollection, IEnumerable<TrafficManagerEndpointData>, IAsyncEnumerable<TrafficManagerEndpointData>
{
Expand All @@ -23,7 +25,7 @@ public partial class TrafficManagerEndpointCollection : ArmCollection, IEnumerab
/// <param name="client"> The client parameters to use in these operations. </param>
/// <param name="id"> The identifier of the parent resource that is the target of operations. </param>
/// /// <param name="profileData">The parent profile data. </param>
internal TrafficManagerEndpointCollection(ArmClient client, ResourceIdentifier id, TrafficManagerProfileData profileData) : this(client, id)
internal TrafficManagerEndpointCollection(ArmClient client, ResourceIdentifier id, TrafficManagerProfileData profileData) : base(client, id)
{
Argument.AssertNotNull(profileData, nameof(profileData));

Expand Down Expand Up @@ -54,6 +56,95 @@ public virtual Pageable<TrafficManagerEndpointData> GetAll()
return PageableHelpers.CreateEnumerable(_ => Page.FromValues(this._profileData.Endpoints, null, null), null, null);
}

/// <summary> Creates or updates a Traffic Manager endpoint. </summary>
/// <param name="waitUntil"> Completion option. </param>
/// <param name="endpointType"> The type of the Traffic Manager endpoint to be created or updated. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint to be created or updated. </param>
/// <param name="data"> The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<ArmOperation<TrafficManagerEndpointResource>> CreateOrUpdateAsync(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default)
{
return await CreateOrUpdateAsync(waitUntil, ParseEndpointType(endpointType), endpointName, data, cancellationToken).ConfigureAwait(false);
}

/// <summary> Creates or updates a Traffic Manager endpoint. </summary>
/// <param name="waitUntil"> Completion option. </param>
/// <param name="endpointType"> The type of the Traffic Manager endpoint to be created or updated. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint to be created or updated. </param>
/// <param name="data"> The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual ArmOperation<TrafficManagerEndpointResource> CreateOrUpdate(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default)
{
return CreateOrUpdate(waitUntil, ParseEndpointType(endpointType), endpointName, data, cancellationToken);
}

/// <summary> Gets a Traffic Manager endpoint. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<TrafficManagerEndpointResource>> GetAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return await GetAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false);
}

/// <summary> Gets a Traffic Manager endpoint. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<TrafficManagerEndpointResource> Get(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return Get(ParseEndpointType(endpointType), endpointName, cancellationToken);
}

/// <summary> Checks to see if the resource exists in azure. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<bool>> ExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return await ExistsAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false);
}

/// <summary> Checks to see if the resource exists in azure. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<bool> Exists(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return Exists(ParseEndpointType(endpointType), endpointName, cancellationToken);
}

/// <summary> Tries to get details for this resource from the service. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<NullableResponse<TrafficManagerEndpointResource>> GetIfExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return await GetIfExistsAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false);
}

/// <summary> Tries to get details for this resource from the service. </summary>
/// <param name="endpointType"> The type of the Traffic Manager endpoint. </param>
/// <param name="endpointName"> The name of the Traffic Manager endpoint. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual NullableResponse<TrafficManagerEndpointResource> GetIfExists(string endpointType, string endpointName, CancellationToken cancellationToken = default)
{
return GetIfExists(ParseEndpointType(endpointType), endpointName, cancellationToken);
}

private static TrafficManagerEndpointType ParseEndpointType(string endpointType)
{
return (TrafficManagerEndpointType)Enum.Parse(typeof(TrafficManagerEndpointType), endpointType, true);
}

IEnumerator<TrafficManagerEndpointData> IEnumerable<TrafficManagerEndpointData>.GetEnumerator()
{
return GetAll().GetEnumerator();
Expand Down
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;
}
}
}
}
Loading
Loading