diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net10.0.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net10.0.cs index 795c78d5a8ba..11d896bc0c65 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net10.0.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net10.0.cs @@ -9,15 +9,23 @@ internal AzureResourceManagerTrafficManagerContext() { } public partial class TrafficManagerEndpointCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected TrafficManagerEndpointCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Exists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetAll() { throw null; } public virtual Azure.AsyncPageable GetAllAsync() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.NullableResponse GetIfExists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } @@ -40,7 +48,10 @@ public TrafficManagerEndpointData() { } public string Target { get { throw null; } set { } } public Azure.Core.ResourceIdentifier TargetResourceId { get { throw null; } set { } } public long? Weight { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -53,6 +64,7 @@ public partial class TrafficManagerEndpointResource : Azure.ResourceManager.ArmR protected TrafficManagerEndpointResource() { } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName) { throw null; } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) { throw null; } public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -73,7 +85,10 @@ public static partial class TrafficManagerExtensions public static Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerEndpointResource GetTrafficManagerEndpointResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } + public static Azure.Response GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetTrafficManagerProfile(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -82,14 +97,29 @@ public static partial class TrafficManagerExtensions public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileCollection GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetTrafficManagerProfilesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetTrafficManagerUserMetric(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetricsResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } } + public partial class TrafficManagerGeographicHierarchyCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerGeographicHierarchyCollection() { } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerGeographicHierarchyData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerGeographicHierarchyData() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion GeographicHierarchy { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -128,7 +158,10 @@ public TrafficManagerHeatMapData() { } public System.Collections.Generic.IList Endpoints { get { throw null; } } public System.DateTimeOffset? StartOn { get { throw null; } set { } } public System.Collections.Generic.IList TrafficFlows { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -176,10 +209,12 @@ public TrafficManagerProfileData() { } public long? MaxReturn { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig MonitorConfig { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? ProfileStatus { get { throw null; } set { } } - public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType? RecordType { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? TrafficRoutingMethod { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -199,7 +234,9 @@ protected TrafficManagerProfileResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerEndpoint(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetTrafficManagerEndpoint(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointCollection GetTrafficManagerEndpoints() { throw null; } public virtual Azure.Response GetTrafficManagerHeatMap(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType heatMapType, System.Collections.Generic.IEnumerable topLeft = null, System.Collections.Generic.IEnumerable botRight = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -217,11 +254,26 @@ protected TrafficManagerProfileResource() { } public virtual Azure.Response Update(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class TrafficManagerUserMetricCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerUserMetricCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerUserMetricData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerUserMetricData() { } public string Key { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -246,6 +298,8 @@ protected TrafficManagerUserMetricsResource() { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Mocking @@ -273,6 +327,8 @@ protected MockableTrafficManagerSubscriptionResource() { } public virtual System.Threading.Tasks.Task> CheckTrafficManagerNameAvailabilityV2Async(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetTrafficManagerProfiles(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetTrafficManagerProfilesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerUserMetric(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() { throw null; } } public partial class MockableTrafficManagerTenantResource : Azure.ResourceManager.ArmResource @@ -280,7 +336,10 @@ public partial class MockableTrafficManagerTenantResource : Azure.ResourceManage protected MockableTrafficManagerTenantResource() { } public virtual Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies() { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() { throw null; } + public virtual Azure.Response GetTrafficManagerGeographicHierarchy(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Models @@ -300,20 +359,29 @@ namespace Azure.ResourceManager.TrafficManager.Models public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public override string ToString() { throw null; } } public static partial class ArmTrafficManagerModelFactory { public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig TrafficManagerDnsConfig(string relativeName = null, string fqdn = null, long? ttl = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow TrafficManagerHeatMapTrafficFlow(System.Net.IPAddress sourceIP = null, double? latitude = default(double?), double? longitude = default(double?), System.Collections.Generic.IEnumerable queryExperiences = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig TrafficManagerMonitorConfig(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? profileMonitorStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? protocol = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol?), long? port = default(long?), string path = null, long? intervalInSeconds = default(long?), long? timeoutInSeconds = default(long?), long? toleratedNumberOfFailures = default(long?), System.Collections.Generic.IEnumerable customHeaders = null, System.Collections.Generic.IEnumerable expectedStatusCodeRanges = null) { throw null; } public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilityResult(string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), bool? isNameAvailable = default(bool?), string unavailableReason = null, string message = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileData TrafficManagerProfileData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? profileStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? trafficRoutingMethod = default(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig dnsConfig = null, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig monitorConfig = null, System.Collections.Generic.IEnumerable endpoints = null, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus?), System.Collections.Generic.IEnumerable allowedEndpointRecordTypes = null, long? maxReturn = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion TrafficManagerRegion(string code = null, string name = null, System.Collections.Generic.IEnumerable regions = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData TrafficManagerTrackedResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } } public partial class ExpectedStatusCodeRangeInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExpectedStatusCodeRangeInfo() { } public int? Max { get { throw null; } set { } } public int? Min { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -326,7 +394,10 @@ public TrafficManagerDnsConfig() { } public string Fqdn { get { throw null; } } public string RelativeName { get { throw null; } set { } } public long? Ttl { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -346,6 +417,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public override string ToString() { throw null; } } @@ -354,7 +426,10 @@ public partial class TrafficManagerEndpointCustomHeaderInfo : System.ClientModel public TrafficManagerEndpointCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -379,6 +454,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public override string ToString() { throw null; } } @@ -395,6 +471,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public override string ToString() { throw null; } } @@ -404,19 +481,31 @@ public TrafficManagerEndpointSubnetInfo() { } public System.Net.IPAddress First { get { throw null; } set { } } public System.Net.IPAddress Last { get { throw null; } set { } } public int? Scope { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public enum TrafficManagerEndpointType + { + AzureEndpoints = 0, + ExternalEndpoints = 1, + NestedEndpoints = 2, + } public partial class TrafficManagerHeatMapEndpoint : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerHeatMapEndpoint() { } public int? EndpointId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -429,7 +518,10 @@ public TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount) { } public int EndpointId { get { throw null; } set { } } public double? Latency { get { throw null; } set { } } public int QueryCount { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -443,7 +535,10 @@ public TrafficManagerHeatMapTrafficFlow() { } public double? Longitude { get { throw null; } set { } } public System.Collections.Generic.IList QueryExperiences { get { throw null; } } public System.Net.IPAddress SourceIP { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -462,6 +557,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public override string ToString() { throw null; } } @@ -477,7 +573,10 @@ public TrafficManagerMonitorConfig() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? Protocol { get { throw null; } set { } } public long? TimeoutInSeconds { get { throw null; } set { } } public long? ToleratedNumberOfFailures { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -489,7 +588,10 @@ public partial class TrafficManagerMonitorConfigCustomHeaderInfo : System.Client public TrafficManagerMonitorConfigCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -510,6 +612,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public override string ToString() { throw null; } } @@ -521,7 +624,10 @@ internal TrafficManagerNameAvailabilityResult() { } public string Name { get { throw null; } } public Azure.Core.ResourceType? ResourceType { get { throw null; } } public string UnavailableReason { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -544,27 +650,11 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct TrafficManagerProfileRecordType : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public TrafficManagerProfileRecordType(string value) { throw null; } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType A { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Aaaa { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Cname { get { throw null; } } - public bool Equals(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType other) { throw null; } - public override bool Equals(object obj) { throw null; } - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TrafficManagerProfileStatus : System.IEquatable { private readonly object _dummy; @@ -577,13 +667,17 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public override string ToString() { throw null; } } public partial class TrafficManagerProxyResourceData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerProxyResourceData() { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -596,7 +690,10 @@ public TrafficManagerRegion() { } public string Code { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Regions { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -608,7 +705,10 @@ public partial class TrafficManagerRelativeDnsNameAvailabilityContent : System.C public TrafficManagerRelativeDnsNameAvailabilityContent() { } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -621,7 +721,10 @@ public TrafficManagerResourceData() { } public Azure.Core.ResourceIdentifier Id { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -633,7 +736,10 @@ public partial class TrafficManagerTrackedResourceData : Azure.ResourceManager.T public TrafficManagerTrackedResourceData() { } public Azure.Core.AzureLocation? Location { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -657,6 +763,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public override string ToString() { throw null; } } @@ -673,6 +780,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public override string ToString() { throw null; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net8.0.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net8.0.cs index 795c78d5a8ba..11d896bc0c65 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net8.0.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.net8.0.cs @@ -9,15 +9,23 @@ internal AzureResourceManagerTrafficManagerContext() { } public partial class TrafficManagerEndpointCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected TrafficManagerEndpointCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Exists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetAll() { throw null; } public virtual Azure.AsyncPageable GetAllAsync() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.NullableResponse GetIfExists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } @@ -40,7 +48,10 @@ public TrafficManagerEndpointData() { } public string Target { get { throw null; } set { } } public Azure.Core.ResourceIdentifier TargetResourceId { get { throw null; } set { } } public long? Weight { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -53,6 +64,7 @@ public partial class TrafficManagerEndpointResource : Azure.ResourceManager.ArmR protected TrafficManagerEndpointResource() { } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName) { throw null; } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) { throw null; } public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -73,7 +85,10 @@ public static partial class TrafficManagerExtensions public static Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerEndpointResource GetTrafficManagerEndpointResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } + public static Azure.Response GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetTrafficManagerProfile(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -82,14 +97,29 @@ public static partial class TrafficManagerExtensions public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileCollection GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetTrafficManagerProfilesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetTrafficManagerUserMetric(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetricsResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } } + public partial class TrafficManagerGeographicHierarchyCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerGeographicHierarchyCollection() { } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerGeographicHierarchyData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerGeographicHierarchyData() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion GeographicHierarchy { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -128,7 +158,10 @@ public TrafficManagerHeatMapData() { } public System.Collections.Generic.IList Endpoints { get { throw null; } } public System.DateTimeOffset? StartOn { get { throw null; } set { } } public System.Collections.Generic.IList TrafficFlows { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -176,10 +209,12 @@ public TrafficManagerProfileData() { } public long? MaxReturn { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig MonitorConfig { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? ProfileStatus { get { throw null; } set { } } - public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType? RecordType { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? TrafficRoutingMethod { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -199,7 +234,9 @@ protected TrafficManagerProfileResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerEndpoint(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetTrafficManagerEndpoint(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointCollection GetTrafficManagerEndpoints() { throw null; } public virtual Azure.Response GetTrafficManagerHeatMap(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType heatMapType, System.Collections.Generic.IEnumerable topLeft = null, System.Collections.Generic.IEnumerable botRight = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -217,11 +254,26 @@ protected TrafficManagerProfileResource() { } public virtual Azure.Response Update(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class TrafficManagerUserMetricCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerUserMetricCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerUserMetricData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerUserMetricData() { } public string Key { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -246,6 +298,8 @@ protected TrafficManagerUserMetricsResource() { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Mocking @@ -273,6 +327,8 @@ protected MockableTrafficManagerSubscriptionResource() { } public virtual System.Threading.Tasks.Task> CheckTrafficManagerNameAvailabilityV2Async(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetTrafficManagerProfiles(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetTrafficManagerProfilesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerUserMetric(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() { throw null; } } public partial class MockableTrafficManagerTenantResource : Azure.ResourceManager.ArmResource @@ -280,7 +336,10 @@ public partial class MockableTrafficManagerTenantResource : Azure.ResourceManage protected MockableTrafficManagerTenantResource() { } public virtual Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies() { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() { throw null; } + public virtual Azure.Response GetTrafficManagerGeographicHierarchy(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Models @@ -300,20 +359,29 @@ namespace Azure.ResourceManager.TrafficManager.Models public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public override string ToString() { throw null; } } public static partial class ArmTrafficManagerModelFactory { public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig TrafficManagerDnsConfig(string relativeName = null, string fqdn = null, long? ttl = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow TrafficManagerHeatMapTrafficFlow(System.Net.IPAddress sourceIP = null, double? latitude = default(double?), double? longitude = default(double?), System.Collections.Generic.IEnumerable queryExperiences = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig TrafficManagerMonitorConfig(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? profileMonitorStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? protocol = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol?), long? port = default(long?), string path = null, long? intervalInSeconds = default(long?), long? timeoutInSeconds = default(long?), long? toleratedNumberOfFailures = default(long?), System.Collections.Generic.IEnumerable customHeaders = null, System.Collections.Generic.IEnumerable expectedStatusCodeRanges = null) { throw null; } public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilityResult(string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), bool? isNameAvailable = default(bool?), string unavailableReason = null, string message = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileData TrafficManagerProfileData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? profileStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? trafficRoutingMethod = default(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig dnsConfig = null, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig monitorConfig = null, System.Collections.Generic.IEnumerable endpoints = null, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus?), System.Collections.Generic.IEnumerable allowedEndpointRecordTypes = null, long? maxReturn = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion TrafficManagerRegion(string code = null, string name = null, System.Collections.Generic.IEnumerable regions = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData TrafficManagerTrackedResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } } public partial class ExpectedStatusCodeRangeInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExpectedStatusCodeRangeInfo() { } public int? Max { get { throw null; } set { } } public int? Min { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -326,7 +394,10 @@ public TrafficManagerDnsConfig() { } public string Fqdn { get { throw null; } } public string RelativeName { get { throw null; } set { } } public long? Ttl { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -346,6 +417,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public override string ToString() { throw null; } } @@ -354,7 +426,10 @@ public partial class TrafficManagerEndpointCustomHeaderInfo : System.ClientModel public TrafficManagerEndpointCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -379,6 +454,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public override string ToString() { throw null; } } @@ -395,6 +471,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public override string ToString() { throw null; } } @@ -404,19 +481,31 @@ public TrafficManagerEndpointSubnetInfo() { } public System.Net.IPAddress First { get { throw null; } set { } } public System.Net.IPAddress Last { get { throw null; } set { } } public int? Scope { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public enum TrafficManagerEndpointType + { + AzureEndpoints = 0, + ExternalEndpoints = 1, + NestedEndpoints = 2, + } public partial class TrafficManagerHeatMapEndpoint : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerHeatMapEndpoint() { } public int? EndpointId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -429,7 +518,10 @@ public TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount) { } public int EndpointId { get { throw null; } set { } } public double? Latency { get { throw null; } set { } } public int QueryCount { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -443,7 +535,10 @@ public TrafficManagerHeatMapTrafficFlow() { } public double? Longitude { get { throw null; } set { } } public System.Collections.Generic.IList QueryExperiences { get { throw null; } } public System.Net.IPAddress SourceIP { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -462,6 +557,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public override string ToString() { throw null; } } @@ -477,7 +573,10 @@ public TrafficManagerMonitorConfig() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? Protocol { get { throw null; } set { } } public long? TimeoutInSeconds { get { throw null; } set { } } public long? ToleratedNumberOfFailures { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -489,7 +588,10 @@ public partial class TrafficManagerMonitorConfigCustomHeaderInfo : System.Client public TrafficManagerMonitorConfigCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -510,6 +612,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public override string ToString() { throw null; } } @@ -521,7 +624,10 @@ internal TrafficManagerNameAvailabilityResult() { } public string Name { get { throw null; } } public Azure.Core.ResourceType? ResourceType { get { throw null; } } public string UnavailableReason { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -544,27 +650,11 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct TrafficManagerProfileRecordType : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public TrafficManagerProfileRecordType(string value) { throw null; } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType A { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Aaaa { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Cname { get { throw null; } } - public bool Equals(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType other) { throw null; } - public override bool Equals(object obj) { throw null; } - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TrafficManagerProfileStatus : System.IEquatable { private readonly object _dummy; @@ -577,13 +667,17 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public override string ToString() { throw null; } } public partial class TrafficManagerProxyResourceData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerProxyResourceData() { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -596,7 +690,10 @@ public TrafficManagerRegion() { } public string Code { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Regions { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -608,7 +705,10 @@ public partial class TrafficManagerRelativeDnsNameAvailabilityContent : System.C public TrafficManagerRelativeDnsNameAvailabilityContent() { } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -621,7 +721,10 @@ public TrafficManagerResourceData() { } public Azure.Core.ResourceIdentifier Id { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -633,7 +736,10 @@ public partial class TrafficManagerTrackedResourceData : Azure.ResourceManager.T public TrafficManagerTrackedResourceData() { } public Azure.Core.AzureLocation? Location { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -657,6 +763,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public override string ToString() { throw null; } } @@ -673,6 +780,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public override string ToString() { throw null; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.netstandard2.0.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.netstandard2.0.cs index 795c78d5a8ba..11d896bc0c65 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.netstandard2.0.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/api/Azure.ResourceManager.TrafficManager.netstandard2.0.cs @@ -9,15 +9,23 @@ internal AzureResourceManagerTrafficManagerContext() { } public partial class TrafficManagerEndpointCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable { protected TrafficManagerEndpointCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string endpointType, string endpointName, Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Exists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetAll() { throw null; } public virtual Azure.AsyncPageable GetAllAsync() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.NullableResponse GetIfExists(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } @@ -40,7 +48,10 @@ public TrafficManagerEndpointData() { } public string Target { get { throw null; } set { } } public Azure.Core.ResourceIdentifier TargetResourceId { get { throw null; } set { } } public long? Weight { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -53,6 +64,7 @@ public partial class TrafficManagerEndpointResource : Azure.ResourceManager.ArmR protected TrafficManagerEndpointResource() { } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointData Data { get { throw null; } } public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName) { throw null; } public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) { throw null; } public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -73,7 +85,10 @@ public static partial class TrafficManagerExtensions public static Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerEndpointResource GetTrafficManagerEndpointResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource) { throw null; } + public static Azure.Response GetTrafficManagerGeographicHierarchy(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } public static Azure.Response GetTrafficManagerProfile(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string profileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -82,14 +97,29 @@ public static partial class TrafficManagerExtensions public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileCollection GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } public static Azure.Pageable GetTrafficManagerProfiles(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.AsyncPageable GetTrafficManagerProfilesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetTrafficManagerUserMetric(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } public static Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetricsResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } } + public partial class TrafficManagerGeographicHierarchyCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerGeographicHierarchyCollection() { } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerGeographicHierarchyData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerGeographicHierarchyData() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion GeographicHierarchy { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -128,7 +158,10 @@ public TrafficManagerHeatMapData() { } public System.Collections.Generic.IList Endpoints { get { throw null; } } public System.DateTimeOffset? StartOn { get { throw null; } set { } } public System.Collections.Generic.IList TrafficFlows { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerHeatMapData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -176,10 +209,12 @@ public TrafficManagerProfileData() { } public long? MaxReturn { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig MonitorConfig { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? ProfileStatus { get { throw null; } set { } } - public Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType? RecordType { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? TrafficRoutingMethod { get { throw null; } set { } } public Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerProfileData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -199,7 +234,9 @@ protected TrafficManagerProfileResource() { } public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerEndpoint(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response GetTrafficManagerEndpoint(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointType endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetTrafficManagerEndpointAsync(string endpointType, string endpointName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerEndpointCollection GetTrafficManagerEndpoints() { throw null; } public virtual Azure.Response GetTrafficManagerHeatMap(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType heatMapType, System.Collections.Generic.IEnumerable topLeft = null, System.Collections.Generic.IEnumerable botRight = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -217,11 +254,26 @@ protected TrafficManagerProfileResource() { } public virtual Azure.Response Update(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.TrafficManager.TrafficManagerProfileData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } + public partial class TrafficManagerUserMetricCollection : Azure.ResourceManager.ArmCollection + { + protected TrafficManagerUserMetricCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class TrafficManagerUserMetricData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerUserMetricData() { } public string Key { get { throw null; } set { } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -246,6 +298,8 @@ protected TrafficManagerUserMetricsResource() { } Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Mocking @@ -273,6 +327,8 @@ protected MockableTrafficManagerSubscriptionResource() { } public virtual System.Threading.Tasks.Task> CheckTrafficManagerNameAvailabilityV2Async(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Pageable GetTrafficManagerProfiles(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AsyncPageable GetTrafficManagerProfilesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetTrafficManagerUserMetric(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerUserMetricAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() { throw null; } } public partial class MockableTrafficManagerTenantResource : Azure.ResourceManager.ArmResource @@ -280,7 +336,10 @@ public partial class MockableTrafficManagerTenantResource : Azure.ResourceManage protected MockableTrafficManagerTenantResource() { } public virtual Azure.Response CheckTrafficManagerRelativeDnsNameAvailability(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies() { throw null; } public virtual Azure.ResourceManager.TrafficManager.TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() { throw null; } + public virtual Azure.Response GetTrafficManagerGeographicHierarchy(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficManagerGeographicHierarchyAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } } namespace Azure.ResourceManager.TrafficManager.Models @@ -300,20 +359,29 @@ namespace Azure.ResourceManager.TrafficManager.Models public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType left, Azure.ResourceManager.TrafficManager.Models.AllowedEndpointRecordType right) { throw null; } public override string ToString() { throw null; } } public static partial class ArmTrafficManagerModelFactory { public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig TrafficManagerDnsConfig(string relativeName = null, string fqdn = null, long? ttl = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow TrafficManagerHeatMapTrafficFlow(System.Net.IPAddress sourceIP = null, double? latitude = default(double?), double? longitude = default(double?), System.Collections.Generic.IEnumerable queryExperiences = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig TrafficManagerMonitorConfig(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? profileMonitorStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? protocol = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol?), long? port = default(long?), string path = null, long? intervalInSeconds = default(long?), long? timeoutInSeconds = default(long?), long? toleratedNumberOfFailures = default(long?), System.Collections.Generic.IEnumerable customHeaders = null, System.Collections.Generic.IEnumerable expectedStatusCodeRanges = null) { throw null; } public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilityResult(string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), bool? isNameAvailable = default(bool?), string unavailableReason = null, string message = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.TrafficManagerProfileData TrafficManagerProfileData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? profileStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus?), Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? trafficRoutingMethod = default(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod?), Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig dnsConfig = null, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig monitorConfig = null, System.Collections.Generic.IEnumerable endpoints = null, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus?), System.Collections.Generic.IEnumerable allowedEndpointRecordTypes = null, long? maxReturn = default(long?)) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion TrafficManagerRegion(string code = null, string name = null, System.Collections.Generic.IEnumerable regions = null) { throw null; } + public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData TrafficManagerTrackedResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } } public partial class ExpectedStatusCodeRangeInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public ExpectedStatusCodeRangeInfo() { } public int? Max { get { throw null; } set { } } public int? Min { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.ExpectedStatusCodeRangeInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -326,7 +394,10 @@ public TrafficManagerDnsConfig() { } public string Fqdn { get { throw null; } } public string RelativeName { get { throw null; } set { } } public long? Ttl { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerDnsConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -346,6 +417,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointAlwaysServeStatus right) { throw null; } public override string ToString() { throw null; } } @@ -354,7 +426,10 @@ public partial class TrafficManagerEndpointCustomHeaderInfo : System.ClientModel public TrafficManagerEndpointCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -379,6 +454,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointMonitorStatus right) { throw null; } public override string ToString() { throw null; } } @@ -395,6 +471,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointStatus right) { throw null; } public override string ToString() { throw null; } } @@ -404,19 +481,31 @@ public TrafficManagerEndpointSubnetInfo() { } public System.Net.IPAddress First { get { throw null; } set { } } public System.Net.IPAddress Last { get { throw null; } set { } } public int? Scope { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerEndpointSubnetInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public enum TrafficManagerEndpointType + { + AzureEndpoints = 0, + ExternalEndpoints = 1, + NestedEndpoints = 2, + } public partial class TrafficManagerHeatMapEndpoint : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerHeatMapEndpoint() { } public int? EndpointId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapEndpoint System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -429,7 +518,10 @@ public TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount) { } public int EndpointId { get { throw null; } set { } } public double? Latency { get { throw null; } set { } } public int QueryCount { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapQueryExperience System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -443,7 +535,10 @@ public TrafficManagerHeatMapTrafficFlow() { } public double? Longitude { get { throw null; } set { } } public System.Collections.Generic.IList QueryExperiences { get { throw null; } } public System.Net.IPAddress SourceIP { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapTrafficFlow System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -462,6 +557,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerHeatMapType right) { throw null; } public override string ToString() { throw null; } } @@ -477,7 +573,10 @@ public TrafficManagerMonitorConfig() { } public Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? Protocol { get { throw null; } set { } } public long? TimeoutInSeconds { get { throw null; } set { } } public long? ToleratedNumberOfFailures { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -489,7 +588,10 @@ public partial class TrafficManagerMonitorConfigCustomHeaderInfo : System.Client public TrafficManagerMonitorConfigCustomHeaderInfo() { } public string Name { get { throw null; } set { } } public string Value { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorConfigCustomHeaderInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -510,6 +612,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerMonitorProtocol right) { throw null; } public override string ToString() { throw null; } } @@ -521,7 +624,10 @@ internal TrafficManagerNameAvailabilityResult() { } public string Name { get { throw null; } } public Azure.Core.ResourceType? ResourceType { get { throw null; } } public string UnavailableReason { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerNameAvailabilityResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -544,27 +650,11 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileMonitorStatus right) { throw null; } public override string ToString() { throw null; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct TrafficManagerProfileRecordType : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public TrafficManagerProfileRecordType(string value) { throw null; } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType A { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Aaaa { get { throw null; } } - public static Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType Cname { get { throw null; } } - public bool Equals(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType other) { throw null; } - public override bool Equals(object obj) { throw null; } - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType (string value) { throw null; } - public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileRecordType right) { throw null; } - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct TrafficManagerProfileStatus : System.IEquatable { private readonly object _dummy; @@ -577,13 +667,17 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficManagerProfileStatus right) { throw null; } public override string ToString() { throw null; } } public partial class TrafficManagerProxyResourceData : Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public TrafficManagerProxyResourceData() { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerProxyResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -596,7 +690,10 @@ public TrafficManagerRegion() { } public string Code { get { throw null; } set { } } public string Name { get { throw null; } set { } } public System.Collections.Generic.IList Regions { get { throw null; } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRegion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -608,7 +705,10 @@ public partial class TrafficManagerRelativeDnsNameAvailabilityContent : System.C public TrafficManagerRelativeDnsNameAvailabilityContent() { } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerRelativeDnsNameAvailabilityContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -621,7 +721,10 @@ public TrafficManagerResourceData() { } public Azure.Core.ResourceIdentifier Id { get { throw null; } set { } } public string Name { get { throw null; } set { } } public Azure.Core.ResourceType? ResourceType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -633,7 +736,10 @@ public partial class TrafficManagerTrackedResourceData : Azure.ResourceManager.T public TrafficManagerTrackedResourceData() { } public Azure.Core.AzureLocation? Location { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.ResourceManager.TrafficManager.Models.TrafficManagerResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.TrafficManager.Models.TrafficManagerTrackedResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -657,6 +763,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod left, Azure.ResourceManager.TrafficManager.Models.TrafficRoutingMethod right) { throw null; } public override string ToString() { throw null; } } @@ -673,6 +780,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus left, Azure.ResourceManager.TrafficManager.Models.TrafficViewEnrollmentStatus right) { throw null; } public override string ToString() { throw null; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/assets.json b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/assets.json index cbd74f02f488..cf9f341d52a5 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/assets.json +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/assets.json @@ -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" } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/metadata.json b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/metadata.json new file mode 100644 index 000000000000..6d38a7e13a69 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/metadata.json @@ -0,0 +1,3 @@ +{ + "apiVersion": "2022-04-01" +} \ No newline at end of file diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Azure.ResourceManager.TrafficManager.csproj b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Azure.ResourceManager.TrafficManager.csproj index f60412d77f71..812fb0d78494 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Azure.ResourceManager.TrafficManager.csproj +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Azure.ResourceManager.TrafficManager.csproj @@ -7,6 +7,5 @@ Microsoft Azure Resource Manager client SDK for Azure resource provider Microsoft.Network TrafficManager. azure;management;arm;resource manager;trafficmanager true - true diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerSubscriptionResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerSubscriptionResource.cs new file mode 100644 index 000000000000..d07bf49be673 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerSubscriptionResource.cs @@ -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 + { + /// Gets the TrafficManagerUserMetricsResource. + /// An object representing a . + public virtual TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() + { + return GetCachedClient(client => new TrafficManagerUserMetricsResource(client, TrafficManagerUserMetricsResource.CreateResourceIdentifier(Id.SubscriptionId))); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerTenantResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerTenantResource.cs new file mode 100644 index 000000000000..405d39ec4857 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/MockableTrafficManagerTenantResource.cs @@ -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 + { + /// Gets the TrafficManagerGeographicHierarchyResource. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() + { + return GetTrafficManagerGeographicHierarchy(default).Value; + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs deleted file mode 100644 index 597a96bd5314..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Azure.Core; - -namespace Azure.ResourceManager.TrafficManager -{ - /// - /// Class to overcome issue when the original resource is generated by swagger has "default" suffix in it. E.g. - /// "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default" - /// which generates HTTP 400 and simply does not work. - /// - internal partial class TrafficManagerUserMetricsKeysRestOperations - { - internal HttpMessage CreateGetRequest(string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointCollection.cs index c61d979028a4..8841c832fff8 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointCollection.cs @@ -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 { /// - /// 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 . + /// 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 . /// public partial class TrafficManagerEndpointCollection : ArmCollection, IEnumerable, IAsyncEnumerable { @@ -23,7 +25,7 @@ public partial class TrafficManagerEndpointCollection : ArmCollection, IEnumerab /// The client parameters to use in these operations. /// The identifier of the parent resource that is the target of operations. /// /// The parent profile data. - 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)); @@ -54,6 +56,95 @@ public virtual Pageable GetAll() return PageableHelpers.CreateEnumerable(_ => Page.FromValues(this._profileData.Endpoints, null, null), null, null); } + /// Creates or updates a Traffic Manager endpoint. + /// Completion option. + /// The type of the Traffic Manager endpoint to be created or updated. + /// The name of the Traffic Manager endpoint to be created or updated. + /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + { + return await CreateOrUpdateAsync(waitUntil, ParseEndpointType(endpointType), endpointName, data, cancellationToken).ConfigureAwait(false); + } + + /// Creates or updates a Traffic Manager endpoint. + /// Completion option. + /// The type of the Traffic Manager endpoint to be created or updated. + /// The name of the Traffic Manager endpoint to be created or updated. + /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + { + return CreateOrUpdate(waitUntil, ParseEndpointType(endpointType), endpointName, data, cancellationToken); + } + + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task> GetAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return await GetAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false); + } + + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual Response Get(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return Get(ParseEndpointType(endpointType), endpointName, cancellationToken); + } + + /// Checks to see if the resource exists in azure. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task> ExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return await ExistsAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false); + } + + /// Checks to see if the resource exists in azure. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual Response Exists(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return Exists(ParseEndpointType(endpointType), endpointName, cancellationToken); + } + + /// Tries to get details for this resource from the service. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task> GetIfExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return await GetIfExistsAsync(ParseEndpointType(endpointType), endpointName, cancellationToken).ConfigureAwait(false); + } + + /// Tries to get details for this resource from the service. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual NullableResponse 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 IEnumerable.GetEnumerator() { return GetAll().GetEnumerator(); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointResource.cs index 2d619a1b0473..bd8ab3c35948 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerEndpointResource.cs @@ -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 { - /// - /// Customizes validation of the resource name since default resource name of the TrafficManagerEndpoint has a template parameter baked in. - /// - public partial class TrafficManagerEndpointResource : ArmResource + public partial class TrafficManagerEndpointResource { - internal static void ValidateResourceId(ResourceIdentifier id) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The profileName. + /// The endpointType. + /// The endpointName. + [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)); + /// Deletes a Traffic Manager endpoint. + /// Completion option. + /// The cancellation token to use. + public virtual async Task 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 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return new TrafficManagerNonGenericArmOperation(operation); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a Traffic Manager endpoint. + /// Completion option. + /// The cancellation token to use. + 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 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return new TrafficManagerNonGenericArmOperation(operation); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerExtensions.cs new file mode 100644 index 000000000000..b1f034ab8b85 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerExtensions.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ComponentModel; +using Azure.ResourceManager.Resources; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Azure.ResourceManager.TrafficManager +{ + [CodeGenSuppress("GetTrafficManagerUserMetrics", typeof(SubscriptionResource))] + public static partial class TrafficManagerExtensions + { + /// Gets the TrafficManagerGeographicHierarchy. + /// The instance the method will execute against. + [EditorBrowsable(EditorBrowsableState.Never)] + public static TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy(this TenantResource tenantResource) + { + return GetMockableTrafficManagerTenantResource(tenantResource).GetTrafficManagerGeographicHierarchy(); + } + + /// Gets the TrafficManagerUserMetricsResource. + /// The instance the method will execute against. + /// An object representing a . + public static TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics(this SubscriptionResource subscriptionResource) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerUserMetrics(); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerNonGenericArmOperation.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerNonGenericArmOperation.cs new file mode 100644 index 000000000000..7dfe0656677f --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerNonGenericArmOperation.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.TrafficManager.Models; + +namespace Azure.ResourceManager.TrafficManager +{ + /// + /// Wraps a generic ArmOperation to provide backward-compatible non-generic ArmOperation return type. + /// + internal class TrafficManagerNonGenericArmOperation : ArmOperation + { + private readonly TrafficManagerArmOperation _inner; + + internal TrafficManagerNonGenericArmOperation(TrafficManagerArmOperation inner) + { + _inner = inner; + } + + public override string Id => _inner.Id; + + public override bool HasCompleted => _inner.HasCompleted; + + public override Response GetRawResponse() => _inner.GetRawResponse(); + + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _inner.UpdateStatus(cancellationToken); + + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _inner.UpdateStatusAsync(cancellationToken); + + public override RehydrationToken? GetRehydrationToken() => _inner.GetRehydrationToken(); + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerProfileResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerProfileResource.cs new file mode 100644 index 000000000000..9973e7dbe71a --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerProfileResource.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +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 +{ + public partial class TrafficManagerProfileResource + { + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + [ForwardsClientCalls] + public virtual async Task> GetTrafficManagerEndpointAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return await GetTrafficManagerEndpointAsync((TrafficManagerEndpointType)Enum.Parse(typeof(TrafficManagerEndpointType), endpointType, true), endpointName, cancellationToken).ConfigureAwait(false); + } + + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + [ForwardsClientCalls] + public virtual Response GetTrafficManagerEndpoint(string endpointType, string endpointName, CancellationToken cancellationToken = default) + { + return GetTrafficManagerEndpoint((TrafficManagerEndpointType)Enum.Parse(typeof(TrafficManagerEndpointType), endpointType, true), endpointName, cancellationToken); + } + + /// Deletes a Traffic Manager profile. + /// Completion option. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return new TrafficManagerNonGenericArmOperation(operation); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Deletes a Traffic Manager profile. + /// Completion option. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Delete"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return new TrafficManagerNonGenericArmOperation(operation); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerUserMetricsResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerUserMetricsResource.cs index 9be67342836a..80f9ef3bf46a 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerUserMetricsResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Customization/TrafficManagerUserMetricsResource.cs @@ -1,58 +1,66 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#nullable disable + using System; +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 { - /// - /// Class to overcome issue when the original resource is generated by swagger has "default" suffix in it. E.g. - /// "/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default" - /// which generates HTTP 400 and simply does not work. - /// + [CodeGenType("TrafficManagerUserMetricResource")] public partial class TrafficManagerUserMetricsResource { - /// Generate the resource identifier of a instance. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId) + /// Backward-compatible CreateOrUpdate. + /// Completion option. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + [ForwardsClientCalls] + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + return Update(waitUntil, cancellationToken); + } + + /// Backward-compatible CreateOrUpdateAsync. + /// Completion option. + /// The cancellation token to use. + [EditorBrowsable(EditorBrowsableState.Never)] + [ForwardsClientCalls] + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - var resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default"; - return new ResourceIdentifier(resourceId); + return await UpdateAsync(waitUntil, cancellationToken).ConfigureAwait(false); } - /// - /// Get the subscription-level key used for Real User Metrics collection. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default - /// - /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_Get - /// - /// - /// - /// - /// The method is added to overcome problem when the Get API returns resource id with the subscription part which - /// actually is an invalid ARM resource id. - /// + /// Delete a subscription-level key used for Real User Metrics collection. + /// Completion option. /// The cancellation token to use. - public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Get"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Delete"); scope.Start(); try { - var response = await _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.GetAsync(Id.SubscriptionId, cancellationToken).ConfigureAwait(false); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - - response.Value.Id = new ResourceIdentifier($"/subscriptions/{Id.SubscriptionId}{response.Value.Id}"); - - return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateDeleteRequest(Id.SubscriptionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return new TrafficManagerNonGenericArmOperation(operation); } catch (Exception e) { @@ -61,37 +69,30 @@ public virtual async Task> GetAsync( } } - /// - /// Get the subscription-level key used for Real User Metrics collection. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default - /// - /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_Get - /// - /// - /// - /// - /// The method is added to overcome problem when the Get API returns resource id with the subscription part which - /// actually is an invalid ARM resource id. - /// + /// Delete a subscription-level key used for Real User Metrics collection. + /// Completion option. /// The cancellation token to use. - public virtual Response Get(CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Get"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Delete"); scope.Start(); try { - var response = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.Get(Id.SubscriptionId, cancellationToken); - if (response.Value == null) - throw new RequestFailedException(response.GetRawResponse()); - - response.Value.Id = new ResourceIdentifier($"/subscriptions/{Id.SubscriptionId}{response.Value.Id}"); - - return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateDeleteRequest(Id.SubscriptionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response 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(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return new TrafficManagerNonGenericArmOperation(operation); } catch (Exception e) { diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ArmTrafficManagerModelFactory.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ArmTrafficManagerModelFactory.cs index 3f5c3451d09b..34e97475d1d6 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ArmTrafficManagerModelFactory.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ArmTrafficManagerModelFactory.cs @@ -5,21 +5,123 @@ #nullable disable +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmTrafficManagerModelFactory { - /// Initializes a new instance of . + + /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. + /// The name of the resource. + /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. + /// Resource tags. + /// The Azure Region where the resource lives. + /// The status of the Traffic Manager profile. + /// The traffic routing method of the Traffic Manager profile. + /// The DNS settings of the Traffic Manager profile. + /// The endpoint monitoring settings of the Traffic Manager profile. + /// The list of endpoints in the Traffic Manager profile. + /// Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase the cost of the Traffic Manage profile. + /// The list of allowed endpoint record types. + /// Maximum number of endpoints to be returned for MultiValue routing type. + /// A new instance for mocking. + public static TrafficManagerProfileData TrafficManagerProfileData(ResourceIdentifier id = default, string name = default, ResourceType? resourceType = default, IDictionary tags = default, AzureLocation? location = default, TrafficManagerProfileStatus? profileStatus = default, TrafficRoutingMethod? trafficRoutingMethod = default, TrafficManagerDnsConfig dnsConfig = default, TrafficManagerMonitorConfig monitorConfig = default, IEnumerable endpoints = default, TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default, IEnumerable allowedEndpointRecordTypes = default, long? maxReturn = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TrafficManagerProfileData( + id, + name, + resourceType, + additionalBinaryDataProperties: null, + tags, + location, + profileStatus is null && trafficRoutingMethod is null && dnsConfig is null && monitorConfig is null && endpoints is null && trafficViewEnrollmentStatus is null && allowedEndpointRecordTypes is null && maxReturn is null ? default : new ProfileProperties( + profileStatus, + trafficRoutingMethod, + dnsConfig, + monitorConfig, + (endpoints ?? new ChangeTrackingList()).ToList(), + trafficViewEnrollmentStatus, + (allowedEndpointRecordTypes ?? new ChangeTrackingList()).ToList(), + maxReturn, + null)); + } + + /// Class containing DNS settings in a Traffic Manager profile. + /// The relative DNS name provided by this Traffic Manager profile. This value is combined with the DNS domain name used by Azure Traffic Manager to form the fully-qualified domain name (FQDN) of the profile. + /// The fully-qualified domain name (FQDN) of the Traffic Manager profile. This is formed from the concatenation of the RelativeName with the DNS domain used by Azure Traffic Manager. + /// The DNS Time-To-Live (TTL), in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses provided by this Traffic Manager profile. + /// A new instance for mocking. + public static TrafficManagerDnsConfig TrafficManagerDnsConfig(string relativeName = default, string fqdn = default, long? ttl = default) + { + return new TrafficManagerDnsConfig(relativeName, fqdn, ttl, additionalBinaryDataProperties: null); + } + + /// Class containing endpoint monitoring settings in a Traffic Manager profile. + /// The profile-level monitoring status of the Traffic Manager profile. + /// The protocol (HTTP, HTTPS or TCP) used to probe for endpoint health. + /// The TCP port used to probe for endpoint health. + /// The path relative to the endpoint domain name used to probe for endpoint health. + /// The monitor interval for endpoints in this profile. This is the interval at which Traffic Manager will check the health of each endpoint in this profile. + /// The monitor timeout for endpoints in this profile. This is the time that Traffic Manager allows endpoints in this profile to response to the health check. + /// The number of consecutive failed health check that Traffic Manager tolerates before declaring an endpoint in this profile Degraded after the next failed health check. + /// List of custom headers. + /// List of expected status code ranges. + /// A new instance for mocking. + public static TrafficManagerMonitorConfig TrafficManagerMonitorConfig(TrafficManagerProfileMonitorStatus? profileMonitorStatus = default, TrafficManagerMonitorProtocol? protocol = default, long? port = default, string path = default, long? intervalInSeconds = default, long? timeoutInSeconds = default, long? toleratedNumberOfFailures = default, IEnumerable customHeaders = default, IEnumerable expectedStatusCodeRanges = default) + { + customHeaders ??= new ChangeTrackingList(); + expectedStatusCodeRanges ??= new ChangeTrackingList(); + + return new TrafficManagerMonitorConfig( + profileMonitorStatus, + protocol, + port, + path, + intervalInSeconds, + timeoutInSeconds, + toleratedNumberOfFailures, + customHeaders.ToList(), + expectedStatusCodeRanges.ToList(), + additionalBinaryDataProperties: null); + } + + /// The resource model definition for a ARM tracked top level resource. + /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. + /// The name of the resource. + /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. + /// Resource tags. + /// The Azure Region where the resource lives. + /// A new instance for mocking. + public static TrafficManagerTrackedResourceData TrafficManagerTrackedResourceData(ResourceIdentifier id = default, string name = default, ResourceType? resourceType = default, IDictionary tags = default, AzureLocation? location = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TrafficManagerTrackedResourceData( + id, + name, + resourceType, + additionalBinaryDataProperties: null, + tags, + location); + } + + /// Class representing a Traffic Manager Name Availability response. /// The relative name. /// Traffic Manager profile resource type. /// Describes whether the relative name is available or not. /// The reason why the name is not available, when applicable. /// Descriptive message that explains why the name is not available, when applicable. /// A new instance for mocking. - public static TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilityResult(string name = null, ResourceType? resourceType = null, bool? isNameAvailable = null, string unavailableReason = null, string message = null) + public static TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilityResult(string name = default, ResourceType? resourceType = default, bool? isNameAvailable = default, string unavailableReason = default, string message = default) { return new TrafficManagerNameAvailabilityResult( name, @@ -27,17 +129,32 @@ public static TrafficManagerNameAvailabilityResult TrafficManagerNameAvailabilit isNameAvailable, unavailableReason, message, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The relative DNS name provided by this Traffic Manager profile. This value is combined with the DNS domain name used by Azure Traffic Manager to form the fully-qualified domain name (FQDN) of the profile. - /// The fully-qualified domain name (FQDN) of the Traffic Manager profile. This is formed from the concatenation of the RelativeName with the DNS domain used by Azure Traffic Manager. - /// The DNS Time-To-Live (TTL), in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses provided by this Traffic Manager profile. - /// A new instance for mocking. - public static TrafficManagerDnsConfig TrafficManagerDnsConfig(string relativeName = null, string fqdn = null, long? ttl = null) + /// Class representing a region in the Geographic hierarchy used with the Geographic traffic routing method. + /// The code of the region. + /// The name of the region. + /// The list of Regions grouped under this Region in the Geographic Hierarchy. + /// A new instance for mocking. + public static TrafficManagerRegion TrafficManagerRegion(string code = default, string name = default, IEnumerable regions = default) + { + regions ??= new ChangeTrackingList(); + + return new TrafficManagerRegion(code, name, regions.ToList(), additionalBinaryDataProperties: null); + } + + /// Class representing a Traffic Manager HeatMap traffic flow properties. + /// The IP address that this query experience originated from. + /// The approximate latitude that these queries originated from. + /// The approximate longitude that these queries originated from. + /// The query experiences produced in this HeatMap calculation. + /// A new instance for mocking. + public static TrafficManagerHeatMapTrafficFlow TrafficManagerHeatMapTrafficFlow(IPAddress sourceIP = default, double? latitude = default, double? longitude = default, IEnumerable queryExperiences = default) { - return new TrafficManagerDnsConfig(relativeName, fqdn, ttl, serializedAdditionalRawData: null); + queryExperiences ??= new ChangeTrackingList(); + + return new TrafficManagerHeatMapTrafficFlow(sourceIP, latitude, longitude, queryExperiences.ToList(), additionalBinaryDataProperties: null); } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..da11a42e5529 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrafficManager.Models; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class ProfilesGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Profiles _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProfilesGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Profiles client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProfilesGetByResourceGroupAsyncCollectionResultOfT(Profiles client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ProfilesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProfilesGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + ProfileListResult result = ProfileListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupCollectionResultOfT.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..bfaab9ea8dfe --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrafficManager.Models; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class ProfilesGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Profiles _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of ProfilesGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Profiles client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProfilesGetByResourceGroupCollectionResultOfT(Profiles client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of ProfilesGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProfilesGetByResourceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + ProfileListResult result = ProfileListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..dc9a414a4781 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrafficManager.Models; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class ProfilesGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Profiles _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ProfilesGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Profiles client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProfilesGetBySubscriptionAsyncCollectionResultOfT(Profiles client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ProfilesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProfilesGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + ProfileListResult result = ProfileListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.GetTrafficManagerProfiles"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionCollectionResultOfT.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..77d4800e3a44 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/CollectionResults/ProfilesGetBySubscriptionCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.TrafficManager.Models; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class ProfilesGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Profiles _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of ProfilesGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Profiles client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public ProfilesGetBySubscriptionCollectionResultOfT(Profiles client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of ProfilesGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of ProfilesGetBySubscriptionCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + ProfileListResult result = ProfileListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.IsAbsoluteUri == true ? nextPage.AbsoluteUri : nextPage?.OriginalString, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.GetTrafficManagerProfiles"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerArmClient.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerArmClient.cs index 211c80d3307b..dbcfcbbb2ad6 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerArmClient.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableTrafficManagerArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableTrafficManagerArmClient for mocking. protected MockableTrafficManagerArmClient() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableTrafficManagerArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableTrafficManagerArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual TrafficManagerEndpointResource GetTrafficManagerEndpointResource(ResourceIdentifier id) @@ -46,10 +35,7 @@ public virtual TrafficManagerEndpointResource GetTrafficManagerEndpointResource( return new TrafficManagerEndpointResource(Client, id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual TrafficManagerProfileResource GetTrafficManagerProfileResource(ResourceIdentifier id) @@ -58,10 +44,7 @@ public virtual TrafficManagerProfileResource GetTrafficManagerProfileResource(Re return new TrafficManagerProfileResource(Client, id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchyResource(ResourceIdentifier id) @@ -70,10 +53,7 @@ public virtual TrafficManagerGeographicHierarchyResource GetTrafficManagerGeogra return new TrafficManagerGeographicHierarchyResource(Client, id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(ResourceIdentifier id) @@ -82,10 +62,7 @@ public virtual TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(Re return new TrafficManagerHeatMapResource(Client, id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual TrafficManagerUserMetricsResource GetTrafficManagerUserMetricsResource(ResourceIdentifier id) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerResourceGroupResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerResourceGroupResource.cs index 9caa7c8b4e90..537d96460073 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerResourceGroupResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerResourceGroupResource.cs @@ -8,33 +8,31 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableTrafficManagerResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableTrafficManagerResourceGroupResource for mocking. protected MockableTrafficManagerResourceGroupResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableTrafficManagerResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of TrafficManagerProfileResources in the ResourceGroupResource. - /// An object representing collection of TrafficManagerProfileResources and their operations over a TrafficManagerProfileResource. + /// Gets a collection of TrafficManagerProfiles in the . + /// An object representing collection of TrafficManagerProfiles and their operations over a TrafficManagerProfileResource. public virtual TrafficManagerProfileCollection GetTrafficManagerProfiles() { return GetCachedClient(client => new TrafficManagerProfileCollection(client, Id)); @@ -44,20 +42,16 @@ public virtual TrafficManagerProfileCollection GetTrafficManagerProfiles() /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// @@ -68,6 +62,8 @@ public virtual TrafficManagerProfileCollection GetTrafficManagerProfiles() [ForwardsClientCalls] public virtual async Task> GetTrafficManagerProfileAsync(string profileName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + return await GetTrafficManagerProfiles().GetAsync(profileName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +71,16 @@ public virtual async Task> GetTrafficMan /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// @@ -99,6 +91,8 @@ public virtual async Task> GetTrafficMan [ForwardsClientCalls] public virtual Response GetTrafficManagerProfile(string profileName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + return GetTrafficManagerProfiles().Get(profileName, cancellationToken); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerSubscriptionResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerSubscriptionResource.cs index fb1600266767..dabf60b55e35 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerSubscriptionResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerSubscriptionResource.cs @@ -8,122 +8,181 @@ using System; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrafficManager; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableTrafficManagerSubscriptionResource : ArmResource { - private ClientDiagnostics _trafficManagerProfileProfilesClientDiagnostics; - private ProfilesRestOperations _trafficManagerProfileProfilesRestClient; + private ClientDiagnostics _profilesClientDiagnostics; + private Profiles _profilesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableTrafficManagerSubscriptionResource for mocking. protected MockableTrafficManagerSubscriptionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableTrafficManagerSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics TrafficManagerProfileProfilesClientDiagnostics => _trafficManagerProfileProfilesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerProfileResource.ResourceType.Namespace, Diagnostics); - private ProfilesRestOperations TrafficManagerProfileProfilesRestClient => _trafficManagerProfileProfilesRestClient ??= new ProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(TrafficManagerProfileResource.ResourceType)); + private ClientDiagnostics ProfilesClientDiagnostics => _profilesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.TrafficManager.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) + private Profiles ProfilesRestClient => _profilesRestClient ??= new Profiles(ProfilesClientDiagnostics, Pipeline, Endpoint, "2022-04-01"); + + /// + /// Get the subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual async Task> GetTrafficManagerUserMetricAsync(CancellationToken cancellationToken = default) { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; + return await GetTrafficManagerUserMetrics().GetAsync(cancellationToken).ConfigureAwait(false); } - /// Gets an object representing a TrafficManagerUserMetricsResource along with the instance operations that can be performed on it in the SubscriptionResource. - /// Returns a object. - public virtual TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics() + /// + /// Get the subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual Response GetTrafficManagerUserMetric(CancellationToken cancellationToken = default) { - return new TrafficManagerUserMetricsResource(Client, Id.AppendProviderResource("Microsoft.Network", "trafficManagerUserMetricsKeys", "default")); + return GetTrafficManagerUserMetrics().Get(cancellationToken); } /// - /// Checks the availability of a Traffic Manager Relative DNS name. + /// Lists all Traffic Manager profiles within a subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2 + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles. + /// + /// + /// Operation Id. + /// Profiles_ListBySubscription. /// /// - /// Operation Id - /// Profiles_CheckTrafficManagerNameAvailabilityV2 + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetTrafficManagerProfilesAsync(CancellationToken cancellationToken = default) + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ProfilesGetBySubscriptionAsyncCollectionResultOfT(ProfilesRestClient, Id.SubscriptionId, context), data => new TrafficManagerProfileResource(Client, data)); + } + + /// + /// Lists all Traffic Manager profiles within a subscription. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. /// The cancellation token to use. - /// is null. - public virtual async Task> CheckTrafficManagerNameAvailabilityV2Async(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetTrafficManagerProfiles(CancellationToken cancellationToken = default) { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = TrafficManagerProfileProfilesClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.CheckTrafficManagerNameAvailabilityV2"); - scope.Start(); - try - { - var response = await TrafficManagerProfileProfilesRestClient.CheckTrafficManagerNameAvailabilityV2Async(Id.SubscriptionId, content, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) + RequestContext context = new RequestContext { - scope.Failed(e); - throw; - } + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ProfilesGetBySubscriptionCollectionResultOfT(ProfilesRestClient, Id.SubscriptionId, context), data => new TrafficManagerProfileResource(Client, data)); } /// /// Checks the availability of a Traffic Manager Relative DNS name. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2 - /// - /// - /// Operation Id - /// Profiles_CheckTrafficManagerNameAvailabilityV2 + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// ProfilesOperationGroup_CheckTrafficManagerNameAvailabilityV2. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The request body. /// The cancellation token to use. /// is null. - public virtual Response CheckTrafficManagerNameAvailabilityV2(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + public virtual async Task> CheckTrafficManagerNameAvailabilityV2Async(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - using var scope = TrafficManagerProfileProfilesClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.CheckTrafficManagerNameAvailabilityV2"); + using DiagnosticScope scope = ProfilesClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.CheckTrafficManagerNameAvailabilityV2"); scope.Start(); try { - var response = TrafficManagerProfileProfilesRestClient.CheckTrafficManagerNameAvailabilityV2(Id.SubscriptionId, content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ProfilesRestClient.CreateCheckTrafficManagerNameAvailabilityV2Request(Id.SubscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -134,61 +193,51 @@ public virtual Response CheckTrafficManage } /// - /// Lists all Traffic Manager profiles within a subscription. + /// Checks the availability of a Traffic Manager Relative DNS name. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles - /// - /// - /// Operation Id - /// Profiles_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// ProfilesOperationGroup_CheckTrafficManagerNameAvailabilityV2. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// + /// The request body. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetTrafficManagerProfilesAsync(CancellationToken cancellationToken = default) + /// is null. + public virtual Response CheckTrafficManagerNameAvailabilityV2(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => TrafficManagerProfileProfilesRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TrafficManagerProfileResource(Client, TrafficManagerProfileData.DeserializeTrafficManagerProfileData(e)), TrafficManagerProfileProfilesClientDiagnostics, Pipeline, "MockableTrafficManagerSubscriptionResource.GetTrafficManagerProfiles", "value", null, cancellationToken); - } + Argument.AssertNotNull(content, nameof(content)); - /// - /// Lists all Traffic Manager profiles within a subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles - /// - /// - /// Operation Id - /// Profiles_ListBySubscription - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetTrafficManagerProfiles(CancellationToken cancellationToken = default) - { - HttpMessage FirstPageRequest(int? pageSizeHint) => TrafficManagerProfileProfilesRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TrafficManagerProfileResource(Client, TrafficManagerProfileData.DeserializeTrafficManagerProfileData(e)), TrafficManagerProfileProfilesClientDiagnostics, Pipeline, "MockableTrafficManagerSubscriptionResource.GetTrafficManagerProfiles", "value", null, cancellationToken); + using DiagnosticScope scope = ProfilesClientDiagnostics.CreateScope("MockableTrafficManagerSubscriptionResource.CheckTrafficManagerNameAvailabilityV2"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ProfilesRestClient.CreateCheckTrafficManagerNameAvailabilityV2Request(Id.SubscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerTenantResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerTenantResource.cs index dd7bfc92723a..a9d7073961f2 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerTenantResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/MockableTrafficManagerTenantResource.cs @@ -8,79 +8,132 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrafficManager; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager.Mocking { - /// A class to add extension methods to TenantResource. + /// A class to add extension methods to . public partial class MockableTrafficManagerTenantResource : ArmResource { - private ClientDiagnostics _trafficManagerProfileProfilesClientDiagnostics; - private ProfilesRestOperations _trafficManagerProfileProfilesRestClient; + private ClientDiagnostics _profilesClientDiagnostics; + private Profiles _profilesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableTrafficManagerTenantResource for mocking. protected MockableTrafficManagerTenantResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableTrafficManagerTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics TrafficManagerProfileProfilesClientDiagnostics => _trafficManagerProfileProfilesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerProfileResource.ResourceType.Namespace, Diagnostics); - private ProfilesRestOperations TrafficManagerProfileProfilesRestClient => _trafficManagerProfileProfilesRestClient ??= new ProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(TrafficManagerProfileResource.ResourceType)); + private ClientDiagnostics ProfilesClientDiagnostics => _profilesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.TrafficManager.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) + private Profiles ProfilesRestClient => _profilesRestClient ??= new Profiles(ProfilesClientDiagnostics, Pipeline, Endpoint, "2022-04-01"); + + /// Gets a collection of TrafficManagerGeographicHierarchies in the . + /// An object representing collection of TrafficManagerGeographicHierarchies and their operations over a TrafficManagerGeographicHierarchyResource. + public virtual TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies() { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; + return GetCachedClient(client => new TrafficManagerGeographicHierarchyCollection(client, Id)); } - /// Gets an object representing a TrafficManagerGeographicHierarchyResource along with the instance operations that can be performed on it in the TenantResource. - /// Returns a object. - public virtual TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy() + /// + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual async Task> GetTrafficManagerGeographicHierarchyAsync(CancellationToken cancellationToken = default) { - return new TrafficManagerGeographicHierarchyResource(Client, Id.AppendProviderResource("Microsoft.Network", "trafficManagerGeographicHierarchies", "default")); + return await GetTrafficManagerGeographicHierarchies().GetAsync(cancellationToken).ConfigureAwait(false); } /// - /// Checks the availability of a Traffic Manager Relative DNS name. + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. /// /// - /// Request Path - /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. /// + /// + /// + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual Response GetTrafficManagerGeographicHierarchy(CancellationToken cancellationToken = default) + { + return GetTrafficManagerGeographicHierarchies().Get(cancellationToken); + } + + /// + /// Checks the availability of a Traffic Manager Relative DNS name. + /// /// - /// Operation Id - /// Profiles_CheckTrafficManagerRelativeDnsNameAvailability + /// Request Path. + /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// ProfilesOperationGroup_CheckTrafficManagerRelativeDnsNameAvailability. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The request body. /// The cancellation token to use. /// is null. public virtual async Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - using var scope = TrafficManagerProfileProfilesClientDiagnostics.CreateScope("MockableTrafficManagerTenantResource.CheckTrafficManagerRelativeDnsNameAvailability"); + using DiagnosticScope scope = ProfilesClientDiagnostics.CreateScope("MockableTrafficManagerTenantResource.CheckTrafficManagerRelativeDnsNameAvailability"); scope.Start(); try { - var response = await TrafficManagerProfileProfilesRestClient.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ProfilesRestClient.CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(TrafficManagerRelativeDnsNameAvailabilityContent.ToRequestContent(content), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -94,35 +147,41 @@ public virtual async Task> CheckT /// Checks the availability of a Traffic Manager Relative DNS name. /// /// - /// Request Path - /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability - /// - /// - /// Operation Id - /// Profiles_CheckTrafficManagerRelativeDnsNameAvailability + /// Request Path. + /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// ProfilesOperationGroup_CheckTrafficManagerRelativeDnsNameAvailability. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The request body. /// The cancellation token to use. /// is null. public virtual Response CheckTrafficManagerRelativeDnsNameAvailability(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(content, nameof(content)); - using var scope = TrafficManagerProfileProfilesClientDiagnostics.CreateScope("MockableTrafficManagerTenantResource.CheckTrafficManagerRelativeDnsNameAvailability"); + using DiagnosticScope scope = ProfilesClientDiagnostics.CreateScope("MockableTrafficManagerTenantResource.CheckTrafficManagerRelativeDnsNameAvailability"); scope.Start(); try { - var response = TrafficManagerProfileProfilesRestClient.CheckTrafficManagerRelativeDnsNameAvailability(content, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = ProfilesRestClient.CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(TrafficManagerRelativeDnsNameAvailabilityContent.ToRequestContent(content), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerNameAvailabilityResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/TrafficManagerExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/TrafficManagerExtensions.cs index 4a930befa5b6..d13cc7ff8a32 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/TrafficManagerExtensions.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Extensions/TrafficManagerExtensions.cs @@ -8,7 +8,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; using Azure.ResourceManager.TrafficManager.Mocking; using Azure.ResourceManager.TrafficManager.Models; @@ -18,35 +20,38 @@ namespace Azure.ResourceManager.TrafficManager /// A class to add extension methods to Azure.ResourceManager.TrafficManager. public static partial class TrafficManagerExtensions { + /// private static MockableTrafficManagerArmClient GetMockableTrafficManagerArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableTrafficManagerArmClient(client0)); + return client.GetCachedClient(client0 => new MockableTrafficManagerArmClient(client0, ResourceIdentifier.Root)); } - private static MockableTrafficManagerResourceGroupResource GetMockableTrafficManagerResourceGroupResource(ArmResource resource) + /// + private static MockableTrafficManagerResourceGroupResource GetMockableTrafficManagerResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableTrafficManagerResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableTrafficManagerResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableTrafficManagerSubscriptionResource GetMockableTrafficManagerSubscriptionResource(ArmResource resource) + /// + private static MockableTrafficManagerSubscriptionResource GetMockableTrafficManagerSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableTrafficManagerSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableTrafficManagerSubscriptionResource(client, subscriptionResource.Id)); } - private static MockableTrafficManagerTenantResource GetMockableTrafficManagerTenantResource(ArmResource resource) + /// + private static MockableTrafficManagerTenantResource GetMockableTrafficManagerTenantResource(TenantResource tenantResource) { - return resource.GetCachedClient(client => new MockableTrafficManagerTenantResource(client, resource.Id)); + return tenantResource.GetCachedClient(client => new MockableTrafficManagerTenantResource(client, tenantResource.Id)); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -58,14 +63,13 @@ public static TrafficManagerEndpointResource GetTrafficManagerEndpointResource(t } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -77,14 +81,13 @@ public static TrafficManagerProfileResource GetTrafficManagerProfileResource(thi } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -96,14 +99,13 @@ public static TrafficManagerGeographicHierarchyResource GetTrafficManagerGeograp } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -115,14 +117,13 @@ public static TrafficManagerHeatMapResource GetTrafficManagerHeatMapResource(thi } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -134,15 +135,15 @@ public static TrafficManagerUserMetricsResource GetTrafficManagerUserMetricsReso } /// - /// Gets a collection of TrafficManagerProfileResources in the ResourceGroupResource. + /// Gets a collection of TrafficManagerProfiles in the /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// is null. - /// An object representing collection of TrafficManagerProfileResources and their operations over a TrafficManagerProfileResource. + /// An object representing collection of TrafficManagerProfiles and their operations over a TrafficManagerProfileResource. public static TrafficManagerProfileCollection GetTrafficManagerProfiles(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -152,34 +153,15 @@ public static TrafficManagerProfileCollection GetTrafficManagerProfiles(this Res /// /// Gets a Traffic Manager profile. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static async Task> GetTrafficManagerProfileAsync(this ResourceGroupResource resourceGroupResource, string profileName, CancellationToken cancellationToken = default) { @@ -190,34 +172,15 @@ public static async Task> GetTrafficMana /// /// Gets a Traffic Manager profile. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static Response GetTrafficManagerProfile(this ResourceGroupResource resourceGroupResource, string profileName, CancellationToken cancellationToken = default) { @@ -227,212 +190,177 @@ public static Response GetTrafficManagerProfile(t } /// - /// Gets an object representing a TrafficManagerUserMetricsResource along with the instance operations that can be performed on it in the SubscriptionResource. + /// Get the subscription-level key used for Real User Metrics collection. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. + /// The cancellation token to use. /// is null. - /// Returns a object. - public static TrafficManagerUserMetricsResource GetTrafficManagerUserMetrics(this SubscriptionResource subscriptionResource) + [ForwardsClientCalls] + public static async Task> GetTrafficManagerUserMetricAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerUserMetrics(); + return await GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerUserMetricAsync(cancellationToken).ConfigureAwait(false); } /// - /// Checks the availability of a Traffic Manager Relative DNS name. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2 - /// + /// Get the subscription-level key used for Real User Metrics collection. /// - /// Operation Id - /// Profiles_CheckTrafficManagerNameAvailabilityV2 - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The the method will execute against. /// The cancellation token to use. - /// or is null. - public static async Task> CheckTrafficManagerNameAvailabilityV2Async(this SubscriptionResource subscriptionResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + /// is null. + [ForwardsClientCalls] + public static Response GetTrafficManagerUserMetric(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return await GetMockableTrafficManagerSubscriptionResource(subscriptionResource).CheckTrafficManagerNameAvailabilityV2Async(content, cancellationToken).ConfigureAwait(false); + return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerUserMetric(cancellationToken); } /// - /// Checks the availability of a Traffic Manager Relative DNS name. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2 - /// - /// - /// Operation Id - /// Profiles_CheckTrafficManagerNameAvailabilityV2 - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// + /// Lists all Traffic Manager profiles within a subscription. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The the method will execute against. /// The cancellation token to use. - /// or is null. - public static Response CheckTrafficManagerNameAvailabilityV2(this SubscriptionResource subscriptionResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetTrafficManagerProfilesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).CheckTrafficManagerNameAvailabilityV2(content, cancellationToken); + return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerProfilesAsync(cancellationToken); } /// /// Lists all Traffic Manager profiles within a subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles - /// - /// - /// Operation Id - /// Profiles_ListBySubscription - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. - public static AsyncPageable GetTrafficManagerProfilesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetTrafficManagerProfiles(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerProfilesAsync(cancellationToken); + return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerProfiles(cancellationToken); } /// - /// Lists all Traffic Manager profiles within a subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles - /// - /// - /// Operation Id - /// Profiles_ListBySubscription - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// + /// Checks the availability of a Traffic Manager Relative DNS name. /// - /// Resource - /// + /// Mocking. + /// To mock this method, please mock instead. /// - /// + /// + /// The the method will execute against. + /// The request body. + /// The cancellation token to use. + /// is null. + public static async Task> CheckTrafficManagerNameAvailabilityV2Async(this SubscriptionResource subscriptionResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableTrafficManagerSubscriptionResource(subscriptionResource).CheckTrafficManagerNameAvailabilityV2Async(content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks the availability of a Traffic Manager Relative DNS name. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. /// is null. - /// A collection of that may take multiple service requests to iterate over. - public static Pageable GetTrafficManagerProfiles(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + public static Response CheckTrafficManagerNameAvailabilityV2(this SubscriptionResource subscriptionResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); - return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).GetTrafficManagerProfiles(cancellationToken); + return GetMockableTrafficManagerSubscriptionResource(subscriptionResource).CheckTrafficManagerNameAvailabilityV2(content, cancellationToken); } /// - /// Gets an object representing a TrafficManagerGeographicHierarchyResource along with the instance operations that can be performed on it in the TenantResource. + /// Gets a collection of TrafficManagerGeographicHierarchies in the /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// is null. - /// Returns a object. - public static TrafficManagerGeographicHierarchyResource GetTrafficManagerGeographicHierarchy(this TenantResource tenantResource) + /// An object representing collection of TrafficManagerGeographicHierarchies and their operations over a TrafficManagerGeographicHierarchyResource. + public static TrafficManagerGeographicHierarchyCollection GetTrafficManagerGeographicHierarchies(this TenantResource tenantResource) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); - return GetMockableTrafficManagerTenantResource(tenantResource).GetTrafficManagerGeographicHierarchy(); + return GetMockableTrafficManagerTenantResource(tenantResource).GetTrafficManagerGeographicHierarchies(); } /// - /// Checks the availability of a Traffic Manager Relative DNS name. - /// - /// - /// Request Path - /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability - /// - /// - /// Operation Id - /// Profiles_CheckTrafficManagerRelativeDnsNameAvailability - /// + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. /// - /// Default Api Version - /// 2024-04-01-preview + /// Mocking. + /// To mock this method, please mock instead. /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static async Task> GetTrafficManagerGeographicHierarchyAsync(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return await GetMockableTrafficManagerTenantResource(tenantResource).GetTrafficManagerGeographicHierarchyAsync(cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. /// - /// Resource - /// + /// Mocking. + /// To mock this method, please mock instead. /// - /// + /// + /// The the method will execute against. + /// The cancellation token to use. + /// is null. + [ForwardsClientCalls] + public static Response GetTrafficManagerGeographicHierarchy(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableTrafficManagerTenantResource(tenantResource).GetTrafficManagerGeographicHierarchy(cancellationToken); + } + + /// + /// Checks the availability of a Traffic Manager Relative DNS name. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static async Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(this TenantResource tenantResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); @@ -442,33 +370,15 @@ public static async Task> CheckTr /// /// Checks the availability of a Traffic Manager Relative DNS name. - /// - /// - /// Request Path - /// /providers/Microsoft.Network/checkTrafficManagerNameAvailability - /// /// - /// Operation Id - /// Profiles_CheckTrafficManagerRelativeDnsNameAvailability - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + /// The the method will execute against. + /// The request body. /// The cancellation token to use. - /// or is null. + /// is null. public static Response CheckTrafficManagerRelativeDnsNameAvailability(this TenantResource tenantResource, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tenantResource, nameof(tenantResource)); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Argument.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Argument.cs index 1669ef13651c..0b6f65717581 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Argument.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.TrafficManager { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) throw new ArgumentException("Value cannot be an empty string.", name); } } - - public static void AssertNotNullOrWhiteSpace(string value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); - } - } - - public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable - { - if (value.Equals(default)) - { - throw new ArgumentException("Value cannot be empty.", name); - } - } - - public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable - { - if (minimum.CompareTo(value) > 0) - { - throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); - } - if (maximum.CompareTo(value) < 0) - { - throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); - } - } - - public static void AssertEnumDefined(Type enumType, object value, string name) - { - if (!Enum.IsDefined(enumType, value)) - { - throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); - } - } - - public static T CheckNotNull(T value, string name) - where T : class - { - AssertNotNull(value, name); - return value; - } - - public static string CheckNotNullOrEmpty(string value, string name) - { - AssertNotNullOrEmpty(value, name); - return value; - } - - public static void AssertNull(T value, string name, string message = null) - { - if (value != null) - { - throw new ArgumentException(message ?? "Value must be null.", name); - } - } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..62f20b8543b0 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingDictionary.cs index c3e30e8370fa..db13a936e200 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.TrafficManager { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerDictionary == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + /// Gets the Keys. public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + /// Gets the Values. public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + /// Gets or sets the value associated with the specified key. public TValue this[TKey key] { get @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) return EnsureDictionary().Remove(item); } + /// The key. + /// The value to add. public void Add(TKey key, TValue value) { EnsureDictionary().Add(key, value); } + /// The key to search for. public bool ContainsKey(TKey key) { if (IsUndefined) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingList.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingList.cs index 698d264603f8..e9784d436037 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.TrafficManager { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerList == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureList().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + /// Gets or sets the value associated with the specified key. public T this[int index] { get @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) return EnsureList().IndexOf(item); } + /// The inner list. + /// The item. public void Insert(int index, T item) { EnsureList().Insert(index, item); } + /// The inner list. public void RemoveAt(int index) { if (IsUndefined) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..c1fb34ba42dc --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.TrafficManager +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ErrorResult.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..4a4de8e3f750 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ModelSerializationExtensions.cs index 89d31033802f..8024effa97df 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/ModelSerializationExtensions.cs @@ -10,19 +10,18 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using System.Runtime.InteropServices; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.TrafficManager { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +47,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var jsonProperty in element.EnumerateObject()) { dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); } return dictionary; case JsonValueKind.Array: - var list = new List(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +92,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +106,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) { - throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); } public static string GetRequiredString(this JsonElement element) { - var value = element.GetString(); + string value = element.GetString(); if (value == null) { throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); @@ -181,9 +180,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -260,150 +256,13 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo writer.WriteObjectValue(value, options); } - internal static bool IsSentinelValue(BinaryData value) - { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } - - internal static class TypeFormatters + public static BinaryData GetUtf8Bytes(this JsonElement element) { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Optional.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Optional.cs index ce0b11aaeb9e..2a4f9503c946 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Optional.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.TrafficManager { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/PageableWrapper.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..8ba8c4847e62 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.TrafficManager +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..4a6f377d6ea9 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.TrafficManager +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public static void UpdateQuery(this RawRequestUriBuilder builder, string name, string value) + { + string currentQuery = builder.Query; + string searchPattern = string.Concat(name, "="); + int paramStartIndex = -1; + if (currentQuery.StartsWith(string.Concat("?", searchPattern))) + { + paramStartIndex = 1; + } + if (paramStartIndex == -1) + { + string prefixedPattern = string.Concat("&", searchPattern); + int prefixedIndex = currentQuery.IndexOf(prefixedPattern); + if (prefixedIndex >= 0) + { + paramStartIndex = prefixedIndex + 1; + } + } + if (paramStartIndex >= 0) + { + int valueStartIndex = paramStartIndex + searchPattern.Length; + int valueEndIndex = currentQuery.IndexOf('&', valueStartIndex); + if (valueEndIndex == -1) + { + valueEndIndex = currentQuery.Length; + } + string beforeParam = currentQuery.Substring(0, valueStartIndex); + string afterParam = currentQuery.Substring(valueEndIndex); + string newQuery = string.Concat(beforeParam, value, afterParam); + builder.Query = newQuery; + } + else + { + builder.AppendQuery(name, value, true); + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RequestContextExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..a1408081ce60 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.TrafficManager +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/SerializationFormat.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..c29a856f2e4e --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.TrafficManager +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/TypeFormatters.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..f2c8d0d65873 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.TrafficManager +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Utf8JsonRequestContent.cs index 7d342fba206a..d1cbeb08923a 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.TrafficManager { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) { JsonWriter.Flush(); _content.WriteTo(stream, cancellationToken); } + /// public override bool TryComputeLength(out long length) { length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperation.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperation.cs deleted file mode 100644 index ac4139933003..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperation.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Core.Pipeline; - -namespace Azure.ResourceManager.TrafficManager -{ -#pragma warning disable SA1649 // File name should match first type name - internal class TrafficManagerArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name - { - private readonly OperationInternal _operation; - private readonly RehydrationToken? _completeRehydrationToken; - private readonly NextLinkOperationImplementation _nextLinkOperation; - private readonly string _operationId; - - /// Initializes a new instance of TrafficManagerArmOperation for mocking. - protected TrafficManagerArmOperation() - { - } - - internal TrafficManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) - { - _operation = OperationInternal.Succeeded(response); - _completeRehydrationToken = rehydrationToken; - _operationId = GetOperationId(rehydrationToken); - } - - internal TrafficManagerArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) - { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) - { - _nextLinkOperation = nextLinkOperationValue; - _operationId = _nextLinkOperation.OperationId; - } - else - { - _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); - _operationId = GetOperationId(_completeRehydrationToken); - } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "TrafficManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); - } - - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerTrafficManagerContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// - public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// - public override bool HasCompleted => _operation.HasCompleted; - - /// - public override Response GetRawResponse() => _operation.RawResponse; - - /// - public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - - /// - public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - - /// - public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); - - /// - public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); - - /// - public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); - - /// - public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperationOfT.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperationOfT.cs index 95c26692106b..4b756b3c633c 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperationOfT.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/LongRunningOperation/TrafficManagerArmOperationOfT.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.TrafficManager { -#pragma warning disable SA1649 // File name should match first type name - internal class TrafficManagerArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class TrafficManagerArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected TrafficManagerArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal TrafficManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal TrafficManagerArmOperation(Response response, RehydrationToken? rehy _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal TrafficManagerArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,54 +59,55 @@ internal TrafficManagerArmOperation(IOperationSource source, ClientDiagnostic _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "TrafficManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "TrafficManagerArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerTrafficManagerContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// + /// Gets the Id. public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// + /// Gets the Value. public override T Value => _operation.Value; - /// + /// Gets the HasValue. public override bool HasValue => _operation.HasValue; - /// + /// Gets the HasCompleted. public override bool HasCompleted => _operation.HasCompleted; - /// + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); - /// + /// public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AllowedEndpointRecordType.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AllowedEndpointRecordType.cs index 61aa7a088aa3..2ccd52a5c563 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AllowedEndpointRecordType.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AllowedEndpointRecordType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,44 +15,63 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct AllowedEndpointRecordType : IEquatable { private readonly string _value; + private const string DomainNameValue = "DomainName"; + private const string IPv4AddressValue = "IPv4Address"; + private const string IPv6AddressValue = "IPv6Address"; + private const string AnyValue = "Any"; /// Initializes a new instance of . + /// The value. /// is null. public AllowedEndpointRecordType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DomainNameValue = "DomainName"; - private const string IPv4AddressValue = "IPv4Address"; - private const string IPv6AddressValue = "IPv6Address"; - private const string AnyValue = "Any"; + _value = value; + } - /// DomainName. + /// Gets the DomainName. public static AllowedEndpointRecordType DomainName { get; } = new AllowedEndpointRecordType(DomainNameValue); - /// IPv4Address. + + /// Gets the IPv4Address. public static AllowedEndpointRecordType IPv4Address { get; } = new AllowedEndpointRecordType(IPv4AddressValue); - /// IPv6Address. + + /// Gets the IPv6Address. public static AllowedEndpointRecordType IPv6Address { get; } = new AllowedEndpointRecordType(IPv6AddressValue); - /// Any. + + /// Gets the Any. public static AllowedEndpointRecordType Any { get; } = new AllowedEndpointRecordType(AnyValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AllowedEndpointRecordType left, AllowedEndpointRecordType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(AllowedEndpointRecordType left, AllowedEndpointRecordType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AllowedEndpointRecordType(string value) => new AllowedEndpointRecordType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AllowedEndpointRecordType?(string value) => value == null ? null : new AllowedEndpointRecordType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is AllowedEndpointRecordType other && Equals(other); - /// + + /// public bool Equals(AllowedEndpointRecordType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AzureResourceManagerTrafficManagerContext.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AzureResourceManagerTrafficManagerContext.cs index afe00e73a347..b9c90f928b7a 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AzureResourceManagerTrafficManagerContext.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/AzureResourceManagerTrafficManagerContext.cs @@ -12,10 +12,15 @@ namespace Azure.ResourceManager.TrafficManager { /// /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// For more information /// + [ModelReaderWriterBuildable(typeof(EndpointProperties))] [ModelReaderWriterBuildable(typeof(ExpectedStatusCodeRangeInfo))] - [ModelReaderWriterBuildable(typeof(ResponseError))] + [ModelReaderWriterBuildable(typeof(GeographicHierarchyProperties))] + [ModelReaderWriterBuildable(typeof(HeatMapProperties))] + [ModelReaderWriterBuildable(typeof(ProfileListResult))] + [ModelReaderWriterBuildable(typeof(ProfileProperties))] + [ModelReaderWriterBuildable(typeof(TrafficManagerDeleteOperationResult))] [ModelReaderWriterBuildable(typeof(TrafficManagerDnsConfig))] [ModelReaderWriterBuildable(typeof(TrafficManagerEndpointCustomHeaderInfo))] [ModelReaderWriterBuildable(typeof(TrafficManagerEndpointData))] @@ -32,7 +37,6 @@ namespace Azure.ResourceManager.TrafficManager [ModelReaderWriterBuildable(typeof(TrafficManagerMonitorConfigCustomHeaderInfo))] [ModelReaderWriterBuildable(typeof(TrafficManagerNameAvailabilityResult))] [ModelReaderWriterBuildable(typeof(TrafficManagerProfileData))] - [ModelReaderWriterBuildable(typeof(TrafficManagerProfileListResult))] [ModelReaderWriterBuildable(typeof(TrafficManagerProfileResource))] [ModelReaderWriterBuildable(typeof(TrafficManagerProxyResourceData))] [ModelReaderWriterBuildable(typeof(TrafficManagerRegion))] @@ -41,6 +45,7 @@ namespace Azure.ResourceManager.TrafficManager [ModelReaderWriterBuildable(typeof(TrafficManagerTrackedResourceData))] [ModelReaderWriterBuildable(typeof(TrafficManagerUserMetricData))] [ModelReaderWriterBuildable(typeof(TrafficManagerUserMetricsResource))] + [ModelReaderWriterBuildable(typeof(UserMetricsProperties))] public partial class AzureResourceManagerTrafficManagerContext : ModelReaderWriterContext { } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.Serialization.cs new file mode 100644 index 000000000000..04aaeede9744 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.Serialization.cs @@ -0,0 +1,390 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager endpoint properties. + internal partial class EndpointProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EndpointProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEndpointProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EndpointProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(EndpointProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + EndpointProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EndpointProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TargetResourceId)) + { + writer.WritePropertyName("targetResourceId"u8); + writer.WriteStringValue(TargetResourceId); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsDefined(EndpointStatus)) + { + writer.WritePropertyName("endpointStatus"u8); + writer.WriteStringValue(EndpointStatus.Value.ToString()); + } + if (Optional.IsDefined(Weight)) + { + writer.WritePropertyName("weight"u8); + writer.WriteNumberValue(Weight.Value); + } + if (Optional.IsDefined(Priority)) + { + writer.WritePropertyName("priority"u8); + writer.WriteNumberValue(Priority.Value); + } + if (Optional.IsDefined(EndpointLocation)) + { + writer.WritePropertyName("endpointLocation"u8); + writer.WriteStringValue(EndpointLocation); + } + if (Optional.IsDefined(EndpointMonitorStatus)) + { + writer.WritePropertyName("endpointMonitorStatus"u8); + writer.WriteStringValue(EndpointMonitorStatus.Value.ToString()); + } + if (Optional.IsDefined(MinChildEndpoints)) + { + writer.WritePropertyName("minChildEndpoints"u8); + writer.WriteNumberValue(MinChildEndpoints.Value); + } + if (Optional.IsDefined(MinChildEndpointsIPv4)) + { + writer.WritePropertyName("minChildEndpointsIPv4"u8); + writer.WriteNumberValue(MinChildEndpointsIPv4.Value); + } + if (Optional.IsDefined(MinChildEndpointsIPv6)) + { + writer.WritePropertyName("minChildEndpointsIPv6"u8); + writer.WriteNumberValue(MinChildEndpointsIPv6.Value); + } + if (Optional.IsCollectionDefined(GeoMapping)) + { + writer.WritePropertyName("geoMapping"u8); + writer.WriteStartArray(); + foreach (string item in GeoMapping) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Subnets)) + { + writer.WritePropertyName("subnets"u8); + writer.WriteStartArray(); + foreach (TrafficManagerEndpointSubnetInfo item in Subnets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CustomHeaders)) + { + writer.WritePropertyName("customHeaders"u8); + writer.WriteStartArray(); + foreach (TrafficManagerEndpointCustomHeaderInfo item in CustomHeaders) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AlwaysServe)) + { + writer.WritePropertyName("alwaysServe"u8); + writer.WriteStringValue(AlwaysServe.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EndpointProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EndpointProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EndpointProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEndpointProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EndpointProperties DeserializeEndpointProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier targetResourceId = default; + string target = default; + TrafficManagerEndpointStatus? endpointStatus = default; + long? weight = default; + long? priority = default; + string endpointLocation = default; + TrafficManagerEndpointMonitorStatus? endpointMonitorStatus = default; + long? minChildEndpoints = default; + long? minChildEndpointsIPv4 = default; + long? minChildEndpointsIPv6 = default; + IList geoMapping = default; + IList subnets = default; + IList customHeaders = default; + TrafficManagerEndpointAlwaysServeStatus? alwaysServe = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("targetResourceId"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("target"u8)) + { + target = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("endpointStatus"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointStatus = new TrafficManagerEndpointStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("weight"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + weight = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("priority"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + priority = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("endpointLocation"u8)) + { + endpointLocation = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("endpointMonitorStatus"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointMonitorStatus = new TrafficManagerEndpointMonitorStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("minChildEndpoints"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minChildEndpoints = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("minChildEndpointsIPv4"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minChildEndpointsIPv4 = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("minChildEndpointsIPv6"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minChildEndpointsIPv6 = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("geoMapping"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + geoMapping = array; + continue; + } + if (prop.NameEquals("subnets"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerEndpointSubnetInfo.DeserializeTrafficManagerEndpointSubnetInfo(item, options)); + } + subnets = array; + continue; + } + if (prop.NameEquals("customHeaders"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerEndpointCustomHeaderInfo.DeserializeTrafficManagerEndpointCustomHeaderInfo(item, options)); + } + customHeaders = array; + continue; + } + if (prop.NameEquals("alwaysServe"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + alwaysServe = new TrafficManagerEndpointAlwaysServeStatus(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EndpointProperties( + targetResourceId, + target, + endpointStatus, + weight, + priority, + endpointLocation, + endpointMonitorStatus, + minChildEndpoints, + minChildEndpointsIPv4, + minChildEndpointsIPv6, + geoMapping ?? new ChangeTrackingList(), + subnets ?? new ChangeTrackingList(), + customHeaders ?? new ChangeTrackingList(), + alwaysServe, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.cs new file mode 100644 index 000000000000..966046013c8f --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/EndpointProperties.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager endpoint properties. + internal partial class EndpointProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public EndpointProperties() + { + GeoMapping = new ChangeTrackingList(); + Subnets = new ChangeTrackingList(); + CustomHeaders = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type 'ExternalEndpoints'. + /// The fully-qualified DNS name or IP address of the endpoint. Traffic Manager returns this value in DNS responses to direct traffic to this endpoint. + /// The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. + /// The weight of this endpoint when using the 'Weighted' traffic routing method. Possible values are from 1 to 1000. + /// The priority of this endpoint when using the 'Priority' traffic routing method. Possible values are from 1 to 1000, lower values represent higher priority. This is an optional parameter. If specified, it must be specified on all endpoints, and no two endpoints can share the same priority value. + /// Specifies the location of the external or nested endpoints when using the 'Performance' traffic routing method. + /// The monitoring status of the endpoint. + /// The minimum number of endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + /// The minimum number of IPv4 (DNS record type A) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + /// The minimum number of IPv6 (DNS record type AAAA) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + /// The list of countries/regions mapped to this endpoint when using the 'Geographic' traffic routing method. Please consult Traffic Manager Geographic documentation for a full list of accepted values. + /// The list of subnets, IP addresses, and/or address ranges mapped to this endpoint when using the 'Subnet' traffic routing method. An empty list will match all ranges not covered by other endpoints. + /// List of custom headers. + /// If Always Serve is enabled, probing for endpoint health will be disabled and endpoints will be included in the traffic routing method. + /// Keeps track of any properties unknown to the library. + internal EndpointProperties(ResourceIdentifier targetResourceId, string target, TrafficManagerEndpointStatus? endpointStatus, long? weight, long? priority, string endpointLocation, TrafficManagerEndpointMonitorStatus? endpointMonitorStatus, long? minChildEndpoints, long? minChildEndpointsIPv4, long? minChildEndpointsIPv6, IList geoMapping, IList subnets, IList customHeaders, TrafficManagerEndpointAlwaysServeStatus? alwaysServe, IDictionary additionalBinaryDataProperties) + { + TargetResourceId = targetResourceId; + Target = target; + EndpointStatus = endpointStatus; + Weight = weight; + Priority = priority; + EndpointLocation = endpointLocation; + EndpointMonitorStatus = endpointMonitorStatus; + MinChildEndpoints = minChildEndpoints; + MinChildEndpointsIPv4 = minChildEndpointsIPv4; + MinChildEndpointsIPv6 = minChildEndpointsIPv6; + GeoMapping = geoMapping; + Subnets = subnets; + CustomHeaders = customHeaders; + AlwaysServe = alwaysServe; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type 'ExternalEndpoints'. + public ResourceIdentifier TargetResourceId { get; set; } + + /// The fully-qualified DNS name or IP address of the endpoint. Traffic Manager returns this value in DNS responses to direct traffic to this endpoint. + public string Target { get; set; } + + /// The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. + public TrafficManagerEndpointStatus? EndpointStatus { get; set; } + + /// The weight of this endpoint when using the 'Weighted' traffic routing method. Possible values are from 1 to 1000. + public long? Weight { get; set; } + + /// The priority of this endpoint when using the 'Priority' traffic routing method. Possible values are from 1 to 1000, lower values represent higher priority. This is an optional parameter. If specified, it must be specified on all endpoints, and no two endpoints can share the same priority value. + public long? Priority { get; set; } + + /// Specifies the location of the external or nested endpoints when using the 'Performance' traffic routing method. + public string EndpointLocation { get; set; } + + /// The monitoring status of the endpoint. + public TrafficManagerEndpointMonitorStatus? EndpointMonitorStatus { get; set; } + + /// The minimum number of endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + public long? MinChildEndpoints { get; set; } + + /// The minimum number of IPv4 (DNS record type A) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + public long? MinChildEndpointsIPv4 { get; set; } + + /// The minimum number of IPv6 (DNS record type AAAA) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. + public long? MinChildEndpointsIPv6 { get; set; } + + /// The list of countries/regions mapped to this endpoint when using the 'Geographic' traffic routing method. Please consult Traffic Manager Geographic documentation for a full list of accepted values. + public IList GeoMapping { get; } = new ChangeTrackingList(); + + /// The list of subnets, IP addresses, and/or address ranges mapped to this endpoint when using the 'Subnet' traffic routing method. An empty list will match all ranges not covered by other endpoints. + public IList Subnets { get; } = new ChangeTrackingList(); + + /// List of custom headers. + public IList CustomHeaders { get; } = new ChangeTrackingList(); + + /// If Always Serve is enabled, probing for endpoint health will be disabled and endpoints will be included in the traffic routing method. + public TrafficManagerEndpointAlwaysServeStatus? AlwaysServe { get; set; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.Serialization.cs index ee1eb68bafc2..4dcdae5ec40e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class ExpectedStatusCodeRangeInfo : IUtf8JsonSerializable, IJsonModel + /// Min and max value of a status code range. + public partial class ExpectedStatusCodeRangeInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ExpectedStatusCodeRangeInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeExpectedStatusCodeRangeInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ExpectedStatusCodeRangeInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Min)) { writer.WritePropertyName("min"u8); @@ -44,15 +84,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("max"u8); writer.WriteNumberValue(Max.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,88 +101,60 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ExpectedStatusCodeRangeInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ExpectedStatusCodeRangeInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ExpectedStatusCodeRangeInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeExpectedStatusCodeRangeInfo(document.RootElement, options); } - internal static ExpectedStatusCodeRangeInfo DeserializeExpectedStatusCodeRangeInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ExpectedStatusCodeRangeInfo DeserializeExpectedStatusCodeRangeInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } int? min = default; int? max = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("min"u8)) + if (prop.NameEquals("min"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - min = property.Value.GetInt32(); + min = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max"u8)) + if (prop.NameEquals("max"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - max = property.Value.GetInt32(); + max = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ExpectedStatusCodeRangeInfo(min, max, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support writing '{options.Format}' format."); - } - } - - ExpectedStatusCodeRangeInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeExpectedStatusCodeRangeInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ExpectedStatusCodeRangeInfo)} does not support reading '{options.Format}' format."); - } + return new ExpectedStatusCodeRangeInfo(min, max, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.cs index c55c9dc4c836..2a11a1d08c50 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ExpectedStatusCodeRangeInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Min and max value of a status code range. public partial class ExpectedStatusCodeRangeInfo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public ExpectedStatusCodeRangeInfo() @@ -53,16 +24,17 @@ public ExpectedStatusCodeRangeInfo() /// Initializes a new instance of . /// Min status code. /// Max status code. - /// Keeps track of any properties unknown to the library. - internal ExpectedStatusCodeRangeInfo(int? min, int? max, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ExpectedStatusCodeRangeInfo(int? min, int? max, IDictionary additionalBinaryDataProperties) { Min = min; Max = max; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Min status code. public int? Min { get; set; } + /// Max status code. public int? Max { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.Serialization.cs new file mode 100644 index 000000000000..31c1b17f116d --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing the properties of the Geographic hierarchy used with the Geographic traffic routing method. + internal partial class GeographicHierarchyProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual GeographicHierarchyProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeGeographicHierarchyProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GeographicHierarchyProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(GeographicHierarchyProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + GeographicHierarchyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeographicHierarchyProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(GeographicHierarchy)) + { + writer.WritePropertyName("geographicHierarchy"u8); + writer.WriteObjectValue(GeographicHierarchy, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + GeographicHierarchyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual GeographicHierarchyProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeographicHierarchyProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGeographicHierarchyProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static GeographicHierarchyProperties DeserializeGeographicHierarchyProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TrafficManagerRegion geographicHierarchy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("geographicHierarchy"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + geographicHierarchy = TrafficManagerRegion.DeserializeTrafficManagerRegion(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new GeographicHierarchyProperties(geographicHierarchy, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.cs new file mode 100644 index 000000000000..867047ac11e2 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/GeographicHierarchyProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing the properties of the Geographic hierarchy used with the Geographic traffic routing method. + internal partial class GeographicHierarchyProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public GeographicHierarchyProperties() + { + } + + /// Initializes a new instance of . + /// The region at the root of the hierarchy from all the regions in the hierarchy can be retrieved. + /// Keeps track of any properties unknown to the library. + internal GeographicHierarchyProperties(TrafficManagerRegion geographicHierarchy, IDictionary additionalBinaryDataProperties) + { + GeographicHierarchy = geographicHierarchy; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The region at the root of the hierarchy from all the regions in the hierarchy can be retrieved. + public TrafficManagerRegion GeographicHierarchy { get; set; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.Serialization.cs new file mode 100644 index 000000000000..977b95d48244 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.Serialization.cs @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager HeatMap properties. + internal partial class HeatMapProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HeatMapProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHeatMapProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HeatMapProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(HeatMapProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + HeatMapProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HeatMapProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (Optional.IsDefined(EndOn)) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndOn.Value, "O"); + } + if (Optional.IsCollectionDefined(Endpoints)) + { + writer.WritePropertyName("endpoints"u8); + writer.WriteStartArray(); + foreach (TrafficManagerHeatMapEndpoint item in Endpoints) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(TrafficFlows)) + { + writer.WritePropertyName("trafficFlows"u8); + writer.WriteStartArray(); + foreach (TrafficManagerHeatMapTrafficFlow item in TrafficFlows) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + HeatMapProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HeatMapProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HeatMapProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHeatMapProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HeatMapProperties DeserializeHeatMapProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? startOn = default; + DateTimeOffset? endOn = default; + IList endpoints = default; + IList trafficFlows = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("startTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("endTime"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endOn = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("endpoints"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerHeatMapEndpoint.DeserializeTrafficManagerHeatMapEndpoint(item, options)); + } + endpoints = array; + continue; + } + if (prop.NameEquals("trafficFlows"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerHeatMapTrafficFlow.DeserializeTrafficManagerHeatMapTrafficFlow(item, options)); + } + trafficFlows = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new HeatMapProperties(startOn, endOn, endpoints ?? new ChangeTrackingList(), trafficFlows ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.cs new file mode 100644 index 000000000000..1c4c989ccfc2 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/HeatMapProperties.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager HeatMap properties. + internal partial class HeatMapProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public HeatMapProperties() + { + Endpoints = new ChangeTrackingList(); + TrafficFlows = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The beginning of the time window for this HeatMap, inclusive. + /// The ending of the time window for this HeatMap, exclusive. + /// The endpoints used in this HeatMap calculation. + /// The traffic flows produced in this HeatMap calculation. + /// Keeps track of any properties unknown to the library. + internal HeatMapProperties(DateTimeOffset? startOn, DateTimeOffset? endOn, IList endpoints, IList trafficFlows, IDictionary additionalBinaryDataProperties) + { + StartOn = startOn; + EndOn = endOn; + Endpoints = endpoints; + TrafficFlows = trafficFlows; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The beginning of the time window for this HeatMap, inclusive. + public DateTimeOffset? StartOn { get; set; } + + /// The ending of the time window for this HeatMap, exclusive. + public DateTimeOffset? EndOn { get; set; } + + /// The endpoints used in this HeatMap calculation. + public IList Endpoints { get; } = new ChangeTrackingList(); + + /// The traffic flows produced in this HeatMap calculation. + public IList TrafficFlows { get; } = new ChangeTrackingList(); + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.Serialization.cs new file mode 100644 index 000000000000..bb7ad897ab78 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// The response of a Profile list operation. + internal partial class ProfileListResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProfileListResult() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProfileListResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProfileListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProfileListResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(ProfileListResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProfileListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static ProfileListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProfileListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileListResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (TrafficManagerProfileData item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProfileListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProfileListResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileListResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProfileListResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProfileListResult DeserializeProfileListResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerProfileData.DeserializeTrafficManagerProfileData(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString(), UriKind.RelativeOrAbsolute); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProfileListResult(value, nextLink, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.cs new file mode 100644 index 000000000000..70695aeec8ee --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileListResult.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// The response of a Profile list operation. + internal partial class ProfileListResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Profile items on this page. + internal ProfileListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Profile items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal ProfileListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Profile items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.Serialization.cs new file mode 100644 index 000000000000..800c015b3dde --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.Serialization.cs @@ -0,0 +1,279 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing the Traffic Manager profile properties. + internal partial class ProfileProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProfileProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProfileProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProfileProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(ProfileProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + ProfileProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ProfileStatus)) + { + writer.WritePropertyName("profileStatus"u8); + writer.WriteStringValue(ProfileStatus.Value.ToString()); + } + if (Optional.IsDefined(TrafficRoutingMethod)) + { + writer.WritePropertyName("trafficRoutingMethod"u8); + writer.WriteStringValue(TrafficRoutingMethod.Value.ToString()); + } + if (Optional.IsDefined(DnsConfig)) + { + writer.WritePropertyName("dnsConfig"u8); + writer.WriteObjectValue(DnsConfig, options); + } + if (Optional.IsDefined(MonitorConfig)) + { + writer.WritePropertyName("monitorConfig"u8); + writer.WriteObjectValue(MonitorConfig, options); + } + if (Optional.IsCollectionDefined(Endpoints)) + { + writer.WritePropertyName("endpoints"u8); + writer.WriteStartArray(); + foreach (TrafficManagerEndpointData item in Endpoints) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TrafficViewEnrollmentStatus)) + { + writer.WritePropertyName("trafficViewEnrollmentStatus"u8); + writer.WriteStringValue(TrafficViewEnrollmentStatus.Value.ToString()); + } + if (Optional.IsCollectionDefined(AllowedEndpointRecordTypes)) + { + writer.WritePropertyName("allowedEndpointRecordTypes"u8); + writer.WriteStartArray(); + foreach (AllowedEndpointRecordType item in AllowedEndpointRecordTypes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(MaxReturn)) + { + writer.WritePropertyName("maxReturn"u8); + writer.WriteNumberValue(MaxReturn.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProfileProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProfileProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProfileProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProfileProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProfileProperties DeserializeProfileProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TrafficManagerProfileStatus? profileStatus = default; + TrafficRoutingMethod? trafficRoutingMethod = default; + TrafficManagerDnsConfig dnsConfig = default; + TrafficManagerMonitorConfig monitorConfig = default; + IList endpoints = default; + TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default; + IList allowedEndpointRecordTypes = default; + long? maxReturn = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("profileStatus"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profileStatus = new TrafficManagerProfileStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("trafficRoutingMethod"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trafficRoutingMethod = new TrafficRoutingMethod(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("dnsConfig"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dnsConfig = TrafficManagerDnsConfig.DeserializeTrafficManagerDnsConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("monitorConfig"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + monitorConfig = TrafficManagerMonitorConfig.DeserializeTrafficManagerMonitorConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("endpoints"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(item, options)); + } + endpoints = array; + continue; + } + if (prop.NameEquals("trafficViewEnrollmentStatus"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trafficViewEnrollmentStatus = new TrafficViewEnrollmentStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("allowedEndpointRecordTypes"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new AllowedEndpointRecordType(item.GetString())); + } + allowedEndpointRecordTypes = array; + continue; + } + if (prop.NameEquals("maxReturn"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxReturn = prop.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProfileProperties( + profileStatus, + trafficRoutingMethod, + dnsConfig, + monitorConfig, + endpoints ?? new ChangeTrackingList(), + trafficViewEnrollmentStatus, + allowedEndpointRecordTypes ?? new ChangeTrackingList(), + maxReturn, + additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.cs new file mode 100644 index 000000000000..24ed463d4d83 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/ProfileProperties.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing the Traffic Manager profile properties. + internal partial class ProfileProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ProfileProperties() + { + Endpoints = new ChangeTrackingList(); + AllowedEndpointRecordTypes = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The status of the Traffic Manager profile. + /// The traffic routing method of the Traffic Manager profile. + /// The DNS settings of the Traffic Manager profile. + /// The endpoint monitoring settings of the Traffic Manager profile. + /// The list of endpoints in the Traffic Manager profile. + /// Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase the cost of the Traffic Manage profile. + /// The list of allowed endpoint record types. + /// Maximum number of endpoints to be returned for MultiValue routing type. + /// Keeps track of any properties unknown to the library. + internal ProfileProperties(TrafficManagerProfileStatus? profileStatus, TrafficRoutingMethod? trafficRoutingMethod, TrafficManagerDnsConfig dnsConfig, TrafficManagerMonitorConfig monitorConfig, IList endpoints, TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus, IList allowedEndpointRecordTypes, long? maxReturn, IDictionary additionalBinaryDataProperties) + { + ProfileStatus = profileStatus; + TrafficRoutingMethod = trafficRoutingMethod; + DnsConfig = dnsConfig; + MonitorConfig = monitorConfig; + Endpoints = endpoints; + TrafficViewEnrollmentStatus = trafficViewEnrollmentStatus; + AllowedEndpointRecordTypes = allowedEndpointRecordTypes; + MaxReturn = maxReturn; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The status of the Traffic Manager profile. + public TrafficManagerProfileStatus? ProfileStatus { get; set; } + + /// The traffic routing method of the Traffic Manager profile. + public TrafficRoutingMethod? TrafficRoutingMethod { get; set; } + + /// The DNS settings of the Traffic Manager profile. + public TrafficManagerDnsConfig DnsConfig { get; set; } + + /// The endpoint monitoring settings of the Traffic Manager profile. + public TrafficManagerMonitorConfig MonitorConfig { get; set; } + + /// The list of endpoints in the Traffic Manager profile. + public IList Endpoints { get; } = new ChangeTrackingList(); + + /// Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase the cost of the Traffic Manage profile. + public TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus { get; set; } + + /// The list of allowed endpoint record types. + public IList AllowedEndpointRecordTypes { get; } = new ChangeTrackingList(); + + /// Maximum number of endpoints to be returned for MultiValue routing type. + public long? MaxReturn { get; set; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.Serialization.cs new file mode 100644 index 000000000000..9a89e494d5eb --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// The result of the request or operation. + internal partial class TrafficManagerDeleteOperationResult : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerDeleteOperationResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerDeleteOperationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerDeleteOperationResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerDeleteOperationResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerDeleteOperationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficManagerDeleteOperationResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerDeleteOperationResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrafficManagerDeleteOperationResult)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(OperationResult)) + { + writer.WritePropertyName("boolean"u8); + writer.WriteBooleanValue(OperationResult.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerDeleteOperationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerDeleteOperationResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TrafficManagerDeleteOperationResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrafficManagerDeleteOperationResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerDeleteOperationResult DeserializeTrafficManagerDeleteOperationResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? operationResult = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("boolean"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + operationResult = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TrafficManagerDeleteOperationResult(operationResult, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.cs new file mode 100644 index 000000000000..da6faa50acf0 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDeleteOperationResult.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// The result of the request or operation. + internal partial class TrafficManagerDeleteOperationResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal TrafficManagerDeleteOperationResult() + { + } + + /// Initializes a new instance of . + /// The result of the operation or request. + /// Keeps track of any properties unknown to the library. + internal TrafficManagerDeleteOperationResult(bool? operationResult, IDictionary additionalBinaryDataProperties) + { + OperationResult = operationResult; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The result of the operation or request. + public bool? OperationResult { get; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.Serialization.cs index 900c1ff7eadc..9879e62ce6c2 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerDnsConfig : IUtf8JsonSerializable, IJsonModel + /// Class containing DNS settings in a Traffic Manager profile. + public partial class TrafficManagerDnsConfig : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerDnsConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerDnsConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerDnsConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support writing '{format}' format."); } - if (Optional.IsDefined(RelativeName)) { writer.WritePropertyName("relativeName"u8); @@ -49,15 +89,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("ttl"u8); writer.WriteNumberValue(Ttl.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,22 +106,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerDnsConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerDnsConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerDnsConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerDnsConfig(document.RootElement, options); } - internal static TrafficManagerDnsConfig DeserializeTrafficManagerDnsConfig(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerDnsConfig DeserializeTrafficManagerDnsConfig(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,67 +134,34 @@ internal static TrafficManagerDnsConfig DeserializeTrafficManagerDnsConfig(JsonE string relativeName = default; string fqdn = default; long? ttl = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("relativeName"u8)) + if (prop.NameEquals("relativeName"u8)) { - relativeName = property.Value.GetString(); + relativeName = prop.Value.GetString(); continue; } - if (property.NameEquals("fqdn"u8)) + if (prop.NameEquals("fqdn"u8)) { - fqdn = property.Value.GetString(); + fqdn = prop.Value.GetString(); continue; } - if (property.NameEquals("ttl"u8)) + if (prop.NameEquals("ttl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - ttl = property.Value.GetInt64(); + ttl = prop.Value.GetInt64(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerDnsConfig(relativeName, fqdn, ttl, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerDnsConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerDnsConfig(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerDnsConfig)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerDnsConfig(relativeName, fqdn, ttl, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.cs index 94b11b0f65be..440db24f4430 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerDnsConfig.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Class containing DNS settings in a Traffic Manager profile. public partial class TrafficManagerDnsConfig { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerDnsConfig() @@ -54,19 +25,21 @@ public TrafficManagerDnsConfig() /// The relative DNS name provided by this Traffic Manager profile. This value is combined with the DNS domain name used by Azure Traffic Manager to form the fully-qualified domain name (FQDN) of the profile. /// The fully-qualified domain name (FQDN) of the Traffic Manager profile. This is formed from the concatenation of the RelativeName with the DNS domain used by Azure Traffic Manager. /// The DNS Time-To-Live (TTL), in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses provided by this Traffic Manager profile. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerDnsConfig(string relativeName, string fqdn, long? ttl, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerDnsConfig(string relativeName, string fqdn, long? ttl, IDictionary additionalBinaryDataProperties) { RelativeName = relativeName; Fqdn = fqdn; Ttl = ttl; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The relative DNS name provided by this Traffic Manager profile. This value is combined with the DNS domain name used by Azure Traffic Manager to form the fully-qualified domain name (FQDN) of the profile. public string RelativeName { get; set; } + /// The fully-qualified domain name (FQDN) of the Traffic Manager profile. This is formed from the concatenation of the RelativeName with the DNS domain used by Azure Traffic Manager. public string Fqdn { get; } + /// The DNS Time-To-Live (TTL), in seconds. This informs the local DNS resolvers and DNS clients how long to cache DNS responses provided by this Traffic Manager profile. public long? Ttl { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointAlwaysServeStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointAlwaysServeStatus.cs index b8532201f987..2871ba213c91 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointAlwaysServeStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointAlwaysServeStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerEndpointAlwaysServeStatus : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerEndpointAlwaysServeStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static TrafficManagerEndpointAlwaysServeStatus Enabled { get; } = new TrafficManagerEndpointAlwaysServeStatus(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficManagerEndpointAlwaysServeStatus Disabled { get; } = new TrafficManagerEndpointAlwaysServeStatus(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerEndpointAlwaysServeStatus left, TrafficManagerEndpointAlwaysServeStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerEndpointAlwaysServeStatus left, TrafficManagerEndpointAlwaysServeStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerEndpointAlwaysServeStatus(string value) => new TrafficManagerEndpointAlwaysServeStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerEndpointAlwaysServeStatus?(string value) => value == null ? null : new TrafficManagerEndpointAlwaysServeStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerEndpointAlwaysServeStatus other && Equals(other); - /// + + /// public bool Equals(TrafficManagerEndpointAlwaysServeStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.Serialization.cs index d00256498a69..c7729092d1f8 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerEndpointCustomHeaderInfo : IUtf8JsonSerializable, IJsonModel + /// Custom header name and value. + public partial class TrafficManagerEndpointCustomHeaderInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerEndpointCustomHeaderInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerEndpointCustomHeaderInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerEndpointCustomHeaderInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWriter wri /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -44,15 +84,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,80 +101,52 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerEndpointCustomHeaderInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerEndpointCustomHeaderInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerEndpointCustomHeaderInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerEndpointCustomHeaderInfo(document.RootElement, options); } - internal static TrafficManagerEndpointCustomHeaderInfo DeserializeTrafficManagerEndpointCustomHeaderInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerEndpointCustomHeaderInfo DeserializeTrafficManagerEndpointCustomHeaderInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerEndpointCustomHeaderInfo(name, value, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerEndpointCustomHeaderInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerEndpointCustomHeaderInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointCustomHeaderInfo)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerEndpointCustomHeaderInfo(name, value, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.cs index 1274ac80b371..cbc124304b1e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointCustomHeaderInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Custom header name and value. public partial class TrafficManagerEndpointCustomHeaderInfo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerEndpointCustomHeaderInfo() @@ -53,16 +24,17 @@ public TrafficManagerEndpointCustomHeaderInfo() /// Initializes a new instance of . /// Header name. /// Header value. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerEndpointCustomHeaderInfo(string name, string value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerEndpointCustomHeaderInfo(string name, string value, IDictionary additionalBinaryDataProperties) { Name = name; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Header name. public string Name { get; set; } + /// Header value. public string Value { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointMonitorStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointMonitorStatus.cs index 5531f08739b8..e1d82e46a5d0 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointMonitorStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointMonitorStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,14 +15,6 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerEndpointMonitorStatus : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TrafficManagerEndpointMonitorStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string CheckingEndpointValue = "CheckingEndpoint"; private const string OnlineValue = "Online"; private const string DegradedValue = "Degraded"; @@ -30,37 +23,67 @@ public TrafficManagerEndpointMonitorStatus(string value) private const string StoppedValue = "Stopped"; private const string UnmonitoredValue = "Unmonitored"; - /// CheckingEndpoint. + /// Initializes a new instance of . + /// The value. + /// is null. + public TrafficManagerEndpointMonitorStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the CheckingEndpoint. public static TrafficManagerEndpointMonitorStatus CheckingEndpoint { get; } = new TrafficManagerEndpointMonitorStatus(CheckingEndpointValue); - /// Online. + + /// Gets the Online. public static TrafficManagerEndpointMonitorStatus Online { get; } = new TrafficManagerEndpointMonitorStatus(OnlineValue); - /// Degraded. + + /// Gets the Degraded. public static TrafficManagerEndpointMonitorStatus Degraded { get; } = new TrafficManagerEndpointMonitorStatus(DegradedValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficManagerEndpointMonitorStatus Disabled { get; } = new TrafficManagerEndpointMonitorStatus(DisabledValue); - /// Inactive. + + /// Gets the Inactive. public static TrafficManagerEndpointMonitorStatus Inactive { get; } = new TrafficManagerEndpointMonitorStatus(InactiveValue); - /// Stopped. + + /// Gets the Stopped. public static TrafficManagerEndpointMonitorStatus Stopped { get; } = new TrafficManagerEndpointMonitorStatus(StoppedValue); - /// Unmonitored. + + /// Gets the Unmonitored. public static TrafficManagerEndpointMonitorStatus Unmonitored { get; } = new TrafficManagerEndpointMonitorStatus(UnmonitoredValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerEndpointMonitorStatus left, TrafficManagerEndpointMonitorStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerEndpointMonitorStatus left, TrafficManagerEndpointMonitorStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerEndpointMonitorStatus(string value) => new TrafficManagerEndpointMonitorStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerEndpointMonitorStatus?(string value) => value == null ? null : new TrafficManagerEndpointMonitorStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerEndpointMonitorStatus other && Equals(other); - /// + + /// public bool Equals(TrafficManagerEndpointMonitorStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointStatus.cs index 7045991c0e1c..ec9113f3d47e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerEndpointStatus : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerEndpointStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static TrafficManagerEndpointStatus Enabled { get; } = new TrafficManagerEndpointStatus(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficManagerEndpointStatus Disabled { get; } = new TrafficManagerEndpointStatus(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerEndpointStatus left, TrafficManagerEndpointStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerEndpointStatus left, TrafficManagerEndpointStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerEndpointStatus(string value) => new TrafficManagerEndpointStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerEndpointStatus?(string value) => value == null ? null : new TrafficManagerEndpointStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerEndpointStatus other && Equals(other); - /// + + /// public bool Equals(TrafficManagerEndpointStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.Serialization.cs index c9fa1db7e174..91e7ff4a445e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.Serialization.cs @@ -10,14 +10,55 @@ using System.Collections.Generic; using System.Net; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerEndpointSubnetInfo : IUtf8JsonSerializable, IJsonModel + /// Subnet first address, scope, and/or last address. + public partial class TrafficManagerEndpointSubnetInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerEndpointSubnetInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerEndpointSubnetInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerEndpointSubnetInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,12 +70,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(First)) { writer.WritePropertyName("first"u8); @@ -50,15 +90,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("scope"u8); writer.WriteNumberValue(Scope.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -67,22 +107,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerEndpointSubnetInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerEndpointSubnetInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerEndpointSubnetInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerEndpointSubnetInfo(document.RootElement, options); } - internal static TrafficManagerEndpointSubnetInfo DeserializeTrafficManagerEndpointSubnetInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerEndpointSubnetInfo DeserializeTrafficManagerEndpointSubnetInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -90,75 +135,42 @@ internal static TrafficManagerEndpointSubnetInfo DeserializeTrafficManagerEndpoi IPAddress first = default; IPAddress last = default; int? scope = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("first"u8)) + if (prop.NameEquals("first"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - first = IPAddress.Parse(property.Value.GetString()); + first = IPAddress.Parse(prop.Value.GetString()); continue; } - if (property.NameEquals("last"u8)) + if (prop.NameEquals("last"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - last = IPAddress.Parse(property.Value.GetString()); + last = IPAddress.Parse(prop.Value.GetString()); continue; } - if (property.NameEquals("scope"u8)) + if (prop.NameEquals("scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - scope = property.Value.GetInt32(); + scope = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerEndpointSubnetInfo(first, last, scope, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerEndpointSubnetInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerEndpointSubnetInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointSubnetInfo)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerEndpointSubnetInfo(first, last, scope, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.cs index 0aad82e2bb9c..c0e9e07001a9 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointSubnetInfo.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Subnet first address, scope, and/or last address. public partial class TrafficManagerEndpointSubnetInfo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerEndpointSubnetInfo() @@ -55,19 +26,21 @@ public TrafficManagerEndpointSubnetInfo() /// First address in the subnet. /// Last address in the subnet. /// Block size (number of leading bits in the subnet mask). - /// Keeps track of any properties unknown to the library. - internal TrafficManagerEndpointSubnetInfo(IPAddress first, IPAddress last, int? scope, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerEndpointSubnetInfo(IPAddress first, IPAddress last, int? scope, IDictionary additionalBinaryDataProperties) { First = first; Last = last; Scope = scope; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// First address in the subnet. public IPAddress First { get; set; } + /// Last address in the subnet. public IPAddress Last { get; set; } + /// Block size (number of leading bits in the subnet mask). public int? Scope { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.Serialization.cs new file mode 100644 index 000000000000..f434ef124653 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.Serialization.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + internal static partial class TrafficManagerEndpointTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this TrafficManagerEndpointType value) => value switch + { + TrafficManagerEndpointType.AzureEndpoints => "AzureEndpoints", + TrafficManagerEndpointType.ExternalEndpoints => "ExternalEndpoints", + TrafficManagerEndpointType.NestedEndpoints => "NestedEndpoints", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TrafficManagerEndpointType value.") + }; + + /// The value to deserialize. + public static TrafficManagerEndpointType ToTrafficManagerEndpointType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureEndpoints")) + { + return TrafficManagerEndpointType.AzureEndpoints; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ExternalEndpoints")) + { + return TrafficManagerEndpointType.ExternalEndpoints; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NestedEndpoints")) + { + return TrafficManagerEndpointType.NestedEndpoints; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown TrafficManagerEndpointType value."); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.cs new file mode 100644 index 000000000000..124cdf1c3058 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerEndpointType.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// + public enum TrafficManagerEndpointType + { + /// AzureEndpoints. + AzureEndpoints, + /// ExternalEndpoints. + ExternalEndpoints, + /// NestedEndpoints. + NestedEndpoints + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.Serialization.cs index 3d84ed81ba2b..77fb997bed76 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.Serialization.cs @@ -10,13 +10,55 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerHeatMapEndpoint : IUtf8JsonSerializable, IJsonModel + /// Class which is a sparse representation of a Traffic Manager endpoint. + public partial class TrafficManagerHeatMapEndpoint : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapEndpoint PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerHeatMapEndpoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerHeatMapEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +70,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ResourceId)) { writer.WritePropertyName("resourceId"u8); @@ -44,15 +85,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("endpointId"u8); writer.WriteNumberValue(EndpointId.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,88 +102,60 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerHeatMapEndpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerHeatMapEndpoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapEndpoint JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerHeatMapEndpoint(document.RootElement, options); } - internal static TrafficManagerHeatMapEndpoint DeserializeTrafficManagerHeatMapEndpoint(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerHeatMapEndpoint DeserializeTrafficManagerHeatMapEndpoint(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier resourceId = default; int? endpointId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("resourceId"u8)) + if (prop.NameEquals("resourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - resourceId = new ResourceIdentifier(property.Value.GetString()); + resourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("endpointId"u8)) + if (prop.NameEquals("endpointId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - endpointId = property.Value.GetInt32(); + endpointId = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerHeatMapEndpoint(resourceId, endpointId, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerHeatMapEndpoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerHeatMapEndpoint(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapEndpoint)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerHeatMapEndpoint(resourceId, endpointId, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.cs index ae10c02de401..50296fee38e8 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapEndpoint.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Class which is a sparse representation of a Traffic Manager endpoint. public partial class TrafficManagerHeatMapEndpoint { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerHeatMapEndpoint() @@ -54,16 +25,17 @@ public TrafficManagerHeatMapEndpoint() /// Initializes a new instance of . /// The ARM Resource ID of this Traffic Manager endpoint. /// A number uniquely identifying this endpoint in query experiences. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerHeatMapEndpoint(ResourceIdentifier resourceId, int? endpointId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerHeatMapEndpoint(ResourceIdentifier resourceId, int? endpointId, IDictionary additionalBinaryDataProperties) { ResourceId = resourceId; EndpointId = endpointId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The ARM Resource ID of this Traffic Manager endpoint. public ResourceIdentifier ResourceId { get; set; } + /// A number uniquely identifying this endpoint in query experiences. public int? EndpointId { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.Serialization.cs index 93f73385fe2e..3f4010ff880f 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.Serialization.cs @@ -9,14 +9,60 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerHeatMapQueryExperience : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager HeatMap query experience properties. + public partial class TrafficManagerHeatMapQueryExperience : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TrafficManagerHeatMapQueryExperience() + { + } + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapQueryExperience PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerHeatMapQueryExperience(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support writing '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerHeatMapQueryExperience IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +74,11 @@ void IJsonModel.Write(Utf8JsonWriter write /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support writing '{format}' format."); } - writer.WritePropertyName("endpointId"u8); writer.WriteNumberValue(EndpointId); writer.WritePropertyName("queryCount"u8); @@ -43,15 +88,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("latency"u8); writer.WriteNumberValue(Latency.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -60,22 +105,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerHeatMapQueryExperience IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerHeatMapQueryExperience IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapQueryExperience JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerHeatMapQueryExperience(document.RootElement, options); } - internal static TrafficManagerHeatMapQueryExperience DeserializeTrafficManagerHeatMapQueryExperience(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerHeatMapQueryExperience DeserializeTrafficManagerHeatMapQueryExperience(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -83,67 +133,34 @@ internal static TrafficManagerHeatMapQueryExperience DeserializeTrafficManagerHe int endpointId = default; int queryCount = default; double? latency = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("endpointId"u8)) + if (prop.NameEquals("endpointId"u8)) { - endpointId = property.Value.GetInt32(); + endpointId = prop.Value.GetInt32(); continue; } - if (property.NameEquals("queryCount"u8)) + if (prop.NameEquals("queryCount"u8)) { - queryCount = property.Value.GetInt32(); + queryCount = prop.Value.GetInt32(); continue; } - if (property.NameEquals("latency"u8)) + if (prop.NameEquals("latency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - latency = property.Value.GetDouble(); + latency = prop.Value.GetDouble(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerHeatMapQueryExperience(endpointId, queryCount, latency, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support writing '{options.Format}' format."); - } + return new TrafficManagerHeatMapQueryExperience(endpointId, queryCount, latency, additionalBinaryDataProperties); } - - TrafficManagerHeatMapQueryExperience IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerHeatMapQueryExperience(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapQueryExperience)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.cs index 336ad0a05e42..1760384034ba 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapQueryExperience.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Class representing a Traffic Manager HeatMap query experience properties. public partial class TrafficManagerHeatMapQueryExperience { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The id of the endpoint from the 'endpoints' array which these queries were routed to. @@ -58,24 +29,21 @@ public TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount) /// The id of the endpoint from the 'endpoints' array which these queries were routed to. /// The number of queries originating from this location. /// The latency experienced by queries originating from this location. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount, double? latency, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerHeatMapQueryExperience(int endpointId, int queryCount, double? latency, IDictionary additionalBinaryDataProperties) { EndpointId = endpointId; QueryCount = queryCount; Latency = latency; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TrafficManagerHeatMapQueryExperience() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The id of the endpoint from the 'endpoints' array which these queries were routed to. public int EndpointId { get; set; } + /// The number of queries originating from this location. public int QueryCount { get; set; } + /// The latency experienced by queries originating from this location. public double? Latency { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.Serialization.cs index 3ade711f76bd..77b9ea4aab57 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.Serialization.cs @@ -10,14 +10,55 @@ using System.Collections.Generic; using System.Net; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerHeatMapTrafficFlow : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager HeatMap traffic flow properties. + public partial class TrafficManagerHeatMapTrafficFlow : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapTrafficFlow PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerHeatMapTrafficFlow(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerHeatMapTrafficFlow IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,12 +70,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SourceIP)) { writer.WritePropertyName("sourceIp"u8); @@ -54,21 +94,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("queryExperiences"u8); writer.WriteStartArray(); - foreach (var item in QueryExperiences) + foreach (TrafficManagerHeatMapQueryExperience item in QueryExperiences) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -77,22 +117,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerHeatMapTrafficFlow IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerHeatMapTrafficFlow IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerHeatMapTrafficFlow JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerHeatMapTrafficFlow(document.RootElement, options); } - internal static TrafficManagerHeatMapTrafficFlow DeserializeTrafficManagerHeatMapTrafficFlow(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerHeatMapTrafficFlow DeserializeTrafficManagerHeatMapTrafficFlow(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -101,45 +146,44 @@ internal static TrafficManagerHeatMapTrafficFlow DeserializeTrafficManagerHeatMa double? latitude = default; double? longitude = default; IList queryExperiences = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sourceIp"u8)) + if (prop.NameEquals("sourceIp"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sourceIP = IPAddress.Parse(property.Value.GetString()); + sourceIP = IPAddress.Parse(prop.Value.GetString()); continue; } - if (property.NameEquals("latitude"u8)) + if (prop.NameEquals("latitude"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - latitude = property.Value.GetDouble(); + latitude = prop.Value.GetDouble(); continue; } - if (property.NameEquals("longitude"u8)) + if (prop.NameEquals("longitude"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - longitude = property.Value.GetDouble(); + longitude = prop.Value.GetDouble(); continue; } - if (property.NameEquals("queryExperiences"u8)) + if (prop.NameEquals("queryExperiences"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TrafficManagerHeatMapQueryExperience.DeserializeTrafficManagerHeatMapQueryExperience(item, options)); } @@ -148,42 +192,10 @@ internal static TrafficManagerHeatMapTrafficFlow DeserializeTrafficManagerHeatMa } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerHeatMapTrafficFlow(sourceIP, latitude, longitude, queryExperiences ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerHeatMapTrafficFlow IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerHeatMapTrafficFlow(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapTrafficFlow)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerHeatMapTrafficFlow(sourceIP, latitude, longitude, queryExperiences ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.cs index 4f4a477230ac..dbf4ca97a064 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapTrafficFlow.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using System.Net; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { /// Class representing a Traffic Manager HeatMap traffic flow properties. public partial class TrafficManagerHeatMapTrafficFlow { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerHeatMapTrafficFlow() @@ -57,22 +29,25 @@ public TrafficManagerHeatMapTrafficFlow() /// The approximate latitude that these queries originated from. /// The approximate longitude that these queries originated from. /// The query experiences produced in this HeatMap calculation. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerHeatMapTrafficFlow(IPAddress sourceIP, double? latitude, double? longitude, IList queryExperiences, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerHeatMapTrafficFlow(IPAddress sourceIP, double? latitude, double? longitude, IList queryExperiences, IDictionary additionalBinaryDataProperties) { SourceIP = sourceIP; Latitude = latitude; Longitude = longitude; QueryExperiences = queryExperiences; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The IP address that this query experience originated from. public IPAddress SourceIP { get; set; } + /// The approximate latitude that these queries originated from. public double? Latitude { get; set; } + /// The approximate longitude that these queries originated from. public double? Longitude { get; set; } + /// The query experiences produced in this HeatMap calculation. public IList QueryExperiences { get; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapType.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapType.cs index fa7c68036f04..99b1cec663cb 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapType.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerHeatMapType.cs @@ -7,42 +7,59 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - /// The TrafficManagerHeatMapType. + /// The type of the heatmap. public readonly partial struct TrafficManagerHeatMapType : IEquatable { private readonly string _value; + private const string DefaultValue = "default"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerHeatMapType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string DefaultValue = "default"; + _value = value; + } - /// default. + /// Gets the Default. public static TrafficManagerHeatMapType Default { get; } = new TrafficManagerHeatMapType(DefaultValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerHeatMapType left, TrafficManagerHeatMapType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerHeatMapType left, TrafficManagerHeatMapType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerHeatMapType(string value) => new TrafficManagerHeatMapType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerHeatMapType?(string value) => value == null ? null : new TrafficManagerHeatMapType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerHeatMapType other && Equals(other); - /// + + /// public bool Equals(TrafficManagerHeatMapType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.Serialization.cs index 25e8d52477be..441ca20d39bd 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerMonitorConfig : IUtf8JsonSerializable, IJsonModel + /// Class containing endpoint monitoring settings in a Traffic Manager profile. + public partial class TrafficManagerMonitorConfig : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerMonitorConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerMonitorConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerMonitorConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support writing '{format}' format."); } - if (Optional.IsDefined(ProfileMonitorStatus)) { writer.WritePropertyName("profileMonitorStatus"u8); @@ -73,7 +113,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("customHeaders"u8); writer.WriteStartArray(); - foreach (var item in CustomHeaders) + foreach (TrafficManagerMonitorConfigCustomHeaderInfo item in CustomHeaders) { writer.WriteObjectValue(item, options); } @@ -83,21 +123,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("expectedStatusCodeRanges"u8); writer.WriteStartArray(); - foreach (var item in ExpectedStatusCodeRanges) + foreach (ExpectedStatusCodeRangeInfo item in ExpectedStatusCodeRanges) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -106,22 +146,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerMonitorConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerMonitorConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerMonitorConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerMonitorConfig(document.RootElement, options); } - internal static TrafficManagerMonitorConfig DeserializeTrafficManagerMonitorConfig(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerMonitorConfig DeserializeTrafficManagerMonitorConfig(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -135,91 +180,90 @@ internal static TrafficManagerMonitorConfig DeserializeTrafficManagerMonitorConf long? toleratedNumberOfFailures = default; IList customHeaders = default; IList expectedStatusCodeRanges = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("profileMonitorStatus"u8)) + if (prop.NameEquals("profileMonitorStatus"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - profileMonitorStatus = new TrafficManagerProfileMonitorStatus(property.Value.GetString()); + profileMonitorStatus = new TrafficManagerProfileMonitorStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("protocol"u8)) + if (prop.NameEquals("protocol"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - protocol = new TrafficManagerMonitorProtocol(property.Value.GetString()); + protocol = new TrafficManagerMonitorProtocol(prop.Value.GetString()); continue; } - if (property.NameEquals("port"u8)) + if (prop.NameEquals("port"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - port = property.Value.GetInt64(); + port = prop.Value.GetInt64(); continue; } - if (property.NameEquals("path"u8)) + if (prop.NameEquals("path"u8)) { - path = property.Value.GetString(); + path = prop.Value.GetString(); continue; } - if (property.NameEquals("intervalInSeconds"u8)) + if (prop.NameEquals("intervalInSeconds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - intervalInSeconds = property.Value.GetInt64(); + intervalInSeconds = prop.Value.GetInt64(); continue; } - if (property.NameEquals("timeoutInSeconds"u8)) + if (prop.NameEquals("timeoutInSeconds"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - timeoutInSeconds = property.Value.GetInt64(); + timeoutInSeconds = prop.Value.GetInt64(); continue; } - if (property.NameEquals("toleratedNumberOfFailures"u8)) + if (prop.NameEquals("toleratedNumberOfFailures"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - toleratedNumberOfFailures = property.Value.GetInt64(); + toleratedNumberOfFailures = prop.Value.GetInt64(); continue; } - if (property.NameEquals("customHeaders"u8)) + if (prop.NameEquals("customHeaders"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TrafficManagerMonitorConfigCustomHeaderInfo.DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(item, options)); } customHeaders = array; continue; } - if (property.NameEquals("expectedStatusCodeRanges"u8)) + if (prop.NameEquals("expectedStatusCodeRanges"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(ExpectedStatusCodeRangeInfo.DeserializeExpectedStatusCodeRangeInfo(item, options)); } @@ -228,10 +272,9 @@ internal static TrafficManagerMonitorConfig DeserializeTrafficManagerMonitorConf } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TrafficManagerMonitorConfig( profileMonitorStatus, protocol, @@ -242,38 +285,7 @@ internal static TrafficManagerMonitorConfig DeserializeTrafficManagerMonitorConf toleratedNumberOfFailures, customHeaders ?? new ChangeTrackingList(), expectedStatusCodeRanges ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerMonitorConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerMonitorConfig(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerMonitorConfig)} does not support reading '{options.Format}' format."); - } + additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.cs index 1b228aae982c..f83ea6ca6cce 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfig.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { /// Class containing endpoint monitoring settings in a Traffic Manager profile. public partial class TrafficManagerMonitorConfig { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerMonitorConfig() @@ -62,8 +34,8 @@ public TrafficManagerMonitorConfig() /// The number of consecutive failed health check that Traffic Manager tolerates before declaring an endpoint in this profile Degraded after the next failed health check. /// List of custom headers. /// List of expected status code ranges. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerMonitorConfig(TrafficManagerProfileMonitorStatus? profileMonitorStatus, TrafficManagerMonitorProtocol? protocol, long? port, string path, long? intervalInSeconds, long? timeoutInSeconds, long? toleratedNumberOfFailures, IList customHeaders, IList expectedStatusCodeRanges, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerMonitorConfig(TrafficManagerProfileMonitorStatus? profileMonitorStatus, TrafficManagerMonitorProtocol? protocol, long? port, string path, long? intervalInSeconds, long? timeoutInSeconds, long? toleratedNumberOfFailures, IList customHeaders, IList expectedStatusCodeRanges, IDictionary additionalBinaryDataProperties) { ProfileMonitorStatus = profileMonitorStatus; Protocol = protocol; @@ -74,25 +46,33 @@ internal TrafficManagerMonitorConfig(TrafficManagerProfileMonitorStatus? profile ToleratedNumberOfFailures = toleratedNumberOfFailures; CustomHeaders = customHeaders; ExpectedStatusCodeRanges = expectedStatusCodeRanges; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The profile-level monitoring status of the Traffic Manager profile. public TrafficManagerProfileMonitorStatus? ProfileMonitorStatus { get; set; } + /// The protocol (HTTP, HTTPS or TCP) used to probe for endpoint health. public TrafficManagerMonitorProtocol? Protocol { get; set; } + /// The TCP port used to probe for endpoint health. public long? Port { get; set; } + /// The path relative to the endpoint domain name used to probe for endpoint health. public string Path { get; set; } + /// The monitor interval for endpoints in this profile. This is the interval at which Traffic Manager will check the health of each endpoint in this profile. public long? IntervalInSeconds { get; set; } + /// The monitor timeout for endpoints in this profile. This is the time that Traffic Manager allows endpoints in this profile to response to the health check. public long? TimeoutInSeconds { get; set; } + /// The number of consecutive failed health check that Traffic Manager tolerates before declaring an endpoint in this profile Degraded after the next failed health check. public long? ToleratedNumberOfFailures { get; set; } + /// List of custom headers. public IList CustomHeaders { get; } + /// List of expected status code ranges. public IList ExpectedStatusCodeRanges { get; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.Serialization.cs index 3f1415871a36..76403720b222 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerMonitorConfigCustomHeaderInfo : IUtf8JsonSerializable, IJsonModel + /// Custom header name and value. + public partial class TrafficManagerMonitorConfigCustomHeaderInfo : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerMonitorConfigCustomHeaderInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerMonitorConfigCustomHeaderInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWrite /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -44,15 +84,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,80 +101,52 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerMonitorConfigCustomHeaderInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerMonitorConfigCustomHeaderInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerMonitorConfigCustomHeaderInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(document.RootElement, options); } - internal static TrafficManagerMonitorConfigCustomHeaderInfo DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerMonitorConfigCustomHeaderInfo DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; string value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerMonitorConfigCustomHeaderInfo(name, value, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerMonitorConfigCustomHeaderInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerMonitorConfigCustomHeaderInfo(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerMonitorConfigCustomHeaderInfo)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerMonitorConfigCustomHeaderInfo(name, value, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.cs index 14c3730664e3..0086b772d37a 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorConfigCustomHeaderInfo.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Custom header name and value. public partial class TrafficManagerMonitorConfigCustomHeaderInfo { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerMonitorConfigCustomHeaderInfo() @@ -53,16 +24,17 @@ public TrafficManagerMonitorConfigCustomHeaderInfo() /// Initializes a new instance of . /// Header name. /// Header value. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerMonitorConfigCustomHeaderInfo(string name, string value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerMonitorConfigCustomHeaderInfo(string name, string value, IDictionary additionalBinaryDataProperties) { Name = name; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Header name. public string Name { get; set; } + /// Header value. public string Value { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorProtocol.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorProtocol.cs index 98a942913faf..101da080bd1f 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorProtocol.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerMonitorProtocol.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,41 +15,59 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerMonitorProtocol : IEquatable { private readonly string _value; + private const string HttpValue = "HTTP"; + private const string HttpsValue = "HTTPS"; + private const string TcpValue = "TCP"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerMonitorProtocol(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string HttpValue = "HTTP"; - private const string HttpsValue = "HTTPS"; - private const string TcpValue = "TCP"; + _value = value; + } - /// HTTP. + /// Gets the Http. public static TrafficManagerMonitorProtocol Http { get; } = new TrafficManagerMonitorProtocol(HttpValue); - /// HTTPS. + + /// Gets the Https. public static TrafficManagerMonitorProtocol Https { get; } = new TrafficManagerMonitorProtocol(HttpsValue); - /// TCP. + + /// Gets the Tcp. public static TrafficManagerMonitorProtocol Tcp { get; } = new TrafficManagerMonitorProtocol(TcpValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerMonitorProtocol left, TrafficManagerMonitorProtocol right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerMonitorProtocol left, TrafficManagerMonitorProtocol right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerMonitorProtocol(string value) => new TrafficManagerMonitorProtocol(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerMonitorProtocol?(string value) => value == null ? null : new TrafficManagerMonitorProtocol(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerMonitorProtocol other && Equals(other); - /// + + /// public bool Equals(TrafficManagerMonitorProtocol other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.Serialization.cs index 56a5172f4030..ec900d2ae597 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.Serialization.cs @@ -9,14 +9,64 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerNameAvailabilityResult : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager Name Availability response. + public partial class TrafficManagerNameAvailabilityResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerNameAvailabilityResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerNameAvailabilityResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficManagerNameAvailabilityResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerNameAvailabilityResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +78,11 @@ void IJsonModel.Write(Utf8JsonWriter write /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -59,15 +108,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -76,112 +125,84 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerNameAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerNameAvailabilityResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerNameAvailabilityResult(document.RootElement, options); } - internal static TrafficManagerNameAvailabilityResult DeserializeTrafficManagerNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerNameAvailabilityResult DeserializeTrafficManagerNameAvailabilityResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; - ResourceType? type = default; - bool? nameAvailable = default; - string reason = default; + ResourceType? resourceType = default; + bool? isNameAvailable = default; + string unavailableReason = default; string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("nameAvailable"u8)) + if (prop.NameEquals("nameAvailable"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nameAvailable = property.Value.GetBoolean(); + isNameAvailable = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("reason"u8)) + if (prop.NameEquals("reason"u8)) { - reason = property.Value.GetString(); + unavailableReason = prop.Value.GetString(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TrafficManagerNameAvailabilityResult( name, - type, - nameAvailable, - reason, + resourceType, + isNameAvailable, + unavailableReason, message, - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support writing '{options.Format}' format."); - } + additionalBinaryDataProperties); } - - TrafficManagerNameAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerNameAvailabilityResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerNameAvailabilityResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.cs index 053e54f5c4d9..a5a64519c416 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerNameAvailabilityResult.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Class representing a Traffic Manager Name Availability response. public partial class TrafficManagerNameAvailabilityResult { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal TrafficManagerNameAvailabilityResult() @@ -57,25 +28,29 @@ internal TrafficManagerNameAvailabilityResult() /// Describes whether the relative name is available or not. /// The reason why the name is not available, when applicable. /// Descriptive message that explains why the name is not available, when applicable. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerNameAvailabilityResult(string name, ResourceType? resourceType, bool? isNameAvailable, string unavailableReason, string message, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerNameAvailabilityResult(string name, ResourceType? resourceType, bool? isNameAvailable, string unavailableReason, string message, IDictionary additionalBinaryDataProperties) { Name = name; ResourceType = resourceType; IsNameAvailable = isNameAvailable; UnavailableReason = unavailableReason; Message = message; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The relative name. public string Name { get; } + /// Traffic Manager profile resource type. public ResourceType? ResourceType { get; } + /// Describes whether the relative name is available or not. public bool? IsNameAvailable { get; } + /// The reason why the name is not available, when applicable. public string UnavailableReason { get; } + /// Descriptive message that explains why the name is not available, when applicable. public string Message { get; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.Serialization.cs deleted file mode 100644 index f065b53f934e..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.Serialization.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure.Core; - -namespace Azure.ResourceManager.TrafficManager.Models -{ - internal partial class TrafficManagerProfileListResult : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(TrafficManagerProfileListResult)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(Value)) - { - writer.WritePropertyName("value"u8); - writer.WriteStartArray(); - foreach (var item in Value) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - TrafficManagerProfileListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(TrafficManagerProfileListResult)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeTrafficManagerProfileListResult(document.RootElement, options); - } - - internal static TrafficManagerProfileListResult DeserializeTrafficManagerProfileListResult(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("value"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(TrafficManagerProfileData.DeserializeTrafficManagerProfileData(item, options)); - } - value = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerProfileListResult(value ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerProfileListResult)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerProfileListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerProfileListResult(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerProfileListResult)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.cs deleted file mode 100644 index 2ee6fc997c2b..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileListResult.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.TrafficManager.Models -{ - /// The list Traffic Manager profiles operation response. - internal partial class TrafficManagerProfileListResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - internal TrafficManagerProfileListResult() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// Gets the list of Traffic manager profiles. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerProfileListResult(IReadOnlyList value, IDictionary serializedAdditionalRawData) - { - Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Gets the list of Traffic manager profiles. - public IReadOnlyList Value { get; } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileMonitorStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileMonitorStatus.cs index d59e333e3887..7e40b42fcc77 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileMonitorStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileMonitorStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,47 +15,67 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerProfileMonitorStatus : IEquatable { private readonly string _value; + private const string CheckingEndpointsValue = "CheckingEndpoints"; + private const string OnlineValue = "Online"; + private const string DegradedValue = "Degraded"; + private const string DisabledValue = "Disabled"; + private const string InactiveValue = "Inactive"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerProfileMonitorStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string CheckingEndpointsValue = "CheckingEndpoints"; - private const string OnlineValue = "Online"; - private const string DegradedValue = "Degraded"; - private const string DisabledValue = "Disabled"; - private const string InactiveValue = "Inactive"; + _value = value; + } - /// CheckingEndpoints. + /// Gets the CheckingEndpoints. public static TrafficManagerProfileMonitorStatus CheckingEndpoints { get; } = new TrafficManagerProfileMonitorStatus(CheckingEndpointsValue); - /// Online. + + /// Gets the Online. public static TrafficManagerProfileMonitorStatus Online { get; } = new TrafficManagerProfileMonitorStatus(OnlineValue); - /// Degraded. + + /// Gets the Degraded. public static TrafficManagerProfileMonitorStatus Degraded { get; } = new TrafficManagerProfileMonitorStatus(DegradedValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficManagerProfileMonitorStatus Disabled { get; } = new TrafficManagerProfileMonitorStatus(DisabledValue); - /// Inactive. + + /// Gets the Inactive. public static TrafficManagerProfileMonitorStatus Inactive { get; } = new TrafficManagerProfileMonitorStatus(InactiveValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerProfileMonitorStatus left, TrafficManagerProfileMonitorStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerProfileMonitorStatus left, TrafficManagerProfileMonitorStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerProfileMonitorStatus(string value) => new TrafficManagerProfileMonitorStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerProfileMonitorStatus?(string value) => value == null ? null : new TrafficManagerProfileMonitorStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerProfileMonitorStatus other && Equals(other); - /// + + /// public bool Equals(TrafficManagerProfileMonitorStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileRecordType.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileRecordType.cs deleted file mode 100644 index a668dc3a7d4b..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileRecordType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.ResourceManager.TrafficManager.Models -{ - /// When record type is set, a traffic manager profile will allow only endpoints that match this type. - public readonly partial struct TrafficManagerProfileRecordType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TrafficManagerProfileRecordType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AValue = "A"; - private const string AaaaValue = "AAAA"; - private const string CnameValue = "CNAME"; - - /// A. - public static TrafficManagerProfileRecordType A { get; } = new TrafficManagerProfileRecordType(AValue); - /// AAAA. - public static TrafficManagerProfileRecordType Aaaa { get; } = new TrafficManagerProfileRecordType(AaaaValue); - /// CNAME. - public static TrafficManagerProfileRecordType Cname { get; } = new TrafficManagerProfileRecordType(CnameValue); - /// Determines if two values are the same. - public static bool operator ==(TrafficManagerProfileRecordType left, TrafficManagerProfileRecordType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(TrafficManagerProfileRecordType left, TrafficManagerProfileRecordType right) => !left.Equals(right); - /// Converts a to a . - public static implicit operator TrafficManagerProfileRecordType(string value) => new TrafficManagerProfileRecordType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is TrafficManagerProfileRecordType other && Equals(other); - /// - public bool Equals(TrafficManagerProfileRecordType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileStatus.cs index 278e4bdbd01f..234982863cff 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProfileStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficManagerProfileStatus : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficManagerProfileStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static TrafficManagerProfileStatus Enabled { get; } = new TrafficManagerProfileStatus(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficManagerProfileStatus Disabled { get; } = new TrafficManagerProfileStatus(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficManagerProfileStatus left, TrafficManagerProfileStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficManagerProfileStatus left, TrafficManagerProfileStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficManagerProfileStatus(string value) => new TrafficManagerProfileStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficManagerProfileStatus?(string value) => value == null ? null : new TrafficManagerProfileStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficManagerProfileStatus other && Equals(other); - /// + + /// public bool Equals(TrafficManagerProfileStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.Serialization.cs index 66bdbfe48730..262f18a49f18 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.Serialization.cs @@ -10,13 +10,55 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerProxyResourceData : IUtf8JsonSerializable, IJsonModel + /// The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + public partial class TrafficManagerProxyResourceData : TrafficManagerResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerProxyResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerProxyResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerProxyResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,103 +70,74 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - TrafficManagerProxyResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerProxyResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerProxyResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerProxyResourceData(document.RootElement, options); } - internal static TrafficManagerProxyResourceData DeserializeTrafficManagerProxyResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerProxyResourceData DeserializeTrafficManagerProxyResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerProxyResourceData(id, name, type, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerProxyResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerProxyResourceData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerProxyResourceData)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerProxyResourceData(id, name, resourceType, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.cs index 3a38f7472c4d..0ab6393a260d 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerProxyResourceData.cs @@ -23,8 +23,8 @@ public TrafficManagerProxyResourceData() /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerProxyResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerProxyResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties) : base(id, name, resourceType, additionalBinaryDataProperties) { } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.Serialization.cs index 6d2711fcd374..e0b25679dabe 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.Serialization.cs @@ -9,14 +9,55 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerRegion : IUtf8JsonSerializable, IJsonModel + /// Class representing a region in the Geographic hierarchy used with the Geographic traffic routing method. + public partial class TrafficManagerRegion : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerRegion PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerRegion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerRegion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +69,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -48,21 +88,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("regions"u8); writer.WriteStartArray(); - foreach (var item in Regions) + foreach (TrafficManagerRegion item in Regions) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +111,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerRegion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerRegion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerRegion JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerRegion(document.RootElement, options); } - internal static TrafficManagerRegion DeserializeTrafficManagerRegion(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerRegion DeserializeTrafficManagerRegion(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,28 +139,27 @@ internal static TrafficManagerRegion DeserializeTrafficManagerRegion(JsonElement string code = default; string name = default; IList regions = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetString(); + code = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("regions"u8)) + if (prop.NameEquals("regions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DeserializeTrafficManagerRegion(item, options)); } @@ -124,42 +168,10 @@ internal static TrafficManagerRegion DeserializeTrafficManagerRegion(JsonElement } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerRegion(code, name, regions ?? new ChangeTrackingList(), serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerRegion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerRegion(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerRegion)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerRegion(code, name, regions ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.cs index bf1950633311..3b77e7801b6f 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRegion.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { /// Class representing a region in the Geographic hierarchy used with the Geographic traffic routing method. public partial class TrafficManagerRegion { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerRegion() @@ -55,19 +27,21 @@ public TrafficManagerRegion() /// The code of the region. /// The name of the region. /// The list of Regions grouped under this Region in the Geographic Hierarchy. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerRegion(string code, string name, IList regions, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerRegion(string code, string name, IList regions, IDictionary additionalBinaryDataProperties) { Code = code; Name = name; Regions = regions; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The code of the region. public string Code { get; set; } + /// The name of the region. public string Name { get; set; } + /// The list of Regions grouped under this Region in the Geographic Hierarchy. public IList Regions { get; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.Serialization.cs index 1e1f86025d16..be1ddfe219a4 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.Serialization.cs @@ -10,13 +10,67 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerRelativeDnsNameAvailabilityContent : IUtf8JsonSerializable, IJsonModel + /// Parameters supplied to check Traffic Manager name operation. + public partial class TrafficManagerRelativeDnsNameAvailabilityContent : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerRelativeDnsNameAvailabilityContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerRelativeDnsNameAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerRelativeDnsNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficManagerRelativeDnsNameAvailabilityContent trafficManagerRelativeDnsNameAvailabilityContent) + { + if (trafficManagerRelativeDnsNameAvailabilityContent == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficManagerRelativeDnsNameAvailabilityContent, ModelSerializationExtensions.WireOptions); + return content; + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +82,11 @@ void IJsonModel.Write(Utf8Json /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -44,15 +97,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("type"u8); writer.WriteStringValue(ResourceType.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,84 +114,56 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerRelativeDnsNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerRelativeDnsNameAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerRelativeDnsNameAvailabilityContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerRelativeDnsNameAvailabilityContent(document.RootElement, options); } - internal static TrafficManagerRelativeDnsNameAvailabilityContent DeserializeTrafficManagerRelativeDnsNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerRelativeDnsNameAvailabilityContent DeserializeTrafficManagerRelativeDnsNameAvailabilityContent(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string name = default; - ResourceType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerRelativeDnsNameAvailabilityContent(name, type, serializedAdditionalRawData); + return new TrafficManagerRelativeDnsNameAvailabilityContent(name, resourceType, additionalBinaryDataProperties); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerRelativeDnsNameAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerRelativeDnsNameAvailabilityContent(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerRelativeDnsNameAvailabilityContent)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.cs index 306bd7614266..578dd9c86767 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerRelativeDnsNameAvailabilityContent.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// Parameters supplied to check Traffic Manager name operation. public partial class TrafficManagerRelativeDnsNameAvailabilityContent { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerRelativeDnsNameAvailabilityContent() @@ -54,16 +25,17 @@ public TrafficManagerRelativeDnsNameAvailabilityContent() /// Initializes a new instance of . /// The name of the resource. /// The type of the resource. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerRelativeDnsNameAvailabilityContent(string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerRelativeDnsNameAvailabilityContent(string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties) { Name = name; ResourceType = resourceType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the resource. public string Name { get; set; } + /// The type of the resource. public ResourceType? ResourceType { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.Serialization.cs index bbcaf8d4fa08..de8641e0dcf7 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.Serialization.cs @@ -10,13 +10,55 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerResourceData : IUtf8JsonSerializable, IJsonModel + /// The core properties of ARM resources. + public partial class TrafficManagerResourceData : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +70,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -49,15 +90,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("type"u8); writer.WriteStringValue(ResourceType.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,94 +107,66 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficManagerResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerResourceData(document.RootElement, options); } - internal static TrafficManagerResourceData DeserializeTrafficManagerResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerResourceData DeserializeTrafficManagerResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerResourceData(id, name, type, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerResourceData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerResourceData)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerResourceData(id, name, resourceType, additionalBinaryDataProperties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.cs index f068626238cc..45417d5bba90 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerResourceData.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.TrafficManager.Models /// The core properties of ARM resources. public partial class TrafficManagerResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public TrafficManagerResourceData() @@ -55,19 +26,21 @@ public TrafficManagerResourceData() /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - internal TrafficManagerResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficManagerResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties) { Id = id; Name = name; ResourceType = resourceType; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. public ResourceIdentifier Id { get; set; } + /// The name of the resource. public string Name { get; set; } + /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. public ResourceType? ResourceType { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.Serialization.cs index 9e769b0b14df..06c3276c821e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.Serialization.cs @@ -10,13 +10,55 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { - public partial class TrafficManagerTrackedResourceData : IUtf8JsonSerializable, IJsonModel + /// The resource model definition for a ARM tracked top level resource. + public partial class TrafficManagerTrackedResourceData : TrafficManagerResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerTrackedResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerTrackedResourceData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +70,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Tags)) { @@ -42,6 +83,11 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -53,125 +99,104 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - TrafficManagerTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerTrackedResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerTrackedResourceData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerTrackedResourceData(document.RootElement, options); } - internal static TrafficManagerTrackedResourceData DeserializeTrafficManagerTrackedResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerTrackedResourceData DeserializeTrafficManagerTrackedResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary tags = default; - AzureLocation? location = default; ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation? location = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("tags"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("location"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TrafficManagerTrackedResourceData( id, name, - type, - serializedAdditionalRawData, + resourceType, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerTrackedResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerTrackedResourceData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerTrackedResourceData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.cs index 041890388eff..6e7a989c7ef7 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficManagerTrackedResourceData.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -24,10 +25,10 @@ public TrafficManagerTrackedResourceData() /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Resource tags. /// The Azure Region where the resource lives. - internal TrafficManagerTrackedResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, IDictionary tags, AzureLocation? location) : base(id, name, resourceType, serializedAdditionalRawData) + internal TrafficManagerTrackedResourceData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation? location) : base(id, name, resourceType, additionalBinaryDataProperties) { Tags = tags; Location = location; @@ -35,6 +36,7 @@ internal TrafficManagerTrackedResourceData(ResourceIdentifier id, string name, R /// Resource tags. public IDictionary Tags { get; } + /// The Azure Region where the resource lives. public AzureLocation? Location { get; set; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficRoutingMethod.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficRoutingMethod.cs index f6078dbf6c1e..bdd445a4834b 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficRoutingMethod.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficRoutingMethod.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,14 +15,6 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficRoutingMethod : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TrafficRoutingMethod(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - private const string PerformanceValue = "Performance"; private const string PriorityValue = "Priority"; private const string WeightedValue = "Weighted"; @@ -29,35 +22,64 @@ public TrafficRoutingMethod(string value) private const string MultiValueValue = "MultiValue"; private const string SubnetValue = "Subnet"; - /// Performance. + /// Initializes a new instance of . + /// The value. + /// is null. + public TrafficRoutingMethod(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Performance. public static TrafficRoutingMethod Performance { get; } = new TrafficRoutingMethod(PerformanceValue); - /// Priority. + + /// Gets the Priority. public static TrafficRoutingMethod Priority { get; } = new TrafficRoutingMethod(PriorityValue); - /// Weighted. + + /// Gets the Weighted. public static TrafficRoutingMethod Weighted { get; } = new TrafficRoutingMethod(WeightedValue); - /// Geographic. + + /// Gets the Geographic. public static TrafficRoutingMethod Geographic { get; } = new TrafficRoutingMethod(GeographicValue); - /// MultiValue. + + /// Gets the MultiValue. public static TrafficRoutingMethod MultiValue { get; } = new TrafficRoutingMethod(MultiValueValue); - /// Subnet. + + /// Gets the Subnet. public static TrafficRoutingMethod Subnet { get; } = new TrafficRoutingMethod(SubnetValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficRoutingMethod left, TrafficRoutingMethod right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficRoutingMethod left, TrafficRoutingMethod right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficRoutingMethod(string value) => new TrafficRoutingMethod(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficRoutingMethod?(string value) => value == null ? null : new TrafficRoutingMethod(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficRoutingMethod other && Equals(other); - /// + + /// public bool Equals(TrafficRoutingMethod other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficViewEnrollmentStatus.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficViewEnrollmentStatus.cs index be0a4c5af165..d77a7a4fbf00 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficViewEnrollmentStatus.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/TrafficViewEnrollmentStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.TrafficManager; namespace Azure.ResourceManager.TrafficManager.Models { @@ -14,38 +15,55 @@ namespace Azure.ResourceManager.TrafficManager.Models public readonly partial struct TrafficViewEnrollmentStatus : IEquatable { private readonly string _value; + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficViewEnrollmentStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string EnabledValue = "Enabled"; - private const string DisabledValue = "Disabled"; + _value = value; + } - /// Enabled. + /// Gets the Enabled. public static TrafficViewEnrollmentStatus Enabled { get; } = new TrafficViewEnrollmentStatus(EnabledValue); - /// Disabled. + + /// Gets the Disabled. public static TrafficViewEnrollmentStatus Disabled { get; } = new TrafficViewEnrollmentStatus(DisabledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficViewEnrollmentStatus left, TrafficViewEnrollmentStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TrafficViewEnrollmentStatus left, TrafficViewEnrollmentStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficViewEnrollmentStatus(string value) => new TrafficViewEnrollmentStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficViewEnrollmentStatus?(string value) => value == null ? null : new TrafficViewEnrollmentStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficViewEnrollmentStatus other && Equals(other); - /// + + /// public bool Equals(TrafficViewEnrollmentStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.Serialization.cs new file mode 100644 index 000000000000..1a3dc263eb92 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.ResourceManager.TrafficManager; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager Real User Metrics key response. + internal partial class UserMetricsProperties : IJsonModel + { + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UserMetricsProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeUserMetricsProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserMetricsProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(UserMetricsProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + UserMetricsProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserMetricsProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Key)) + { + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UserMetricsProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UserMetricsProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserMetricsProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserMetricsProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UserMetricsProperties DeserializeUserMetricsProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UserMetricsProperties(key, additionalBinaryDataProperties); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.cs new file mode 100644 index 000000000000..973b7e9a213f --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/Models/UserMetricsProperties.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.TrafficManager.Models +{ + /// Class representing a Traffic Manager Real User Metrics key response. + internal partial class UserMetricsProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public UserMetricsProperties() + { + } + + /// Initializes a new instance of . + /// The key returned by the User Metrics operation. + /// Keeps track of any properties unknown to the library. + internal UserMetricsProperties(string key, IDictionary additionalBinaryDataProperties) + { + Key = key; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The key returned by the User Metrics operation. + public string Key { get; set; } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ProviderConstants.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ProviderConstants.cs index 6924504a1645..c9ae32d6e4e7 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ProviderConstants.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.TrafficManager { - internal static class ProviderConstants + internal static partial class ProviderConstants { + /// Gets the DefaultProviderNamespace. public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/EndpointsRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/EndpointsRestOperations.cs index f3c4c0bfd009..4ee0f0fd1981 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/EndpointsRestOperations.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/EndpointsRestOperations.cs @@ -6,154 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.TrafficManager { - internal partial class EndpointsRestOperations + internal partial class Endpoints { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of EndpointsRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public EndpointsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-04-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data) + /// Initializes a new instance of Endpoints for mocking. + protected Endpoints() { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointType, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointType, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; } - /// Update a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be updated. - /// The Traffic Manager endpoint parameters supplied to the Update operation. - /// The cancellation token to use. - /// , , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + /// Initializes a new instance of Endpoints. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Endpoints(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerEndpointData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Update a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be updated. - /// The Traffic Manager endpoint parameters supplied to the Update operation. - /// The cancellation token to use. - /// , , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - Argument.AssertNotNull(data, nameof(data)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerEndpointData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -165,128 +55,21 @@ internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string res uri.AppendPath(endpointType, true); uri.AppendPath("/", false); uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointType, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + if (_apiVersion != null) { - case 200: - { - TrafficManagerEndpointData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerEndpointData)null, message.Response); - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - /// Gets a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerEndpointData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerEndpointData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointType, true); - uri.AppendPath("/", false); - uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -298,92 +81,23 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath(endpointType, true); uri.AppendPath("/", false); uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create or update a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be created or updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be created or updated. - /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. - /// The cancellation token to use. - /// , , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - { - TrafficManagerEndpointData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create or update a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be created or updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be created or updated. - /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. - /// The cancellation token to use. - /// , , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - { - TrafficManagerEndpointData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -395,16 +109,23 @@ internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string uri.AppendPath(endpointType, true); uri.AppendPath("/", false); uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -416,69 +137,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath(endpointType, true); uri.AppendPath("/", false); uri.AppendPath(endpointName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Deletes a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be deleted. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be deleted. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + if (_apiVersion != null) { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Deletes a Traffic Manager endpoint. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of the Traffic Manager endpoint to be deleted. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be deleted. - /// The cancellation token to use. - /// , , , or is null. - /// , , , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); - Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + request.Headers.SetValue("Accept", "application/json"); + return message; } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/GeographicHierarchiesRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/GeographicHierarchiesRestOperations.cs index 679867d45639..0966384d27aa 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/GeographicHierarchiesRestOperations.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/GeographicHierarchiesRestOperations.cs @@ -6,101 +6,56 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.TrafficManager { - internal partial class GeographicHierarchiesRestOperations + internal partial class GeographicHierarchies { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of GeographicHierarchiesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public GeographicHierarchiesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of GeographicHierarchies for mocking. + protected GeographicHierarchies() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-04-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetDefaultRequestUri() + /// Initializes a new instance of GeographicHierarchies. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal GeographicHierarchies(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetDefaultRequest() - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. - /// The cancellation token to use. - public async Task> GetDefaultAsync(CancellationToken cancellationToken = default) - { - using var message = CreateGetDefaultRequest(); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerGeographicHierarchyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerGeographicHierarchyData.DeserializeTrafficManagerGeographicHierarchyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerGeographicHierarchyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. - /// The cancellation token to use. - public Response GetDefault(CancellationToken cancellationToken = default) + internal HttpMessage CreateGetDefaultRequest(RequestContext context) { - using var message = CreateGetDefaultRequest(); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default", false); + if (_apiVersion != null) { - case 200: - { - TrafficManagerGeographicHierarchyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerGeographicHierarchyData.DeserializeTrafficManagerGeographicHierarchyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerGeographicHierarchyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/HeatMapRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/HeatMapRestOperations.cs index ec2a81c106f3..6b13b99fd863 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/HeatMapRestOperations.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/HeatMapRestOperations.cs @@ -7,66 +7,44 @@ using System; using System.Collections.Generic; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - internal partial class HeatMapRestOperations + internal partial class HeatMap { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of HeatMapRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public HeatMapRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of HeatMap for mocking. + protected HeatMap() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-04-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType, IEnumerable topLeft, IEnumerable botRight) + /// Initializes a new instance of HeatMap. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal HeatMap(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendPath("/heatMaps/", false); - uri.AppendPath(heatMapType.ToString(), true); - if (topLeft != null && !(topLeft is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) - { - uri.AppendQueryDelimited("topLeft", topLeft, ",", true); - } - if (botRight != null && !(botRight is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) - { - uri.AppendQueryDelimited("botRight", botRight, ",", true); - } - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType, IEnumerable topLeft, IEnumerable botRight) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName, string heatMapType, IEnumerable topLeft, IEnumerable botRight, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -75,88 +53,25 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); uri.AppendPath(profileName, true); uri.AppendPath("/heatMaps/", false); - uri.AppendPath(heatMapType.ToString(), true); + uri.AppendPath(heatMapType, true); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } if (topLeft != null && !(topLeft is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) { - uri.AppendQueryDelimited("topLeft", topLeft, ",", true); + uri.AppendQueryDelimited("topLeft", topLeft, ",", escape: true); } if (botRight != null && !(botRight is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) { - uri.AppendQueryDelimited("botRight", botRight, ",", true); + uri.AppendQueryDelimited("botRight", botRight, ",", escape: true); } - uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// Gets latest heatmap for Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of HeatMap for the Traffic Manager profile. - /// The top left latitude,longitude pair of the rectangular viewport to query for. - /// The bottom right latitude,longitude pair of the rectangular viewport to query for. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName, heatMapType, topLeft, botRight); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerHeatMapData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerHeatMapData.DeserializeTrafficManagerHeatMapData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerHeatMapData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets latest heatmap for Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The type of HeatMap for the Traffic Manager profile. - /// The top left latitude,longitude pair of the rectangular viewport to query for. - /// The bottom right latitude,longitude pair of the rectangular viewport to query for. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName, heatMapType, topLeft, botRight); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerHeatMapData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerHeatMapData.DeserializeTrafficManagerHeatMapData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerHeatMapData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/ProfilesRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/ProfilesRestOperations.cs index 1ce1ef32dbc4..6e6976eb3c12 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/ProfilesRestOperations.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/ProfilesRestOperations.cs @@ -6,365 +6,66 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - internal partial class ProfilesRestOperations + internal partial class Profiles { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of ProfilesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public ProfilesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) - { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-04-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequestUri(TrafficManagerRelativeDnsNameAvailabilityContent content) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailability", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(TrafficManagerRelativeDnsNameAvailabilityContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailability", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Checks the availability of a Traffic Manager Relative DNS name. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. - /// The cancellation token to use. - /// is null. - public async Task> CheckTrafficManagerRelativeDnsNameAvailabilityAsync(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerNameAvailabilityResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerNameAvailabilityResult.DeserializeTrafficManagerNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Checks the availability of a Traffic Manager Relative DNS name. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. - /// The cancellation token to use. - /// is null. - public Response CheckTrafficManagerRelativeDnsNameAvailability(TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerNameAvailabilityResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerNameAvailabilityResult.DeserializeTrafficManagerNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCheckTrafficManagerNameAvailabilityV2RequestUri(string subscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent content) + /// Initializes a new instance of Profiles for mocking. + protected Profiles() { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; } - internal HttpMessage CreateCheckTrafficManagerNameAvailabilityV2Request(string subscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent content) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content0 = new Utf8JsonRequestContent(); - content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); - request.Content = content0; - _userAgent.Apply(message); - return message; - } - - /// Checks the availability of a Traffic Manager Relative DNS name. - /// The ID of the target subscription. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> CheckTrafficManagerNameAvailabilityV2Async(string subscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) + /// Initializes a new instance of Profiles. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Profiles(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); - - using var message = CreateCheckTrafficManagerNameAvailabilityV2Request(subscriptionId, content); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerNameAvailabilityResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerNameAvailabilityResult.DeserializeTrafficManagerNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Checks the availability of a Traffic Manager Relative DNS name. - /// The ID of the target subscription. - /// The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response CheckTrafficManagerNameAvailabilityV2(string subscriptionId, TrafficManagerRelativeDnsNameAvailabilityContent content, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNull(content, nameof(content)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateCheckTrafficManagerNameAvailabilityV2Request(subscriptionId, content); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerNameAvailabilityResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerNameAvailabilityResult.DeserializeTrafficManagerNameAvailabilityResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Lists all Traffic Manager profiles within a resource group. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerProfileListResult.DeserializeTrafficManagerProfileListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all Traffic Manager profiles within a resource group. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); + uri.AppendPath(profileName, true); + if (_apiVersion != null) { - case 200: - { - TrafficManagerProfileListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerProfileListResult.DeserializeTrafficManagerProfileListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } - } - - internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); - uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Lists all Traffic Manager profiles within a subscription. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerProfileListResult.DeserializeTrafficManagerProfileListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Lists all Traffic Manager profiles within a subscription. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerProfileListResult.DeserializeTrafficManagerProfileListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string profileName) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -372,16 +73,23 @@ internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string res uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string profileName) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -389,78 +97,23 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Gets a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string profileName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + if (_apiVersion != null) { - case 200: - { - TrafficManagerProfileData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerProfileData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Gets a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string profileName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, profileName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerProfileData)null, message.Response); - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string profileName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -468,280 +121,142 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data) + internal HttpMessage CreateGetBySubscriptionRequest(string subscriptionId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Create or update a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, profileName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) { - case 200: - case 201: - { - TrafficManagerProfileData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); + uri.Reset(nextPage); } - } - - /// Create or update a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, profileName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + else { - case 200: - case 201: - { - TrafficManagerProfileData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); + uri.Reset(new Uri(_endpoint, nextPage)); } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string profileName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string profileName) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Deletes a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile to be deleted. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string profileName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, profileName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + if (nextPage.IsAbsoluteUri) { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); + uri.Reset(nextPage); } - } - - /// Deletes a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile to be deleted. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string profileName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, profileName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + else { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); + uri.Reset(new Uri(_endpoint, nextPage)); } + if (_apiVersion != null) + { + uri.UpdateQuery("api-version", _apiVersion); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data) + internal HttpMessage CreateCheckTrafficManagerRelativeDnsNameAvailabilityRequest(RequestContent content, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailability", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; + return message; } - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data) + internal HttpMessage CreateCheckTrafficManagerNameAvailabilityV2Request(string subscriptionId, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.Network/trafficmanagerprofiles/", false); - uri.AppendPath(profileName, true); - uri.AppendQuery("api-version", _apiVersion, true); + uri.AppendPath("/providers/Microsoft.Network/checkTrafficManagerNameAvailabilityV2", false); + if (_apiVersion != null) + { + uri.AppendQuery("api-version", _apiVersion, true); + } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - - /// Update a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The Traffic Manager profile parameters supplied to the Update operation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, profileName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Traffic Manager profile. - /// The ID of the target subscription. - /// The name of the resource group. The name is case insensitive. - /// The name of the Traffic Manager profile. - /// The Traffic Manager profile parameters supplied to the Update operation. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, profileName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerProfileData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerProfileData.DeserializeTrafficManagerProfileData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs index 272cdd85cd0d..792135dec021 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/RestOperations/TrafficManagerUserMetricsKeysRestOperations.cs @@ -6,210 +6,96 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; namespace Azure.ResourceManager.TrafficManager { - internal partial class TrafficManagerUserMetricsKeysRestOperations + internal partial class TrafficManagerUserMetricsKeys { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of TrafficManagerUserMetricsKeysRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// server parameter. - /// Api Version. - /// or is null. - public TrafficManagerUserMetricsKeysRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of TrafficManagerUserMetricsKeys for mocking. + protected TrafficManagerUserMetricsKeys() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2024-04-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - /// Get the subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, CancellationToken cancellationToken = default) + /// Initializes a new instance of TrafficManagerUserMetricsKeys. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal TrafficManagerUserMetricsKeys(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateGetRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerUserMetricData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerUserMetricData.DeserializeTrafficManagerUserMetricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerUserMetricData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get the subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficManagerUserMetricData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerUserMetricData.DeserializeTrafficManagerUserMetricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficManagerUserMetricData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId) + internal HttpMessage CreateGetRequest(string subscriptionId, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - /// Create or update a subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> CreateOrUpdateAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + if (_apiVersion != null) { - case 201: - { - TrafficManagerUserMetricData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficManagerUserMetricData.DeserializeTrafficManagerUserMetricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - /// Create or update a subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 201: - { - TrafficManagerUserMetricData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficManagerUserMetricData.DeserializeTrafficManagerUserMetricData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - /// Delete a subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateDeleteRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) + if (_apiVersion != null) { - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Put; + request.Headers.SetValue("Accept", "application/json"); + return message; } - /// Delete a subscription-level key used for Real User Metrics collection. - /// The ID of the target subscription. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateDeleteRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default", false); + if (_apiVersion != null) { - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); + uri.AppendQuery("api-version", _apiVersion, true); } + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + request.Headers.SetValue("Accept", "application/json"); + return message; } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointCollection.cs index 7bba0a097692..e008142c5d51 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointCollection.cs @@ -6,11 +6,14 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { @@ -21,77 +24,82 @@ namespace Azure.ResourceManager.TrafficManager /// public partial class TrafficManagerEndpointCollection : ArmCollection { - private readonly ClientDiagnostics _trafficManagerEndpointEndpointsClientDiagnostics; - private readonly EndpointsRestOperations _trafficManagerEndpointEndpointsRestClient; + private readonly ClientDiagnostics _endpointsClientDiagnostics; + private readonly Endpoints _endpointsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerEndpointCollection for mocking. protected TrafficManagerEndpointCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal TrafficManagerEndpointCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerEndpointEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerEndpointResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficManagerEndpointResource.ResourceType, out string trafficManagerEndpointEndpointsApiVersion); - _trafficManagerEndpointEndpointsRestClient = new EndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerEndpointEndpointsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficManagerEndpointResource.ResourceType, out string trafficManagerEndpointApiVersion); + _endpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerEndpointResource.ResourceType.Namespace, Diagnostics); + _endpointsRestClient = new Endpoints(_endpointsClientDiagnostics, Pipeline, Endpoint, trafficManagerEndpointApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficManagerProfileResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficManagerProfileResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficManagerProfileResource.ResourceType), id); + } } /// /// Create or update a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_CreateOrUpdate + /// Operation Id. + /// Endpoints_CreateOrUpdate. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The type of the Traffic Manager endpoint to be created or updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be created or updated. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// , or is null. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, TrafficManagerEndpointType endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.CreateOrUpdate"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, data, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerEndpointEndpointsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerEndpointResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, TrafficManagerEndpointData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,46 +113,49 @@ public virtual async Task> CreateOr /// Create or update a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_CreateOrUpdate + /// Operation Id. + /// Endpoints_CreateOrUpdate. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The type of the Traffic Manager endpoint to be created or updated. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint to be created or updated. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. /// The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// , or is null. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, TrafficManagerEndpointType endpointType, string endpointName, TrafficManagerEndpointData data, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.CreateOrUpdate"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.CreateOrUpdate"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, data, cancellationToken); - var uri = _trafficManagerEndpointEndpointsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerEndpointResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, TrafficManagerEndpointData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -158,40 +169,43 @@ public virtual ArmOperation CreateOrUpdate(WaitU /// Gets a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Endpoints_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> GetAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetAsync(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Get"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Get"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -205,40 +219,43 @@ public virtual async Task> GetAsync(str /// Gets a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Get + /// Operation Id. + /// Endpoints_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual Response Get(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Get(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Get"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Get"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -252,38 +269,51 @@ public virtual Response Get(string endpointType, /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Get + /// Operation Id. + /// Endpoints_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> ExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ExistsAsync(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Exists"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Exists"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerEndpointData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -297,38 +327,51 @@ public virtual async Task> ExistsAsync(string endpointType, strin /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Endpoints_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual Response Exists(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response Exists(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Exists"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.Exists"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerEndpointData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -342,40 +385,55 @@ public virtual Response Exists(string endpointType, string endpointName, C /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Endpoints_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual async Task> GetIfExistsAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetIfExistsAsync(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.GetIfExists"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerEndpointData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -389,40 +447,55 @@ public virtual async Task> GetI /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Endpoints_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. + /// The type of the Traffic Manager endpoint. /// The name of the Traffic Manager endpoint. /// The cancellation token to use. - /// or is an empty string, and was expected to be non-empty. - /// or is null. - public virtual NullableResponse GetIfExists(string endpointType, string endpointName, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual NullableResponse GetIfExists(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(endpointType, nameof(endpointType)); Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.GetIfExists"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointCollection.GetIfExists"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType, endpointName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointType.ToString(), endpointName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerEndpointData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.Serialization.cs index a0ed3f4ded0f..3140e585c0c0 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.Serialization.cs @@ -9,15 +9,76 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - public partial class TrafficManagerEndpointData : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager endpoint. + public partial class TrafficManagerEndpointData : TrafficManagerProxyResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerEndpointData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerEndpointData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerEndpointData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficManagerEndpointData trafficManagerEndpointData) + { + if (trafficManagerEndpointData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficManagerEndpointData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TrafficManagerEndpointData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerEndpointData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,392 +90,89 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(TargetResourceId)) - { - writer.WritePropertyName("targetResourceId"u8); - writer.WriteStringValue(TargetResourceId); - } - if (Optional.IsDefined(Target)) - { - writer.WritePropertyName("target"u8); - writer.WriteStringValue(Target); - } - if (Optional.IsDefined(EndpointStatus)) - { - writer.WritePropertyName("endpointStatus"u8); - writer.WriteStringValue(EndpointStatus.Value.ToString()); - } - if (Optional.IsDefined(Weight)) - { - writer.WritePropertyName("weight"u8); - writer.WriteNumberValue(Weight.Value); - } - if (Optional.IsDefined(Priority)) - { - writer.WritePropertyName("priority"u8); - writer.WriteNumberValue(Priority.Value); - } - if (Optional.IsDefined(EndpointLocation)) - { - writer.WritePropertyName("endpointLocation"u8); - writer.WriteStringValue(EndpointLocation); - } - if (Optional.IsDefined(EndpointMonitorStatus)) - { - writer.WritePropertyName("endpointMonitorStatus"u8); - writer.WriteStringValue(EndpointMonitorStatus.Value.ToString()); - } - if (Optional.IsDefined(MinChildEndpoints)) - { - if (MinChildEndpoints != null) - { - writer.WritePropertyName("minChildEndpoints"u8); - writer.WriteNumberValue(MinChildEndpoints.Value); - } - else - { - writer.WriteNull("minChildEndpoints"); - } - } - if (Optional.IsDefined(MinChildEndpointsIPv4)) - { - if (MinChildEndpointsIPv4 != null) - { - writer.WritePropertyName("minChildEndpointsIPv4"u8); - writer.WriteNumberValue(MinChildEndpointsIPv4.Value); - } - else - { - writer.WriteNull("minChildEndpointsIPv4"); - } - } - if (Optional.IsDefined(MinChildEndpointsIPv6)) + if (Optional.IsDefined(Properties)) { - if (MinChildEndpointsIPv6 != null) - { - writer.WritePropertyName("minChildEndpointsIPv6"u8); - writer.WriteNumberValue(MinChildEndpointsIPv6.Value); - } - else - { - writer.WriteNull("minChildEndpointsIPv6"); - } - } - if (Optional.IsCollectionDefined(GeoMapping)) - { - writer.WritePropertyName("geoMapping"u8); - writer.WriteStartArray(); - foreach (var item in GeoMapping) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (Optional.IsCollectionDefined(Subnets)) - { - writer.WritePropertyName("subnets"u8); - writer.WriteStartArray(); - foreach (var item in Subnets) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(CustomHeaders)) - { - writer.WritePropertyName("customHeaders"u8); - writer.WriteStartArray(); - foreach (var item in CustomHeaders) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(AlwaysServe)) - { - writer.WritePropertyName("alwaysServe"u8); - writer.WriteStringValue(AlwaysServe.Value.ToString()); - } - writer.WriteEndObject(); } - TrafficManagerEndpointData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerEndpointData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerEndpointData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerEndpointData(document.RootElement, options); } - internal static TrafficManagerEndpointData DeserializeTrafficManagerEndpointData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerEndpointData DeserializeTrafficManagerEndpointData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - ResourceIdentifier targetResourceId = default; - string target = default; - TrafficManagerEndpointStatus? endpointStatus = default; - long? weight = default; - long? priority = default; - string endpointLocation = default; - TrafficManagerEndpointMonitorStatus? endpointMonitorStatus = default; - long? minChildEndpoints = default; - long? minChildEndpointsIPv4 = default; - long? minChildEndpointsIPv6 = default; - IList geoMapping = default; - IList subnets = default; - IList customHeaders = default; - TrafficManagerEndpointAlwaysServeStatus? alwaysServe = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + EndpointProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("targetResourceId"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - targetResourceId = new ResourceIdentifier(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("target"u8)) - { - target = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("endpointStatus"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endpointStatus = new TrafficManagerEndpointStatus(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("weight"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - weight = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("priority"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - priority = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("endpointLocation"u8)) - { - endpointLocation = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("endpointMonitorStatus"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endpointMonitorStatus = new TrafficManagerEndpointMonitorStatus(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("minChildEndpoints"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - minChildEndpoints = null; - continue; - } - minChildEndpoints = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("minChildEndpointsIPv4"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - minChildEndpointsIPv4 = null; - continue; - } - minChildEndpointsIPv4 = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("minChildEndpointsIPv6"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - minChildEndpointsIPv6 = null; - continue; - } - minChildEndpointsIPv6 = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("geoMapping"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - geoMapping = array; - continue; - } - if (property0.NameEquals("subnets"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(TrafficManagerEndpointSubnetInfo.DeserializeTrafficManagerEndpointSubnetInfo(item, options)); - } - subnets = array; - continue; - } - if (property0.NameEquals("customHeaders"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(TrafficManagerEndpointCustomHeaderInfo.DeserializeTrafficManagerEndpointCustomHeaderInfo(item, options)); - } - customHeaders = array; - continue; - } - if (property0.NameEquals("alwaysServe"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - alwaysServe = new TrafficManagerEndpointAlwaysServeStatus(property0.Value.GetString()); - continue; - } - } + properties = EndpointProperties.DeserializeEndpointProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerEndpointData( - id, - name, - type, - serializedAdditionalRawData, - targetResourceId, - target, - endpointStatus, - weight, - priority, - endpointLocation, - endpointMonitorStatus, - minChildEndpoints, - minChildEndpointsIPv4, - minChildEndpointsIPv6, - geoMapping ?? new ChangeTrackingList(), - subnets ?? new ChangeTrackingList(), - customHeaders ?? new ChangeTrackingList(), - alwaysServe); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support writing '{options.Format}' format."); - } + return new TrafficManagerEndpointData(id, name, resourceType, additionalBinaryDataProperties, properties); } - - TrafficManagerEndpointData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerEndpointData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerEndpointData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.cs index eaa2491823e6..394c3ffbe3e3 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointData.cs @@ -12,84 +12,252 @@ namespace Azure.ResourceManager.TrafficManager { - /// - /// A class representing the TrafficManagerEndpoint data model. - /// Class representing a Traffic Manager endpoint. - /// + /// Class representing a Traffic Manager endpoint. public partial class TrafficManagerEndpointData : TrafficManagerProxyResourceData { /// Initializes a new instance of . public TrafficManagerEndpointData() { - GeoMapping = new ChangeTrackingList(); - Subnets = new ChangeTrackingList(); - CustomHeaders = new ChangeTrackingList(); } /// Initializes a new instance of . /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - /// The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type 'ExternalEndpoints'. - /// The fully-qualified DNS name or IP address of the endpoint. Traffic Manager returns this value in DNS responses to direct traffic to this endpoint. - /// The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. - /// The weight of this endpoint when using the 'Weighted' traffic routing method. Possible values are from 1 to 1000. - /// The priority of this endpoint when using the 'Priority' traffic routing method. Possible values are from 1 to 1000, lower values represent higher priority. This is an optional parameter. If specified, it must be specified on all endpoints, and no two endpoints can share the same priority value. - /// Specifies the location of the external or nested endpoints when using the 'Performance' traffic routing method. - /// The monitoring status of the endpoint. - /// The minimum number of endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - /// The minimum number of IPv4 (DNS record type A) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - /// The minimum number of IPv6 (DNS record type AAAA) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - /// The list of countries/regions mapped to this endpoint when using the 'Geographic' traffic routing method. Please consult Traffic Manager Geographic documentation for a full list of accepted values. - /// The list of subnets, IP addresses, and/or address ranges mapped to this endpoint when using the 'Subnet' traffic routing method. An empty list will match all ranges not covered by other endpoints. - /// List of custom headers. - /// If Always Serve is enabled, probing for endpoint health will be disabled and endpoints will be included in the traffic routing method. - internal TrafficManagerEndpointData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, ResourceIdentifier targetResourceId, string target, TrafficManagerEndpointStatus? endpointStatus, long? weight, long? priority, string endpointLocation, TrafficManagerEndpointMonitorStatus? endpointMonitorStatus, long? minChildEndpoints, long? minChildEndpointsIPv4, long? minChildEndpointsIPv6, IList geoMapping, IList subnets, IList customHeaders, TrafficManagerEndpointAlwaysServeStatus? alwaysServe) : base(id, name, resourceType, serializedAdditionalRawData) - { - TargetResourceId = targetResourceId; - Target = target; - EndpointStatus = endpointStatus; - Weight = weight; - Priority = priority; - EndpointLocation = endpointLocation; - EndpointMonitorStatus = endpointMonitorStatus; - MinChildEndpoints = minChildEndpoints; - MinChildEndpointsIPv4 = minChildEndpointsIPv4; - MinChildEndpointsIPv6 = minChildEndpointsIPv6; - GeoMapping = geoMapping; - Subnets = subnets; - CustomHeaders = customHeaders; - AlwaysServe = alwaysServe; + /// Keeps track of any properties unknown to the library. + /// The properties of the Traffic Manager endpoint. + internal TrafficManagerEndpointData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, EndpointProperties properties) : base(id, name, resourceType, additionalBinaryDataProperties) + { + Properties = properties; } + /// The properties of the Traffic Manager endpoint. + internal EndpointProperties Properties { get; set; } + /// The Azure Resource URI of the of the endpoint. Not applicable to endpoints of type 'ExternalEndpoints'. - public ResourceIdentifier TargetResourceId { get; set; } + public ResourceIdentifier TargetResourceId + { + get + { + return Properties is null ? default : Properties.TargetResourceId; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.TargetResourceId = value; + } + } + /// The fully-qualified DNS name or IP address of the endpoint. Traffic Manager returns this value in DNS responses to direct traffic to this endpoint. - public string Target { get; set; } + public string Target + { + get + { + return Properties is null ? default : Properties.Target; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.Target = value; + } + } + /// The status of the endpoint. If the endpoint is Enabled, it is probed for endpoint health and is included in the traffic routing method. - public TrafficManagerEndpointStatus? EndpointStatus { get; set; } + public TrafficManagerEndpointStatus? EndpointStatus + { + get + { + return Properties is null ? default : Properties.EndpointStatus; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.EndpointStatus = value.Value; + } + } + /// The weight of this endpoint when using the 'Weighted' traffic routing method. Possible values are from 1 to 1000. - public long? Weight { get; set; } + public long? Weight + { + get + { + return Properties is null ? default : Properties.Weight; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.Weight = value.Value; + } + } + /// The priority of this endpoint when using the 'Priority' traffic routing method. Possible values are from 1 to 1000, lower values represent higher priority. This is an optional parameter. If specified, it must be specified on all endpoints, and no two endpoints can share the same priority value. - public long? Priority { get; set; } + public long? Priority + { + get + { + return Properties is null ? default : Properties.Priority; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.Priority = value.Value; + } + } + /// Specifies the location of the external or nested endpoints when using the 'Performance' traffic routing method. - public string EndpointLocation { get; set; } + public string EndpointLocation + { + get + { + return Properties is null ? default : Properties.EndpointLocation; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.EndpointLocation = value; + } + } + /// The monitoring status of the endpoint. - public TrafficManagerEndpointMonitorStatus? EndpointMonitorStatus { get; set; } + public TrafficManagerEndpointMonitorStatus? EndpointMonitorStatus + { + get + { + return Properties is null ? default : Properties.EndpointMonitorStatus; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.EndpointMonitorStatus = value.Value; + } + } + /// The minimum number of endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - public long? MinChildEndpoints { get; set; } + public long? MinChildEndpoints + { + get + { + return Properties is null ? default : Properties.MinChildEndpoints; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.MinChildEndpoints = value.Value; + } + } + /// The minimum number of IPv4 (DNS record type A) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - public long? MinChildEndpointsIPv4 { get; set; } + public long? MinChildEndpointsIPv4 + { + get + { + return Properties is null ? default : Properties.MinChildEndpointsIPv4; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.MinChildEndpointsIPv4 = value.Value; + } + } + /// The minimum number of IPv6 (DNS record type AAAA) endpoints that must be available in the child profile in order for the parent profile to be considered available. Only applicable to endpoint of type 'NestedEndpoints'. - public long? MinChildEndpointsIPv6 { get; set; } + public long? MinChildEndpointsIPv6 + { + get + { + return Properties is null ? default : Properties.MinChildEndpointsIPv6; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.MinChildEndpointsIPv6 = value.Value; + } + } + /// The list of countries/regions mapped to this endpoint when using the 'Geographic' traffic routing method. Please consult Traffic Manager Geographic documentation for a full list of accepted values. - public IList GeoMapping { get; } + public IList GeoMapping + { + get + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + return Properties.GeoMapping; + } + } + /// The list of subnets, IP addresses, and/or address ranges mapped to this endpoint when using the 'Subnet' traffic routing method. An empty list will match all ranges not covered by other endpoints. - public IList Subnets { get; } + public IList Subnets + { + get + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + return Properties.Subnets; + } + } + /// List of custom headers. - public IList CustomHeaders { get; } + public IList CustomHeaders + { + get + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + return Properties.CustomHeaders; + } + } + /// If Always Serve is enabled, probing for endpoint health will be disabled and endpoints will be included in the traffic routing method. - public TrafficManagerEndpointAlwaysServeStatus? AlwaysServe { get; set; } + public TrafficManagerEndpointAlwaysServeStatus? AlwaysServe + { + get + { + return Properties is null ? default : Properties.AlwaysServe; + } + set + { + if (Properties is null) + { + Properties = new EndpointProperties(); + } + Properties.AlwaysServe = value.Value; + } + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.Serialization.cs index ba3ab66c8db7..946ad343380b 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.TrafficManager { + /// public partial class TrafficManagerEndpointResource : IJsonModel { - private static TrafficManagerEndpointData s_dataDeserializationInstance; - private static TrafficManagerEndpointData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficManagerEndpointData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - TrafficManagerEndpointData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TrafficManagerEndpointData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerTrafficManagerContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficManagerEndpointData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerTrafficManagerContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.cs index 961a6a3c6b6e..b18d17109f1f 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerEndpointResource.cs @@ -6,48 +6,36 @@ #nullable disable using System; -using System.Globalization; -using System.Linq; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { /// - /// A Class representing a TrafficManagerEndpoint along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetTrafficManagerEndpointResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficManagerEndpoint method. + /// A class representing a TrafficManagerEndpoint along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTrafficManagerEndpoints method. /// public partial class TrafficManagerEndpointResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The profileName. - /// The endpointType. - /// The endpointName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, string endpointType, string endpointName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficManagerEndpointEndpointsClientDiagnostics; - private readonly EndpointsRestOperations _trafficManagerEndpointEndpointsRestClient; + private readonly ClientDiagnostics _endpointsClientDiagnostics; + private readonly Endpoints _endpointsRestClient; private readonly TrafficManagerEndpointData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Network/trafficmanagerprofiles/{endpointType}"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerEndpointResource for mocking. protected TrafficManagerEndpointResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal TrafficManagerEndpointResource(ArmClient client, TrafficManagerEndpointData data) : this(client, data.Id) @@ -56,65 +44,94 @@ internal TrafficManagerEndpointResource(ArmClient client, TrafficManagerEndpoint _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal TrafficManagerEndpointResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerEndpointEndpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficManagerEndpointEndpointsApiVersion); - _trafficManagerEndpointEndpointsRestClient = new EndpointsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerEndpointEndpointsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficManagerEndpointApiVersion); + _endpointsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); + _endpointsRestClient = new Endpoints(_endpointsClientDiagnostics, Pipeline, Endpoint, trafficManagerEndpointApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual TrafficManagerEndpointData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The profileName. + /// The endpointType. + /// The endpointName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerEndpointType endpointType, string endpointName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } + } + /// /// Gets a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Get + /// Operation Id. + /// Endpoints_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Get"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Get"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -128,33 +145,41 @@ public virtual async Task> GetAsync(Can /// Gets a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Get + /// Operation Id. + /// Endpoints_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Get"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Get"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -164,112 +189,24 @@ public virtual Response Get(CancellationToken ca } } - /// - /// Deletes a Traffic Manager endpoint. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Delete - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Delete"); - scope.Start(); - try - { - var response = await _trafficManagerEndpointEndpointsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerEndpointEndpointsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Deletes a Traffic Manager endpoint. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Delete - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Delete"); - scope.Start(); - try - { - var response = _trafficManagerEndpointEndpointsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, cancellationToken); - var uri = _trafficManagerEndpointEndpointsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - /// /// Update a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Update + /// Operation Id. + /// Endpoints_Update. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -280,11 +217,21 @@ public virtual async Task> UpdateAsync( { Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Update"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Update"); scope.Start(); try { - var response = await _trafficManagerEndpointEndpointsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, TrafficManagerEndpointData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -298,20 +245,20 @@ public virtual async Task> UpdateAsync( /// Update a Traffic Manager endpoint. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}. /// /// - /// Operation Id - /// Endpoints_Update + /// Operation Id. + /// Endpoints_Update. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -322,11 +269,21 @@ public virtual Response Update(TrafficManagerEnd { Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerEndpointEndpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Update"); + using DiagnosticScope scope = _endpointsClientDiagnostics.CreateScope("TrafficManagerEndpointResource.Update"); scope.Start(); try { - var response = _trafficManagerEndpointEndpointsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.ResourceType.GetLastType(), Id.Name, data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _endpointsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, Id.ResourceType.Type, TrafficManagerEndpointData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerEndpointData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerEndpointResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyCollection.cs new file mode 100644 index 000000000000..ff393984e8e3 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyCollection.cs @@ -0,0 +1,360 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.TrafficManager +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTrafficManagerGeographicHierarchies method from an instance of . + /// + public partial class TrafficManagerGeographicHierarchyCollection : ArmCollection + { + private readonly ClientDiagnostics _geographicHierarchiesClientDiagnostics; + private readonly GeographicHierarchies _geographicHierarchiesRestClient; + + /// Initializes a new instance of TrafficManagerGeographicHierarchyCollection for mocking. + protected TrafficManagerGeographicHierarchyCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TrafficManagerGeographicHierarchyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(TrafficManagerGeographicHierarchyResource.ResourceType, out string trafficManagerGeographicHierarchyApiVersion); + _geographicHierarchiesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerGeographicHierarchyResource.ResourceType.Namespace, Diagnostics); + _geographicHierarchiesRestClient = new GeographicHierarchies(_geographicHierarchiesClientDiagnostics, Pipeline, Endpoint, trafficManagerGeographicHierarchyApiVersion ?? "2022-04-01"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != TenantResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TenantResource.ResourceType), id); + } + } + + /// + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> ExistsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerGeographicHierarchyData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual Response Exists(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerGeographicHierarchyData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetIfExistsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerGeographicHierarchyData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. + /// + /// + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual NullableResponse GetIfExists(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerGeographicHierarchyData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.Serialization.cs index 6a0b6079db8d..acd742bb46e3 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.Serialization.cs @@ -9,15 +9,64 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - public partial class TrafficManagerGeographicHierarchyData : IUtf8JsonSerializable, IJsonModel + /// Class representing the Geographic hierarchy used with the Geographic traffic routing method. + public partial class TrafficManagerGeographicHierarchyData : TrafficManagerProxyResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerGeographicHierarchyData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerGeographicHierarchyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerGeographicHierarchyData)PersistableModelCreateCore(data, options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficManagerGeographicHierarchyData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerGeographicHierarchyData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,133 +78,89 @@ void IJsonModel.Write(Utf8JsonWriter writ /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(GeographicHierarchy)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("geographicHierarchy"u8); - writer.WriteObjectValue(GeographicHierarchy, options); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - TrafficManagerGeographicHierarchyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerGeographicHierarchyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerGeographicHierarchyData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerGeographicHierarchyData(document.RootElement, options); } - internal static TrafficManagerGeographicHierarchyData DeserializeTrafficManagerGeographicHierarchyData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerGeographicHierarchyData DeserializeTrafficManagerGeographicHierarchyData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - TrafficManagerRegion geographicHierarchy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + GeographicHierarchyProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("geographicHierarchy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - geographicHierarchy = TrafficManagerRegion.DeserializeTrafficManagerRegion(property0.Value, options); - continue; - } - } + properties = GeographicHierarchyProperties.DeserializeGeographicHierarchyProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerGeographicHierarchyData(id, name, type, serializedAdditionalRawData, geographicHierarchy); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerGeographicHierarchyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerGeographicHierarchyData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerGeographicHierarchyData)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerGeographicHierarchyData(id, name, resourceType, additionalBinaryDataProperties, properties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.cs index 736287e6a3a2..5b73d1a4409d 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyData.cs @@ -12,10 +12,7 @@ namespace Azure.ResourceManager.TrafficManager { - /// - /// A class representing the TrafficManagerGeographicHierarchy data model. - /// Class representing the Geographic hierarchy used with the Geographic traffic routing method. - /// + /// Class representing the Geographic hierarchy used with the Geographic traffic routing method. public partial class TrafficManagerGeographicHierarchyData : TrafficManagerProxyResourceData { /// Initializes a new instance of . @@ -27,14 +24,31 @@ public TrafficManagerGeographicHierarchyData() /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - /// The region at the root of the hierarchy from all the regions in the hierarchy can be retrieved. - internal TrafficManagerGeographicHierarchyData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, TrafficManagerRegion geographicHierarchy) : base(id, name, resourceType, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + /// The properties of the Geographic Hierarchy resource. + internal TrafficManagerGeographicHierarchyData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, GeographicHierarchyProperties properties) : base(id, name, resourceType, additionalBinaryDataProperties) { - GeographicHierarchy = geographicHierarchy; + Properties = properties; } + /// The properties of the Geographic Hierarchy resource. + internal GeographicHierarchyProperties Properties { get; set; } + /// The region at the root of the hierarchy from all the regions in the hierarchy can be retrieved. - public TrafficManagerRegion GeographicHierarchy { get; set; } + public TrafficManagerRegion GeographicHierarchy + { + get + { + return Properties is null ? default : Properties.GeographicHierarchy; + } + set + { + if (Properties is null) + { + Properties = new GeographicHierarchyProperties(); + } + Properties.GeographicHierarchy = value; + } + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.Serialization.cs index 923e508b5865..1f774825af12 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.TrafficManager { + /// public partial class TrafficManagerGeographicHierarchyResource : IJsonModel { - private static TrafficManagerGeographicHierarchyData s_dataDeserializationInstance; - private static TrafficManagerGeographicHierarchyData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficManagerGeographicHierarchyData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - TrafficManagerGeographicHierarchyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TrafficManagerGeographicHierarchyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerTrafficManagerContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficManagerGeographicHierarchyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerTrafficManagerContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.cs index b0f0a7866864..cac1d0e55312 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerGeographicHierarchyResource.cs @@ -6,43 +6,36 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.TrafficManager { /// - /// A Class representing a TrafficManagerGeographicHierarchy along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetTrafficManagerGeographicHierarchyResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficManagerGeographicHierarchy method. + /// A class representing a TrafficManagerGeographicHierarchy along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTrafficManagerGeographicHierarchies method. /// public partial class TrafficManagerGeographicHierarchyResource : ArmResource { - /// Generate the resource identifier of a instance. - public static ResourceIdentifier CreateResourceIdentifier() - { - var resourceId = $"/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficManagerGeographicHierarchyGeographicHierarchiesClientDiagnostics; - private readonly GeographicHierarchiesRestOperations _trafficManagerGeographicHierarchyGeographicHierarchiesRestClient; + private readonly ClientDiagnostics _geographicHierarchiesClientDiagnostics; + private readonly GeographicHierarchies _geographicHierarchiesRestClient; private readonly TrafficManagerGeographicHierarchyData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Network/trafficManagerGeographicHierarchies"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerGeographicHierarchyResource for mocking. protected TrafficManagerGeographicHierarchyResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal TrafficManagerGeographicHierarchyResource(ArmClient client, TrafficManagerGeographicHierarchyData data) : this(client, data.Id) @@ -51,71 +44,89 @@ internal TrafficManagerGeographicHierarchyResource(ArmClient client, TrafficMana _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal TrafficManagerGeographicHierarchyResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerGeographicHierarchyGeographicHierarchiesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficManagerGeographicHierarchyGeographicHierarchiesApiVersion); - _trafficManagerGeographicHierarchyGeographicHierarchiesRestClient = new GeographicHierarchiesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerGeographicHierarchyGeographicHierarchiesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficManagerGeographicHierarchyApiVersion); + _geographicHierarchiesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); + _geographicHierarchiesRestClient = new GeographicHierarchies(_geographicHierarchiesClientDiagnostics, Pipeline, Endpoint, trafficManagerGeographicHierarchyApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual TrafficManagerGeographicHierarchyData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + public static ResourceIdentifier CreateResourceIdentifier() + { + string resourceId = $"/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. /// /// - /// Request Path - /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. /// /// - /// Operation Id - /// GeographicHierarchies_GetDefault + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerGeographicHierarchyGeographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyResource.Get"); + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyResource.Get"); scope.Start(); try { - var response = await _trafficManagerGeographicHierarchyGeographicHierarchiesRestClient.GetDefaultAsync(cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -129,33 +140,41 @@ public virtual async Task> G /// Gets the default Geographic Hierarchy used by the Geographic traffic routing method. /// /// - /// Request Path - /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default + /// Request Path. + /// /providers/Microsoft.Network/trafficManagerGeographicHierarchies/default. /// /// - /// Operation Id - /// GeographicHierarchies_GetDefault + /// Operation Id. + /// TrafficManagerGeographicHierarchies_GetDefault. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerGeographicHierarchyGeographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyResource.Get"); + using DiagnosticScope scope = _geographicHierarchiesClientDiagnostics.CreateScope("TrafficManagerGeographicHierarchyResource.Get"); scope.Start(); try { - var response = _trafficManagerGeographicHierarchyGeographicHierarchiesRestClient.GetDefault(cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _geographicHierarchiesRestClient.CreateGetDefaultRequest(context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerGeographicHierarchyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerGeographicHierarchyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapCollection.cs index e47595349961..3d23307d23e5 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapCollection.cs @@ -7,11 +7,13 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager @@ -23,67 +25,73 @@ namespace Azure.ResourceManager.TrafficManager /// public partial class TrafficManagerHeatMapCollection : ArmCollection { - private readonly ClientDiagnostics _trafficManagerHeatMapHeatMapClientDiagnostics; - private readonly HeatMapRestOperations _trafficManagerHeatMapHeatMapRestClient; + private readonly ClientDiagnostics _heatMapClientDiagnostics; + private readonly HeatMap _heatMapRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerHeatMapCollection for mocking. protected TrafficManagerHeatMapCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal TrafficManagerHeatMapCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerHeatMapHeatMapClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerHeatMapResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficManagerHeatMapResource.ResourceType, out string trafficManagerHeatMapHeatMapApiVersion); - _trafficManagerHeatMapHeatMapRestClient = new HeatMapRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerHeatMapHeatMapApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficManagerHeatMapResource.ResourceType, out string trafficManagerHeatMapApiVersion); + _heatMapClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerHeatMapResource.ResourceType.Namespace, Diagnostics); + _heatMapRestClient = new HeatMap(_heatMapClientDiagnostics, Pipeline, Endpoint, trafficManagerHeatMapApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficManagerProfileResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficManagerProfileResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficManagerProfileResource.ResourceType), id); + } } /// /// Gets latest heatmap for Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual async Task> GetAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Get"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Get"); scope.Start(); try { - var response = await _trafficManagerHeatMapHeatMapRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -97,36 +105,40 @@ public virtual async Task> GetAsync(Traf /// Gets latest heatmap for Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Operation Id - /// HeatMap_Get + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual Response Get(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual Response Get(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Get"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Get"); scope.Start(); try { - var response = _trafficManagerHeatMapHeatMapRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -140,34 +152,48 @@ public virtual Response Get(TrafficManagerHeatMap /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual async Task> ExistsAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual async Task> ExistsAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Exists"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Exists"); scope.Start(); try { - var response = await _trafficManagerHeatMapHeatMapRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerHeatMapData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -181,34 +207,48 @@ public virtual async Task> ExistsAsync(TrafficManagerHeatMapType /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual Response Exists(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual Response Exists(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Exists"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.Exists"); scope.Start(); try { - var response = _trafficManagerHeatMapHeatMapRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerHeatMapData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -222,36 +262,52 @@ public virtual Response Exists(TrafficManagerHeatMapType heatMapType, IEnu /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Operation Id - /// HeatMap_Get + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual async Task> GetIfExistsAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual async Task> GetIfExistsAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.GetIfExists"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficManagerHeatMapHeatMapRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerHeatMapData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -265,36 +321,52 @@ public virtual async Task> GetIf /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// - /// The type of HeatMap for the Traffic Manager profile. + /// The type of the heatmap. /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual NullableResponse GetIfExists(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual NullableResponse GetIfExists(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.GetIfExists"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapCollection.GetIfExists"); scope.Start(); try { - var response = _trafficManagerHeatMapHeatMapRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType, topLeft, botRight, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, heatMapType.ToString(), topLeft, botRight, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerHeatMapData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.Serialization.cs index d970c49ce001..a08ab962e6ec 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.Serialization.cs @@ -9,15 +9,64 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - public partial class TrafficManagerHeatMapData : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager HeatMap. + public partial class TrafficManagerHeatMapData : TrafficManagerProxyResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerHeatMapData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support reading '{options.Format}' format."); + } + } + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerHeatMapData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerHeatMapData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficManagerHeatMapData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerHeatMapData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,206 +78,89 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(StartOn)) - { - writer.WritePropertyName("startTime"u8); - writer.WriteStringValue(StartOn.Value, "O"); - } - if (Optional.IsDefined(EndOn)) - { - writer.WritePropertyName("endTime"u8); - writer.WriteStringValue(EndOn.Value, "O"); - } - if (Optional.IsCollectionDefined(Endpoints)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("endpoints"u8); - writer.WriteStartArray(); - foreach (var item in Endpoints) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsCollectionDefined(TrafficFlows)) - { - writer.WritePropertyName("trafficFlows"u8); - writer.WriteStartArray(); - foreach (var item in TrafficFlows) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - TrafficManagerHeatMapData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerHeatMapData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerHeatMapData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerHeatMapData(document.RootElement, options); } - internal static TrafficManagerHeatMapData DeserializeTrafficManagerHeatMapData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerHeatMapData DeserializeTrafficManagerHeatMapData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - DateTimeOffset? startTime = default; - DateTimeOffset? endTime = default; - IList endpoints = default; - IList trafficFlows = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + HeatMapProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("startTime"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startTime = property0.Value.GetDateTimeOffset("O"); - continue; - } - if (property0.NameEquals("endTime"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endTime = property0.Value.GetDateTimeOffset("O"); - continue; - } - if (property0.NameEquals("endpoints"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(TrafficManagerHeatMapEndpoint.DeserializeTrafficManagerHeatMapEndpoint(item, options)); - } - endpoints = array; - continue; - } - if (property0.NameEquals("trafficFlows"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(TrafficManagerHeatMapTrafficFlow.DeserializeTrafficManagerHeatMapTrafficFlow(item, options)); - } - trafficFlows = array; - continue; - } - } + properties = HeatMapProperties.DeserializeHeatMapProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerHeatMapData( - id, - name, - type, - serializedAdditionalRawData, - startTime, - endTime, - endpoints ?? new ChangeTrackingList(), - trafficFlows ?? new ChangeTrackingList()); + return new TrafficManagerHeatMapData(id, name, resourceType, additionalBinaryDataProperties, properties); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerHeatMapData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerHeatMapData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerHeatMapData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.cs index a82a9b422d97..193a89173157 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapData.cs @@ -12,43 +12,86 @@ namespace Azure.ResourceManager.TrafficManager { - /// - /// A class representing the TrafficManagerHeatMap data model. - /// Class representing a Traffic Manager HeatMap. - /// + /// Class representing a Traffic Manager HeatMap. public partial class TrafficManagerHeatMapData : TrafficManagerProxyResourceData { /// Initializes a new instance of . public TrafficManagerHeatMapData() { - Endpoints = new ChangeTrackingList(); - TrafficFlows = new ChangeTrackingList(); } /// Initializes a new instance of . /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - /// The beginning of the time window for this HeatMap, inclusive. - /// The ending of the time window for this HeatMap, exclusive. - /// The endpoints used in this HeatMap calculation. - /// The traffic flows produced in this HeatMap calculation. - internal TrafficManagerHeatMapData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, DateTimeOffset? startOn, DateTimeOffset? endOn, IList endpoints, IList trafficFlows) : base(id, name, resourceType, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + /// The properties of the Traffic Manager HeatMap. + internal TrafficManagerHeatMapData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, HeatMapProperties properties) : base(id, name, resourceType, additionalBinaryDataProperties) { - StartOn = startOn; - EndOn = endOn; - Endpoints = endpoints; - TrafficFlows = trafficFlows; + Properties = properties; } + /// The properties of the Traffic Manager HeatMap. + internal HeatMapProperties Properties { get; set; } + /// The beginning of the time window for this HeatMap, inclusive. - public DateTimeOffset? StartOn { get; set; } + public DateTimeOffset? StartOn + { + get + { + return Properties is null ? default : Properties.StartOn; + } + set + { + if (Properties is null) + { + Properties = new HeatMapProperties(); + } + Properties.StartOn = value.Value; + } + } + /// The ending of the time window for this HeatMap, exclusive. - public DateTimeOffset? EndOn { get; set; } + public DateTimeOffset? EndOn + { + get + { + return Properties is null ? default : Properties.EndOn; + } + set + { + if (Properties is null) + { + Properties = new HeatMapProperties(); + } + Properties.EndOn = value.Value; + } + } + /// The endpoints used in this HeatMap calculation. - public IList Endpoints { get; } + public IList Endpoints + { + get + { + if (Properties is null) + { + Properties = new HeatMapProperties(); + } + return Properties.Endpoints; + } + } + /// The traffic flows produced in this HeatMap calculation. - public IList TrafficFlows { get; } + public IList TrafficFlows + { + get + { + if (Properties is null) + { + Properties = new HeatMapProperties(); + } + return Properties.TrafficFlows; + } + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.Serialization.cs index 1f6ed79421a2..fdc230864b0d 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.TrafficManager { + /// public partial class TrafficManagerHeatMapResource : IJsonModel { - private static TrafficManagerHeatMapData s_dataDeserializationInstance; - private static TrafficManagerHeatMapData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficManagerHeatMapData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - TrafficManagerHeatMapData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TrafficManagerHeatMapData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerTrafficManagerContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficManagerHeatMapData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerTrafficManagerContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.cs index a91c6e298b9f..28afdcd434ca 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerHeatMapResource.cs @@ -7,47 +7,36 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { /// - /// A Class representing a TrafficManagerHeatMap along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetTrafficManagerHeatMapResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficManagerHeatMap method. + /// A class representing a TrafficManagerHeatMap along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTrafficManagerHeatMaps method. /// public partial class TrafficManagerHeatMapResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The profileName. - /// The heatMapType. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficManagerHeatMapHeatMapClientDiagnostics; - private readonly HeatMapRestOperations _trafficManagerHeatMapHeatMapRestClient; + private readonly ClientDiagnostics _heatMapClientDiagnostics; + private readonly HeatMap _heatMapRestClient; private readonly TrafficManagerHeatMapData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Network/trafficmanagerprofiles/heatMaps"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerHeatMapResource for mocking. protected TrafficManagerHeatMapResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal TrafficManagerHeatMapResource(ArmClient client, TrafficManagerHeatMapData data) : this(client, data.Id) @@ -56,73 +45,95 @@ internal TrafficManagerHeatMapResource(ArmClient client, TrafficManagerHeatMapDa _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal TrafficManagerHeatMapResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerHeatMapHeatMapClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficManagerHeatMapHeatMapApiVersion); - _trafficManagerHeatMapHeatMapRestClient = new HeatMapRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerHeatMapHeatMapApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficManagerHeatMapApiVersion); + _heatMapClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); + _heatMapRestClient = new HeatMap(_heatMapClientDiagnostics, Pipeline, Endpoint, trafficManagerHeatMapApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual TrafficManagerHeatMapData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The profileName. + /// The heatMapType. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName, TrafficManagerHeatMapType heatMapType) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Gets latest heatmap for Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Operation Id - /// HeatMap_Get + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual async Task> GetAsync(IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapResource.Get"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapResource.Get"); scope.Start(); try { - var response = await _trafficManagerHeatMapHeatMapRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, topLeft, botRight, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, topLeft, botRight, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -136,35 +147,43 @@ public virtual async Task> GetAsync(IEnu /// Gets latest heatmap for Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType}. /// /// - /// Operation Id - /// HeatMap_Get + /// Operation Id. + /// HeatMapModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The top left latitude,longitude pair of the rectangular viewport to query for. /// The bottom right latitude,longitude pair of the rectangular viewport to query for. /// The cancellation token to use. - public virtual Response Get(IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + public virtual Response Get(IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerHeatMapHeatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapResource.Get"); + using DiagnosticScope scope = _heatMapClientDiagnostics.CreateScope("TrafficManagerHeatMapResource.Get"); scope.Start(); try { - var response = _trafficManagerHeatMapHeatMapRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, topLeft, botRight, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _heatMapRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, topLeft, botRight, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerHeatMapData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerHeatMapResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileCollection.cs index 5aee377b5c33..d0e2455c2def 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.TrafficManager @@ -25,51 +26,49 @@ namespace Azure.ResourceManager.TrafficManager /// public partial class TrafficManagerProfileCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _trafficManagerProfileProfilesClientDiagnostics; - private readonly ProfilesRestOperations _trafficManagerProfileProfilesRestClient; + private readonly ClientDiagnostics _profilesClientDiagnostics; + private readonly Profiles _profilesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerProfileCollection for mocking. protected TrafficManagerProfileCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal TrafficManagerProfileCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerProfileProfilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerProfileResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficManagerProfileResource.ResourceType, out string trafficManagerProfileProfilesApiVersion); - _trafficManagerProfileProfilesRestClient = new ProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerProfileProfilesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficManagerProfileResource.ResourceType, out string trafficManagerProfileApiVersion); + _profilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerProfileResource.ResourceType.Namespace, Diagnostics); + _profilesRestClient = new Profiles(_profilesClientDiagnostics, Pipeline, Endpoint, trafficManagerProfileApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceGroupResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } } /// /// Create or update a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// @@ -77,23 +76,31 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The name of the Traffic Manager profile. /// The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.CreateOrUpdate"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, profileName, data, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerProfileProfilesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, profileName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, TrafficManagerProfileData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -107,20 +114,16 @@ public virtual async Task> CreateOrU /// Create or update a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_CreateOrUpdate + /// Operation Id. + /// Profiles_CreateOrUpdate. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// @@ -128,23 +131,31 @@ public virtual async Task> CreateOrU /// The name of the Traffic Manager profile. /// The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string profileName, TrafficManagerProfileData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.CreateOrUpdate"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.CreateOrUpdate"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, profileName, data, cancellationToken); - var uri = _trafficManagerProfileProfilesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, profileName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, TrafficManagerProfileData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -158,38 +169,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUn /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Get + /// Operation Id. + /// Profiles_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Get"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Get"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -203,38 +218,42 @@ public virtual async Task> GetAsync(stri /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Get"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Get"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -248,49 +267,44 @@ public virtual Response Get(string profileName, C /// Lists all Traffic Manager profiles within a resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles. /// /// - /// Operation Id - /// Profiles_ListByResourceGroup + /// Operation Id. + /// Profiles_ListByResourceGroup. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _trafficManagerProfileProfilesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, null, e => new TrafficManagerProfileResource(Client, TrafficManagerProfileData.DeserializeTrafficManagerProfileData(e)), _trafficManagerProfileProfilesClientDiagnostics, Pipeline, "TrafficManagerProfileCollection.GetAll", "value", null, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new ProfilesGetByResourceGroupAsyncCollectionResultOfT(_profilesRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new TrafficManagerProfileResource(Client, data)); } /// /// Lists all Traffic Manager profiles within a resource group. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles - /// - /// - /// Operation Id - /// Profiles_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// @@ -298,44 +312,61 @@ public virtual AsyncPageable GetAllAsync(Cancella /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _trafficManagerProfileProfilesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, null, e => new TrafficManagerProfileResource(Client, TrafficManagerProfileData.DeserializeTrafficManagerProfileData(e)), _trafficManagerProfileProfilesClientDiagnostics, Pipeline, "TrafficManagerProfileCollection.GetAll", "value", null, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new ProfilesGetByResourceGroupCollectionResultOfT(_profilesRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new TrafficManagerProfileResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Exists"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Exists"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerProfileData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -349,36 +380,50 @@ public virtual async Task> ExistsAsync(string profileName, Cancel /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Get + /// Operation Id. + /// Profiles_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Exists"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.Exists"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerProfileData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -392,38 +437,54 @@ public virtual Response Exists(string profileName, CancellationToken cance /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Operation Id. + /// Profiles_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetIfExists"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerProfileData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -437,38 +498,54 @@ public virtual async Task> GetIf /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Get + /// Operation Id. + /// Profiles_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2022-04-01. /// /// /// /// The name of the Traffic Manager profile. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string profileName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetIfExists"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileCollection.GetIfExists"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, profileName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, profileName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerProfileData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -488,6 +565,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.Serialization.cs index fe86a23554e7..3475a4479f5b 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.Serialization.cs @@ -9,15 +9,76 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - public partial class TrafficManagerProfileData : IUtf8JsonSerializable, IJsonModel + /// Class representing a Traffic Manager profile. + public partial class TrafficManagerProfileData : TrafficManagerTrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerProfileData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerProfileData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerProfileData)PersistableModelCreateCore(data, options); + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficManagerProfileData trafficManagerProfileData) + { + if (trafficManagerProfileData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficManagerProfileData, ModelSerializationExtensions.WireOptions); + return content; + } + /// The to deserialize the from. + internal static TrafficManagerProfileData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerProfileData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -29,321 +90,128 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(ProfileStatus)) - { - writer.WritePropertyName("profileStatus"u8); - writer.WriteStringValue(ProfileStatus.Value.ToString()); - } - if (Optional.IsDefined(TrafficRoutingMethod)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("trafficRoutingMethod"u8); - writer.WriteStringValue(TrafficRoutingMethod.Value.ToString()); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (Optional.IsDefined(DnsConfig)) - { - writer.WritePropertyName("dnsConfig"u8); - writer.WriteObjectValue(DnsConfig, options); - } - if (Optional.IsDefined(MonitorConfig)) - { - writer.WritePropertyName("monitorConfig"u8); - writer.WriteObjectValue(MonitorConfig, options); - } - if (Optional.IsCollectionDefined(Endpoints)) - { - writer.WritePropertyName("endpoints"u8); - writer.WriteStartArray(); - foreach (var item in Endpoints) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(TrafficViewEnrollmentStatus)) - { - writer.WritePropertyName("trafficViewEnrollmentStatus"u8); - writer.WriteStringValue(TrafficViewEnrollmentStatus.Value.ToString()); - } - if (Optional.IsCollectionDefined(AllowedEndpointRecordTypes)) - { - writer.WritePropertyName("allowedEndpointRecordTypes"u8); - writer.WriteStartArray(); - foreach (var item in AllowedEndpointRecordTypes) - { - writer.WriteStringValue(item.ToString()); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(MaxReturn)) - { - if (MaxReturn != null) - { - writer.WritePropertyName("maxReturn"u8); - writer.WriteNumberValue(MaxReturn.Value); - } - else - { - writer.WriteNull("maxReturn"); - } - } - if (Optional.IsDefined(RecordType)) - { - writer.WritePropertyName("recordType"u8); - writer.WriteStringValue(RecordType.Value.ToString()); - } - writer.WriteEndObject(); } - TrafficManagerProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerProfileData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerProfileData(document.RootElement, options); } - internal static TrafficManagerProfileData DeserializeTrafficManagerProfileData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerProfileData DeserializeTrafficManagerProfileData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IDictionary tags = default; - AzureLocation? location = default; ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - TrafficManagerProfileStatus? profileStatus = default; - TrafficRoutingMethod? trafficRoutingMethod = default; - TrafficManagerDnsConfig dnsConfig = default; - TrafficManagerMonitorConfig monitorConfig = default; - IList endpoints = default; - TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus = default; - IList allowedEndpointRecordTypes = default; - long? maxReturn = default; - TrafficManagerProfileRecordType? recordType = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation? location = default; + ProfileProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) - { - dictionary.Add(property0.Name, property0.Value.GetString()); - } - tags = dictionary; + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("tags"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("location"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("profileStatus"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - profileStatus = new TrafficManagerProfileStatus(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("trafficRoutingMethod"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trafficRoutingMethod = new TrafficRoutingMethod(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("dnsConfig"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dnsConfig = TrafficManagerDnsConfig.DeserializeTrafficManagerDnsConfig(property0.Value, options); - continue; - } - if (property0.NameEquals("monitorConfig"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - monitorConfig = TrafficManagerMonitorConfig.DeserializeTrafficManagerMonitorConfig(property0.Value, options); - continue; - } - if (property0.NameEquals("endpoints"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(TrafficManagerEndpointData.DeserializeTrafficManagerEndpointData(item, options)); - } - endpoints = array; - continue; - } - if (property0.NameEquals("trafficViewEnrollmentStatus"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - trafficViewEnrollmentStatus = new TrafficViewEnrollmentStatus(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("allowedEndpointRecordTypes"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(new AllowedEndpointRecordType(item.GetString())); - } - allowedEndpointRecordTypes = array; - continue; - } - if (property0.NameEquals("maxReturn"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - maxReturn = null; - continue; - } - maxReturn = property0.Value.GetInt64(); - continue; - } - if (property0.NameEquals("recordType"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - recordType = new TrafficManagerProfileRecordType(property0.Value.GetString()); - continue; - } - } + properties = ProfileProperties.DeserializeProfileProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new TrafficManagerProfileData( id, name, - type, - serializedAdditionalRawData, + resourceType, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - profileStatus, - trafficRoutingMethod, - dnsConfig, - monitorConfig, - endpoints ?? new ChangeTrackingList(), - trafficViewEnrollmentStatus, - allowedEndpointRecordTypes ?? new ChangeTrackingList(), - maxReturn, - recordType); + properties); } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerProfileData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerProfileData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerProfileData)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.cs index 87665e551afe..961fbc610836 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileData.cs @@ -12,65 +12,156 @@ namespace Azure.ResourceManager.TrafficManager { - /// - /// A class representing the TrafficManagerProfile data model. - /// Class representing a Traffic Manager profile. - /// + /// Class representing a Traffic Manager profile. public partial class TrafficManagerProfileData : TrafficManagerTrackedResourceData { /// Initializes a new instance of . public TrafficManagerProfileData() { - Endpoints = new ChangeTrackingList(); - AllowedEndpointRecordTypes = new ChangeTrackingList(); } /// Initializes a new instance of . /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// Resource tags. /// The Azure Region where the resource lives. - /// The status of the Traffic Manager profile. - /// The traffic routing method of the Traffic Manager profile. - /// The DNS settings of the Traffic Manager profile. - /// The endpoint monitoring settings of the Traffic Manager profile. - /// The list of endpoints in the Traffic Manager profile. - /// Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase the cost of the Traffic Manage profile. - /// The list of allowed endpoint record types. - /// Maximum number of endpoints to be returned for MultiValue routing type. - /// When record type is set, a traffic manager profile will allow only endpoints that match this type. - internal TrafficManagerProfileData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, IDictionary tags, AzureLocation? location, TrafficManagerProfileStatus? profileStatus, TrafficRoutingMethod? trafficRoutingMethod, TrafficManagerDnsConfig dnsConfig, TrafficManagerMonitorConfig monitorConfig, IList endpoints, TrafficViewEnrollmentStatus? trafficViewEnrollmentStatus, IList allowedEndpointRecordTypes, long? maxReturn, TrafficManagerProfileRecordType? recordType) : base(id, name, resourceType, serializedAdditionalRawData, tags, location) + /// The properties of the Traffic Manager profile. + internal TrafficManagerProfileData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation? location, ProfileProperties properties) : base(id, name, resourceType, additionalBinaryDataProperties, tags, location) { - ProfileStatus = profileStatus; - TrafficRoutingMethod = trafficRoutingMethod; - DnsConfig = dnsConfig; - MonitorConfig = monitorConfig; - Endpoints = endpoints; - TrafficViewEnrollmentStatus = trafficViewEnrollmentStatus; - AllowedEndpointRecordTypes = allowedEndpointRecordTypes; - MaxReturn = maxReturn; - RecordType = recordType; + Properties = properties; } + /// The properties of the Traffic Manager profile. + internal ProfileProperties Properties { get; set; } + /// The status of the Traffic Manager profile. - public TrafficManagerProfileStatus? ProfileStatus { get; set; } + public TrafficManagerProfileStatus? ProfileStatus + { + get + { + return Properties is null ? default : Properties.ProfileStatus; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.ProfileStatus = value.Value; + } + } + /// The traffic routing method of the Traffic Manager profile. - public TrafficRoutingMethod? TrafficRoutingMethod { get; set; } + public TrafficRoutingMethod? TrafficRoutingMethod + { + get + { + return Properties is null ? default : Properties.TrafficRoutingMethod; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.TrafficRoutingMethod = value.Value; + } + } + /// The DNS settings of the Traffic Manager profile. - public TrafficManagerDnsConfig DnsConfig { get; set; } + public TrafficManagerDnsConfig DnsConfig + { + get + { + return Properties is null ? default : Properties.DnsConfig; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.DnsConfig = value; + } + } + /// The endpoint monitoring settings of the Traffic Manager profile. - public TrafficManagerMonitorConfig MonitorConfig { get; set; } + public TrafficManagerMonitorConfig MonitorConfig + { + get + { + return Properties is null ? default : Properties.MonitorConfig; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.MonitorConfig = value; + } + } + /// The list of endpoints in the Traffic Manager profile. - public IList Endpoints { get; } + public IList Endpoints + { + get + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + return Properties.Endpoints; + } + } + /// Indicates whether Traffic View is 'Enabled' or 'Disabled' for the Traffic Manager profile. Null, indicates 'Disabled'. Enabling this feature will increase the cost of the Traffic Manage profile. - public TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus { get; set; } + public TrafficViewEnrollmentStatus? TrafficViewEnrollmentStatus + { + get + { + return Properties is null ? default : Properties.TrafficViewEnrollmentStatus; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.TrafficViewEnrollmentStatus = value.Value; + } + } + /// The list of allowed endpoint record types. - public IList AllowedEndpointRecordTypes { get; } + public IList AllowedEndpointRecordTypes + { + get + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + return Properties.AllowedEndpointRecordTypes; + } + } + /// Maximum number of endpoints to be returned for MultiValue routing type. - public long? MaxReturn { get; set; } - /// When record type is set, a traffic manager profile will allow only endpoints that match this type. - public TrafficManagerProfileRecordType? RecordType { get; set; } + public long? MaxReturn + { + get + { + return Properties is null ? default : Properties.MaxReturn; + } + set + { + if (Properties is null) + { + Properties = new ProfileProperties(); + } + Properties.MaxReturn = value.Value; + } + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.Serialization.cs index 60c6d3e50574..9c55178dcac6 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.TrafficManager { + /// public partial class TrafficManagerProfileResource : IJsonModel { - private static TrafficManagerProfileData s_dataDeserializationInstance; - private static TrafficManagerProfileData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficManagerProfileData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - TrafficManagerProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TrafficManagerProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerTrafficManagerContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficManagerProfileData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerTrafficManagerContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.cs index 44bc035b0a62..ce7712babd3e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerProfileResource.cs @@ -7,47 +7,37 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { /// - /// A Class representing a TrafficManagerProfile along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetTrafficManagerProfileResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficManagerProfile method. + /// A class representing a TrafficManagerProfile along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetTrafficManagerProfiles method. /// public partial class TrafficManagerProfileResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The profileName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficManagerProfileProfilesClientDiagnostics; - private readonly ProfilesRestOperations _trafficManagerProfileProfilesRestClient; + private readonly ClientDiagnostics _profilesClientDiagnostics; + private readonly Profiles _profilesRestClient; private readonly TrafficManagerProfileData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Network/trafficmanagerprofiles"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerProfileResource for mocking. protected TrafficManagerProfileResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal TrafficManagerProfileResource(ArmClient client, TrafficManagerProfileData data) : this(client, data.Id) @@ -56,211 +46,92 @@ internal TrafficManagerProfileResource(ArmClient client, TrafficManagerProfileDa _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal TrafficManagerProfileResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerProfileProfilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficManagerProfileProfilesApiVersion); - _trafficManagerProfileProfilesRestClient = new ProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerProfileProfilesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficManagerProfileApiVersion); + _profilesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); + _profilesRestClient = new Profiles(_profilesClientDiagnostics, Pipeline, Endpoint, trafficManagerProfileApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual TrafficManagerProfileData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// Gets a collection of TrafficManagerEndpointResources in the TrafficManagerProfile. - /// An object representing collection of TrafficManagerEndpointResources and their operations over a TrafficManagerEndpointResource. - public virtual TrafficManagerEndpointCollection GetTrafficManagerEndpoints() - { - return GetCachedClient(client => new TrafficManagerEndpointCollection(client, Id)); - } - - /// - /// Gets a Traffic Manager endpoint. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetTrafficManagerEndpointAsync(string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - return await GetTrafficManagerEndpoints().GetAsync(endpointType, endpointName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Gets a Traffic Manager endpoint. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName} - /// - /// - /// Operation Id - /// Endpoints_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The type of the Traffic Manager endpoint. Only AzureEndpoints, ExternalEndpoints and NestedEndpoints are allowed here. - /// The name of the Traffic Manager endpoint. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetTrafficManagerEndpoint(string endpointType, string endpointName, CancellationToken cancellationToken = default) - { - return GetTrafficManagerEndpoints().Get(endpointType, endpointName, cancellationToken); - } - - /// Gets a collection of TrafficManagerHeatMapResources in the TrafficManagerProfile. - /// An object representing collection of TrafficManagerHeatMapResources and their operations over a TrafficManagerHeatMapResource. - public virtual TrafficManagerHeatMapCollection GetTrafficManagerHeatMaps() - { - return GetCachedClient(client => new TrafficManagerHeatMapCollection(client, Id)); - } - - /// - /// Gets latest heatmap for Traffic Manager profile. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The type of HeatMap for the Traffic Manager profile. - /// The top left latitude,longitude pair of the rectangular viewport to query for. - /// The bottom right latitude,longitude pair of the rectangular viewport to query for. - /// The cancellation token to use. - [ForwardsClientCalls] - public virtual async Task> GetTrafficManagerHeatMapAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The profileName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string profileName) { - return await GetTrafficManagerHeatMaps().GetAsync(heatMapType, topLeft, botRight, cancellationToken).ConfigureAwait(false); + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}"; + return new ResourceIdentifier(resourceId); } - /// - /// Gets latest heatmap for Traffic Manager profile. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/heatMaps/{heatMapType} - /// - /// - /// Operation Id - /// HeatMap_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The type of HeatMap for the Traffic Manager profile. - /// The top left latitude,longitude pair of the rectangular viewport to query for. - /// The bottom right latitude,longitude pair of the rectangular viewport to query for. - /// The cancellation token to use. - [ForwardsClientCalls] - public virtual Response GetTrafficManagerHeatMap(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = null, IEnumerable botRight = null, CancellationToken cancellationToken = default) + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) { - return GetTrafficManagerHeatMaps().Get(heatMapType, topLeft, botRight, cancellationToken); + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Get + /// Operation Id. + /// Profiles_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Get"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Get"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -274,33 +145,41 @@ public virtual async Task> GetAsync(Canc /// Gets a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Get + /// Operation Id. + /// Profiles_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Get"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Get"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -310,112 +189,24 @@ public virtual Response Get(CancellationToken can } } - /// - /// Deletes a Traffic Manager profile. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Delete - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Delete"); - scope.Start(); - try - { - var response = await _trafficManagerProfileProfilesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerProfileProfilesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Deletes a Traffic Manager profile. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Delete - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) - { - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Delete"); - scope.Start(); - try - { - var response = _trafficManagerProfileProfilesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var uri = _trafficManagerProfileProfilesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - /// /// Update a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Update + /// Operation Id. + /// Profiles_Update. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -426,11 +217,21 @@ public virtual async Task> UpdateAsync(T { Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Update"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Update"); scope.Start(); try { - var response = await _trafficManagerProfileProfilesRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, TrafficManagerProfileData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -444,20 +245,20 @@ public virtual async Task> UpdateAsync(T /// Update a Traffic Manager profile. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}. /// /// - /// Operation Id - /// Profiles_Update + /// Operation Id. + /// Profiles_Update. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -468,11 +269,21 @@ public virtual Response Update(TrafficManagerProf { Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Update"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.Update"); scope.Start(); try { - var response = _trafficManagerProfileProfilesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, TrafficManagerProfileData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -482,27 +293,7 @@ public virtual Response Update(TrafficManagerProf } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -512,29 +303,35 @@ public virtual async Task> AddTagAsync(s Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.AddTag"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficManagerProfileData(); - foreach (var tag in current.Tags) + TrafficManagerProfileData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -544,27 +341,7 @@ public virtual async Task> AddTagAsync(s } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -574,29 +351,35 @@ public virtual Response AddTag(string key, string Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.AddTag"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficManagerProfileData(); - foreach (var tag in current.Tags) + TrafficManagerProfileData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -606,54 +389,40 @@ public virtual Response AddTag(string key, string } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.SetTags"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficManagerProfileData(); + TrafficManagerProfileData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -663,54 +432,40 @@ public virtual async Task> SetTagsAsync( } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.SetTags"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficManagerProfileData(); + TrafficManagerProfileData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); patch.Tags.ReplaceWith(tags); - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -720,27 +475,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -748,29 +483,35 @@ public virtual async Task> RemoveTagAsyn { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.RemoveTag"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _trafficManagerProfileProfilesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficManagerProfileData(); - foreach (var tag in current.Tags) + TrafficManagerProfileData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); - return result; + Response result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -780,27 +521,7 @@ public virtual async Task> RemoveTagAsyn } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName} - /// - /// - /// Operation Id - /// Profiles_Get - /// - /// - /// Default Api Version - /// 2024-04-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -808,29 +529,35 @@ public virtual Response RemoveTag(string key, Can { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficManagerProfileProfilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.RemoveTag"); + using DiagnosticScope scope = _profilesClientDiagnostics.CreateScope("TrafficManagerProfileResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _trafficManagerProfileProfilesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficManagerProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _profilesRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerProfileData.FromResponse(result), result); + return Response.FromValue(new TrafficManagerProfileResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficManagerProfileData(); - foreach (var tag in current.Tags) + TrafficManagerProfileData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficManagerProfileData patch = new TrafficManagerProfileData(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(patch, cancellationToken: cancellationToken); - return result; + Response result = Update(patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); } } catch (Exception e) @@ -839,5 +566,69 @@ public virtual Response RemoveTag(string key, Can throw; } } + + /// Gets a collection of TrafficManagerEndpoints in the . + /// An object representing collection of TrafficManagerEndpoints and their operations over a TrafficManagerEndpointResource. + public virtual TrafficManagerEndpointCollection GetTrafficManagerEndpoints() + { + return GetCachedClient(client => new TrafficManagerEndpointCollection(client, Id)); + } + + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrafficManagerEndpointAsync(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); + + return await GetTrafficManagerEndpoints().GetAsync(endpointType, endpointName, cancellationToken).ConfigureAwait(false); + } + + /// Gets a Traffic Manager endpoint. + /// The type of the Traffic Manager endpoint. + /// The name of the Traffic Manager endpoint. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrafficManagerEndpoint(TrafficManagerEndpointType endpointType, string endpointName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); + + return GetTrafficManagerEndpoints().Get(endpointType, endpointName, cancellationToken); + } + + /// Gets a collection of TrafficManagerHeatMaps in the . + /// An object representing collection of TrafficManagerHeatMaps and their operations over a TrafficManagerHeatMapResource. + public virtual TrafficManagerHeatMapCollection GetTrafficManagerHeatMaps() + { + return GetCachedClient(client => new TrafficManagerHeatMapCollection(client, Id)); + } + + /// Gets latest heatmap for Traffic Manager profile. + /// The type of the heatmap. + /// The top left latitude,longitude pair of the rectangular viewport to query for. + /// The bottom right latitude,longitude pair of the rectangular viewport to query for. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual async Task> GetTrafficManagerHeatMapAsync(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) + { + return await GetTrafficManagerHeatMaps().GetAsync(heatMapType, topLeft, botRight, cancellationToken).ConfigureAwait(false); + } + + /// Gets latest heatmap for Traffic Manager profile. + /// The type of the heatmap. + /// The top left latitude,longitude pair of the rectangular viewport to query for. + /// The bottom right latitude,longitude pair of the rectangular viewport to query for. + /// The cancellation token to use. + [ForwardsClientCalls] + public virtual Response GetTrafficManagerHeatMap(TrafficManagerHeatMapType heatMapType, IEnumerable topLeft = default, IEnumerable botRight = default, CancellationToken cancellationToken = default) + { + return GetTrafficManagerHeatMaps().Get(heatMapType, topLeft, botRight, cancellationToken); + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricCollection.cs new file mode 100644 index 000000000000..178443cf0f1f --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricCollection.cs @@ -0,0 +1,456 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.TrafficManager +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTrafficManagerUserMetrics method from an instance of . + /// + public partial class TrafficManagerUserMetricCollection : ArmCollection + { + private readonly ClientDiagnostics _trafficManagerUserMetricsKeysClientDiagnostics; + private readonly TrafficManagerUserMetricsKeys _trafficManagerUserMetricsKeysRestClient; + + /// Initializes a new instance of TrafficManagerUserMetricCollection for mocking. + protected TrafficManagerUserMetricCollection() + { + } + + /// Initializes a new instance of class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TrafficManagerUserMetricCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + TryGetApiVersion(TrafficManagerUserMetricsResource.ResourceType, out string trafficManagerUserMetricApiVersion); + _trafficManagerUserMetricsKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", TrafficManagerUserMetricsResource.ResourceType.Namespace, Diagnostics); + _trafficManagerUserMetricsKeysRestClient = new TrafficManagerUserMetricsKeys(_trafficManagerUserMetricsKeysClientDiagnostics, Pipeline, Endpoint, trafficManagerUserMetricApiVersion ?? "2022-04-01"); + ValidateResourceId(id); + } + + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != SubscriptionResource.ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, SubscriptionResource.ResourceType), id); + } + } + + /// + /// Create or update a subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create or update a subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_CreateOrUpdate. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.CreateOrUpdate"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletion(cancellationToken); + } + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the subscription-level key used for Real User Metrics collection. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.Get"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> ExistsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerUserMetricData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual Response Exists(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.Exists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerUserMetricData)null, result); + break; + default: + throw new RequestFailedException(result); + } + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetIfExistsAsync(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerUserMetricData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. + /// + /// + /// Operation Id. + /// UserMetricsModels_Get. + /// + /// + /// Default Api Version. + /// 2022-04-01. + /// + /// + /// + /// The cancellation token to use. + public virtual NullableResponse GetIfExists(CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricCollection.GetIfExists"); + scope.Start(); + try + { + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficManagerUserMetricData)null, result); + break; + default: + throw new RequestFailedException(result); + } + if (response.Value == null) + { + return new NoValueResponse(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.Serialization.cs index 665a07df66e4..945a2222d87d 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.Serialization.cs @@ -9,14 +9,64 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; +using Azure.ResourceManager.TrafficManager.Models; namespace Azure.ResourceManager.TrafficManager { - public partial class TrafficManagerUserMetricData : IUtf8JsonSerializable, IJsonModel + /// Class representing Traffic Manager User Metrics. + public partial class TrafficManagerUserMetricData : TrafficManagerProxyResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// The data to parse. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrafficManagerUserMetricData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support writing '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The data to parse. + /// The client options for reading and writing models. + TrafficManagerUserMetricData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficManagerUserMetricData)PersistableModelCreateCore(data, options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficManagerUserMetricData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficManagerUserMetricData(document.RootElement, ModelSerializationExtensions.WireOptions); + } + + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,129 +78,89 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Key)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("key"u8); - writer.WriteStringValue(Key); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - TrafficManagerUserMetricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficManagerUserMetricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficManagerUserMetricData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TrafficManagerResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficManagerUserMetricData(document.RootElement, options); } - internal static TrafficManagerUserMetricData DeserializeTrafficManagerUserMetricData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficManagerUserMetricData DeserializeTrafficManagerUserMetricData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier id = default; string name = default; - ResourceType? type = default; - string key = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + ResourceType? resourceType = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + UserMetricsProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - id = new ResourceIdentifier(property.Value.GetString()); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString(); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - type = new ResourceType(property.Value.GetString()); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("key"u8)) - { - key = property0.Value.GetString(); - continue; - } - } + properties = UserMetricsProperties.DeserializeUserMetricsProperties(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new TrafficManagerUserMetricData(id, name, type, serializedAdditionalRawData, key); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options, AzureResourceManagerTrafficManagerContext.Default); - default: - throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support writing '{options.Format}' format."); - } - } - - TrafficManagerUserMetricData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); - return DeserializeTrafficManagerUserMetricData(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(TrafficManagerUserMetricData)} does not support reading '{options.Format}' format."); - } + return new TrafficManagerUserMetricData(id, name, resourceType, additionalBinaryDataProperties, properties); } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.cs index 1fe16c30f646..c9c24a6535d0 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricData.cs @@ -12,10 +12,7 @@ namespace Azure.ResourceManager.TrafficManager { - /// - /// A class representing the TrafficManagerUserMetric data model. - /// Class representing Traffic Manager User Metrics. - /// + /// Class representing Traffic Manager User Metrics. public partial class TrafficManagerUserMetricData : TrafficManagerProxyResourceData { /// Initializes a new instance of . @@ -27,14 +24,31 @@ public TrafficManagerUserMetricData() /// Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficManagerProfiles/{resourceName}. /// The name of the resource. /// The type of the resource. Ex- Microsoft.Network/trafficManagerProfiles. - /// Keeps track of any properties unknown to the library. - /// The key returned by the User Metrics operation. - internal TrafficManagerUserMetricData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary serializedAdditionalRawData, string key) : base(id, name, resourceType, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + /// The properties of the Traffic Manager User Metrics. + internal TrafficManagerUserMetricData(ResourceIdentifier id, string name, ResourceType? resourceType, IDictionary additionalBinaryDataProperties, UserMetricsProperties properties) : base(id, name, resourceType, additionalBinaryDataProperties) { - Key = key; + Properties = properties; } + /// The properties of the Traffic Manager User Metrics. + internal UserMetricsProperties Properties { get; set; } + /// The key returned by the User Metrics operation. - public string Key { get; set; } + public string Key + { + get + { + return Properties is null ? default : Properties.Key; + } + set + { + if (Properties is null) + { + Properties = new UserMetricsProperties(); + } + Properties.Key = value; + } + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.Serialization.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.Serialization.cs index 0f5334bff3b7..76c64f9a5bff 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.Serialization.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.TrafficManager { + /// public partial class TrafficManagerUserMetricsResource : IJsonModel { - private static TrafficManagerUserMetricData s_dataDeserializationInstance; - private static TrafficManagerUserMetricData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficManagerUserMetricData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - TrafficManagerUserMetricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + TrafficManagerUserMetricData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerTrafficManagerContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficManagerUserMetricData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerTrafficManagerContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.cs index 5151d5bb61c1..2dc58d4dc9c8 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/Generated/TrafficManagerUserMetricsResource.cs @@ -6,36 +6,36 @@ #nullable disable using System; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.TrafficManager { /// - /// A Class representing a TrafficManagerUserMetrics along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetTrafficManagerUserMetricsResource method. + /// A class representing a TrafficManagerUserMetric along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. /// Otherwise you can get one from its parent resource using the GetTrafficManagerUserMetrics method. /// public partial class TrafficManagerUserMetricsResource : ArmResource { - private readonly ClientDiagnostics _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics; - private readonly TrafficManagerUserMetricsKeysRestOperations _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient; + private readonly ClientDiagnostics _trafficManagerUserMetricsKeysClientDiagnostics; + private readonly TrafficManagerUserMetricsKeys _trafficManagerUserMetricsKeysRestClient; private readonly TrafficManagerUserMetricData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.Network/trafficManagerUserMetricsKeys"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficManagerUserMetricsResource for mocking. protected TrafficManagerUserMetricsResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal TrafficManagerUserMetricsResource(ArmClient client, TrafficManagerUserMetricData data) : this(client, data.Id) @@ -44,76 +44,91 @@ internal TrafficManagerUserMetricsResource(ArmClient client, TrafficManagerUserM _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal TrafficManagerUserMetricsResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficManagerUserMetricsTrafficManagerUserMetricsKeysApiVersion); - _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient = new TrafficManagerUserMetricsKeysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficManagerUserMetricsTrafficManagerUserMetricsKeysApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficManagerUserMetricApiVersion); + _trafficManagerUserMetricsKeysClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.TrafficManager", ResourceType.Namespace, Diagnostics); + _trafficManagerUserMetricsKeysRestClient = new TrafficManagerUserMetricsKeys(_trafficManagerUserMetricsKeysClientDiagnostics, Pipeline, Endpoint, trafficManagerUserMetricApiVersion ?? "2022-04-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual TrafficManagerUserMetricData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId) + { + string resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// - /// Delete a subscription-level key used for Real User Metrics collection. + /// Get the subscription-level key used for Real User Metrics collection. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. /// /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_Delete + /// Operation Id. + /// UserMetricsModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Delete"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Get"); scope.Start(); try { - var response = await _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.DeleteAsync(Id.SubscriptionId, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateDeleteRequestUri(Id.SubscriptionId); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -123,41 +138,45 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a subscription-level key used for Real User Metrics collection. + /// Get the subscription-level key used for Real User Metrics collection. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. /// /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_Delete + /// Operation Id. + /// UserMetricsModels_Get. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Delete"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Get"); scope.Start(); try { - var response = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.Delete(Id.SubscriptionId, cancellationToken); - var uri = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateDeleteRequestUri(Id.SubscriptionId); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(response, rehydrationToken); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateGetRequest(Id.SubscriptionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -167,40 +186,48 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Create or update a subscription-level key used for Real User Metrics collection. + /// Update a TrafficManagerUserMetric. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. /// /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_CreateOrUpdate + /// Operation Id. + /// UserMetricsModels_CreateOrUpdate. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual async Task> UpdateAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.CreateOrUpdate"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Update"); scope.Start(); try { - var response = await _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, cancellationToken).ConfigureAwait(false); - var uri = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -211,40 +238,48 @@ public virtual async Task> Creat } /// - /// Create or update a subscription-level key used for Real User Metrics collection. + /// Update a TrafficManagerUserMetric. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default. /// /// - /// Operation Id - /// TrafficManagerUserMetricsKeys_CreateOrUpdate + /// Operation Id. + /// UserMetricsModels_CreateOrUpdate. /// /// - /// Default Api Version - /// 2024-04-01-preview + /// Default Api Version. + /// 2022-04-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. /// The cancellation token to use. - public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, CancellationToken cancellationToken = default) + public virtual ArmOperation Update(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.CreateOrUpdate"); + using DiagnosticScope scope = _trafficManagerUserMetricsKeysClientDiagnostics.CreateScope("TrafficManagerUserMetricsResource.Update"); scope.Start(); try { - var response = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateOrUpdate(Id.SubscriptionId, cancellationToken); - var uri = _trafficManagerUserMetricsTrafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficManagerUserMetricsKeysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficManagerUserMetricData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + TrafficManagerArmOperation operation = new TrafficManagerArmOperation(Response.FromValue(new TrafficManagerUserMetricsResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/autorest.md b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/autorest.md.bak similarity index 100% rename from sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/autorest.md rename to sdk/trafficmanager/Azure.ResourceManager.TrafficManager/src/autorest.md.bak diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Azure.ResourceManager.TrafficManager.Tests.csproj b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Azure.ResourceManager.TrafficManager.Tests.csproj index 6188455e5c0d..0dcbfe3ef93b 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Azure.ResourceManager.TrafficManager.Tests.csproj +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Azure.ResourceManager.TrafficManager.Tests.csproj @@ -6,4 +6,7 @@ + + + diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs deleted file mode 100644 index 257237eeaf4e..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_SubscriptionResourceExtensions - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameAvailablePOST21() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/NameAvailabilityV2Test_NameAvailable-POST-example-21.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent - { - Name = "azsmnet5403", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameNotAvailablePOST23() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/NameAvailabilityV2Test_NameNotAvailable-POST-example-23.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent - { - Name = "azsmnet4696", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTrafficManagerProfiles_ListBySubscription() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-BySubscription.json - // this example is just showing the usage of "Profiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (TrafficManagerProfileResource item in subscriptionResource.GetTrafficManagerProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TenantResourceExtensions.cs deleted file mode 100644 index fc9cbce81aa1..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TenantResourceExtensions.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TenantResourceExtensions - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameAvailablePOST21() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/NameAvailabilityTest_NameAvailable-POST-example-21.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent - { - Name = "azsmnet5403", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameNotAvailablePOST23() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/NameAvailabilityTest_NameNotAvailable-POST-example-23.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent - { - Name = "azsmnet4696", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs deleted file mode 100644 index f0ae3dc217c5..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs +++ /dev/null @@ -1,585 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Net; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerEndpointCollection - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithAlwaysServe() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PUT-External-WithAlwaysServe.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - AlwaysServe = TrafficManagerEndpointAlwaysServeStatus.Enabled, - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithCustomHeaders() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PUT-External-WithCustomHeaders.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - CustomHeaders = {new TrafficManagerEndpointCustomHeaderInfo -{ -Name = "header-1", -Value = "value-1", -}, new TrafficManagerEndpointCustomHeaderInfo -{ -Name = "header-2", -Value = "value-2", -}}, - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithGeoMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PUT-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - GeoMapping = { "GEO-AS", "GEO-AF" }, - Name = "My external endpoint", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithLocation() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PUT-External-WithLocation.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithSubnetMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PUT-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - Subnets = {new TrafficManagerEndpointSubnetInfo -{ -First = IPAddress.Parse("1.2.3.0"), -Scope = 24, -}, new TrafficManagerEndpointSubnetInfo -{ -First = IPAddress.Parse("25.26.27.28"), -Last = IPAddress.Parse("29.30.31.32"), -}}, - Name = "My external endpoint", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithGeoMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithLocation() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithSubnetMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithGeoMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - bool result = await collection.ExistsAsync(endpointType, endpointName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithLocation() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - bool result = await collection.ExistsAsync(endpointType, endpointName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithSubnetMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - bool result = await collection.ExistsAsync(endpointType, endpointName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithGeoMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithLocation() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithSubnetMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerEndpointResource - TrafficManagerEndpointCollection collection = trafficManagerProfile.GetTrafficManagerEndpoints(); - - // invoke the operation - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointResource.cs deleted file mode 100644 index 59f438aae867..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerEndpointResource.cs +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerEndpointResource - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithGeoMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - TrafficManagerEndpointResource result = await trafficManagerEndpoint.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithLocation() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - TrafficManagerEndpointResource result = await trafficManagerEndpoint.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithSubnetMapping() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; - string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - TrafficManagerEndpointResource result = await trafficManagerEndpoint.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_EndpointDELETEExternal() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-DELETE-External.json - // this example is just showing the usage of "Endpoints_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - await trafficManagerEndpoint.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_EndpointPATCHExternalTarget() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Endpoint-PATCH-External-Target.json - // this example is just showing the usage of "Endpoints_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - TrafficManagerEndpointData data = new TrafficManagerEndpointData - { - Target = "another.foobar.contoso.com", - Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), - }; - TrafficManagerEndpointResource result = await trafficManagerEndpoint.UpdateAsync(data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerGeographicHierarchyResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerGeographicHierarchyResource.cs deleted file mode 100644 index 0323e25262bd..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerGeographicHierarchyResource.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerGeographicHierarchyResource - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GeographicHierarchyGETDefault() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/GeographicHierarchy-GET-default.json - // this example is just showing the usage of "GeographicHierarchies_GetDefault" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerGeographicHierarchyResource created on azure - // for more information of creating TrafficManagerGeographicHierarchyResource, please refer to the document of TrafficManagerGeographicHierarchyResource - ResourceIdentifier trafficManagerGeographicHierarchyResourceId = TrafficManagerGeographicHierarchyResource.CreateResourceIdentifier(); - TrafficManagerGeographicHierarchyResource trafficManagerGeographicHierarchy = client.GetTrafficManagerGeographicHierarchyResource(trafficManagerGeographicHierarchyResourceId); - - // invoke the operation - TrafficManagerGeographicHierarchyResource result = await trafficManagerGeographicHierarchy.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerGeographicHierarchyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs deleted file mode 100644 index ef4257a82307..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerHeatMapCollection - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGET() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithNullValues() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-Null-Values.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithTopLeftBotRight() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] { 10, 50.001 }; - IEnumerable botRight = new double[] { -50.001, 80 }; - TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType, topLeft: topLeft, botRight: botRight); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_HeatMapGET() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - bool result = await collection.ExistsAsync(heatMapType); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_HeatMapGETWithNullValues() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-Null-Values.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - bool result = await collection.ExistsAsync(heatMapType); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_HeatMapGETWithTopLeftBotRight() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] { 10, 50.001 }; - IEnumerable botRight = new double[] { -50.001, 80 }; - bool result = await collection.ExistsAsync(heatMapType, topLeft: topLeft, botRight: botRight); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HeatMapGET() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - NullableResponse response = await collection.GetIfExistsAsync(heatMapType); - TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HeatMapGETWithNullValues() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-Null-Values.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - NullableResponse response = await collection.GetIfExistsAsync(heatMapType); - TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HeatMapGETWithTopLeftBotRight() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // get the collection of this TrafficManagerHeatMapResource - TrafficManagerHeatMapCollection collection = trafficManagerProfile.GetTrafficManagerHeatMaps(); - - // invoke the operation - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] { 10, 50.001 }; - IEnumerable botRight = new double[] { -50.001, 80 }; - NullableResponse response = await collection.GetIfExistsAsync(heatMapType, topLeft: topLeft, botRight: botRight); - TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs deleted file mode 100644 index fc8081dedde4..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerHeatMapResource - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGET() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerHeatMapResource created on azure - // for more information of creating TrafficManagerHeatMapResource, please refer to the document of TrafficManagerHeatMapResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - ResourceIdentifier trafficManagerHeatMapResourceId = TrafficManagerHeatMapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, heatMapType); - TrafficManagerHeatMapResource trafficManagerHeatMap = client.GetTrafficManagerHeatMapResource(trafficManagerHeatMapResourceId); - - // invoke the operation - TrafficManagerHeatMapResource result = await trafficManagerHeatMap.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithNullValues() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-Null-Values.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerHeatMapResource created on azure - // for more information of creating TrafficManagerHeatMapResource, please refer to the document of TrafficManagerHeatMapResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - ResourceIdentifier trafficManagerHeatMapResourceId = TrafficManagerHeatMapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, heatMapType); - TrafficManagerHeatMapResource trafficManagerHeatMap = client.GetTrafficManagerHeatMapResource(trafficManagerHeatMapResourceId); - - // invoke the operation - TrafficManagerHeatMapResource result = await trafficManagerHeatMap.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithTopLeftBotRight() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json - // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerHeatMapResource created on azure - // for more information of creating TrafficManagerHeatMapResource, please refer to the document of TrafficManagerHeatMapResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - ResourceIdentifier trafficManagerHeatMapResourceId = TrafficManagerHeatMapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, heatMapType); - TrafficManagerHeatMapResource trafficManagerHeatMap = client.GetTrafficManagerHeatMapResource(trafficManagerHeatMapResourceId); - - // invoke the operation - IEnumerable topLeft = new double[] { 10, 50.001 }; - IEnumerable botRight = new double[] { -50.001, 80 }; - TrafficManagerHeatMapResource result = await trafficManagerHeatMap.GetAsync(topLeft: topLeft, botRight: botRight); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileCollection.cs deleted file mode 100644 index bf75e9a66cb6..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileCollection.cs +++ /dev/null @@ -1,922 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerProfileCollection - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTMultiValue() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-MultiValue.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azsmnet6386"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.MultiValue, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azsmnet6386", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - }, - TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, - MaxReturn = 2L, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTNoEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-NoEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azsmnet6386"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azsmnet6386", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - }, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithAliasing() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-WithAliasing.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = {new TrafficManagerEndpointData -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -}}, - AllowedEndpointRecordTypes = { AllowedEndpointRecordType.DomainName }, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithCustomHeaders() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-WithCustomHeaders.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - CustomHeaders = {new TrafficManagerMonitorConfigCustomHeaderInfo -{ -Name = "header-1", -Value = "value-1", -}, new TrafficManagerMonitorConfigCustomHeaderInfo -{ -Name = "header-2", -Value = "value-2", -}}, - ExpectedStatusCodeRanges = {new ExpectedStatusCodeRangeInfo -{ -Min = 200, -Max = 205, -}, new ExpectedStatusCodeRangeInfo -{ -Min = 400, -Max = 410, -}}, - }, - Endpoints = {new TrafficManagerEndpointData -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -CustomHeaders = {new TrafficManagerEndpointCustomHeaderInfo -{ -Name = "header-2", -Value = "value-2-overridden", -}}, -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -}}, - TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-WithEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = {new TrafficManagerEndpointData -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -}}, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithEndpointsAndRecordType() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-WithEndpointsAndRecordType.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = {new TrafficManagerEndpointData -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -}}, - RecordType = TrafficManagerProfileRecordType.Cname, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithNestedEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PUT-WithNestedEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myresourcegroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "parentprofile"; - TrafficManagerProfileData data = new TrafficManagerProfileData - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Priority, - DnsConfig = new TrafficManagerDnsConfig - { - RelativeName = "parentprofile", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = {new TrafficManagerEndpointData -{ -Target = "firstnestedprofile.tmpreview.watmtest.azure-test.net", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -Weight = 1L, -Priority = 1L, -MinChildEndpoints = 2L, -MinChildEndpointsIPv4 = 1L, -MinChildEndpointsIPv6 = 2L, -Name = "MyFirstNestedEndpoint", -ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), -}, new TrafficManagerEndpointData -{ -Target = "secondnestedprofile.tmpreview.watmtest.azure-test.net", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -Weight = 1L, -Priority = 2L, -MinChildEndpoints = 2L, -MinChildEndpointsIPv4 = 2L, -MinChildEndpointsIPv6 = 1L, -Name = "MySecondNestedEndpoint", -ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), -}}, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithEndpointsAndRecordType() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpointsAndRecordType.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewDisabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewEnabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProfilesByResourceGroup() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-ByResourceGroup.json - // this example is just showing the usage of "Profiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager3640"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation and iterate over the result - await foreach (TrafficManagerProfileResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithEndpointsAndRecordType() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpointsAndRecordType.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithTrafficViewDisabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithTrafficViewEnabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithEndpointsAndRecordType() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpointsAndRecordType.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithTrafficViewDisabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithTrafficViewEnabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileResource.cs deleted file mode 100644 index 2d3e3eada7ed..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerProfileResource.cs +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using Azure.ResourceManager.TrafficManager.Models; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerProfileResource - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithEndpoints() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - TrafficManagerProfileResource result = await trafficManagerProfile.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithEndpointsAndRecordType() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithEndpointsAndRecordType.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - TrafficManagerProfileResource result = await trafficManagerProfile.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewDisabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - TrafficManagerProfileResource result = await trafficManagerProfile.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewEnabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - TrafficManagerProfileResource result = await trafficManagerProfile.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ProfileDELETE() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-DELETE.json - // this example is just showing the usage of "Profiles_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - await trafficManagerProfile.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_ProfilePATCHMonitorConfig() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/Profile-PATCH-MonitorConfig.json - // this example is just showing the usage of "Profiles_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerProfileResource created on azure - // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); - - // invoke the operation - TrafficManagerProfileData data = new TrafficManagerProfileData - { - MonitorConfig = new TrafficManagerMonitorConfig - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 30L, - TimeoutInSeconds = 6L, - ToleratedNumberOfFailures = 4L, - CustomHeaders = {new TrafficManagerMonitorConfigCustomHeaderInfo -{ -Name = "header-1", -Value = "value-1", -}, new TrafficManagerMonitorConfigCustomHeaderInfo -{ -Name = "header-2", -Value = "value-2", -}}, - }, - }; - TrafficManagerProfileResource result = await trafficManagerProfile.UpdateAsync(data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs deleted file mode 100644 index 6587c5177744..000000000000 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading.Tasks; -using Azure.Core; -using Azure.Identity; -using NUnit.Framework; - -namespace Azure.ResourceManager.TrafficManager.Samples -{ - public partial class Sample_TrafficManagerUserMetricsResource - { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_TrafficManagerUserMetricsKeysGET() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/TrafficManagerUserMetricsKeys-GET.json - // this example is just showing the usage of "TrafficManagerUserMetricsKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerUserMetricsResource created on azure - // for more information of creating TrafficManagerUserMetricsResource, please refer to the document of TrafficManagerUserMetricsResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier trafficManagerUserMetricsResourceId = TrafficManagerUserMetricsResource.CreateResourceIdentifier(subscriptionId); - TrafficManagerUserMetricsResource trafficManagerUserMetrics = client.GetTrafficManagerUserMetricsResource(trafficManagerUserMetricsResourceId); - - // invoke the operation - TrafficManagerUserMetricsResource result = await trafficManagerUserMetrics.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerUserMetricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_TrafficManagerUserMetricsKeysDELETE() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/TrafficManagerUserMetricsKeys-DELETE.json - // this example is just showing the usage of "TrafficManagerUserMetricsKeys_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerUserMetricsResource created on azure - // for more information of creating TrafficManagerUserMetricsResource, please refer to the document of TrafficManagerUserMetricsResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier trafficManagerUserMetricsResourceId = TrafficManagerUserMetricsResource.CreateResourceIdentifier(subscriptionId); - TrafficManagerUserMetricsResource trafficManagerUserMetrics = client.GetTrafficManagerUserMetricsResource(trafficManagerUserMetricsResourceId); - - // invoke the operation - await trafficManagerUserMetrics.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TrafficManagerUserMetricsKeysPUT() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/preview/2024-04-01-preview/examples/TrafficManagerUserMetricsKeys-PUT.json - // this example is just showing the usage of "TrafficManagerUserMetricsKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerUserMetricsResource created on azure - // for more information of creating TrafficManagerUserMetricsResource, please refer to the document of TrafficManagerUserMetricsResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier trafficManagerUserMetricsResourceId = TrafficManagerUserMetricsResource.CreateResourceIdentifier(subscriptionId); - TrafficManagerUserMetricsResource trafficManagerUserMetrics = client.GetTrafficManagerUserMetricsResource(trafficManagerUserMetricsResourceId); - - // invoke the operation - ArmOperation lro = await trafficManagerUserMetrics.CreateOrUpdateAsync(WaitUntil.Completed); - TrafficManagerUserMetricsResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerUserMetricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } -} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/EndpointTests.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/EndpointTests.cs index c73d9809f162..e0f39e316045 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/EndpointTests.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/EndpointTests.cs @@ -16,20 +16,17 @@ public sealed class EndpointTests : ProfileTestBase public EndpointTests(bool isAsync) : base(isAsync) //, RecordedTestMode.Record) { } - private TrafficManagerEndpointResource DefaultEndpointResource => - new TrafficManagerEndpointResource( - Client, - TrafficManagerEndpointResource.CreateResourceIdentifier( - _subscription.Data.SubscriptionId, - _resourceGroup.Data.Name, - _profileName, - EndpointTypeName, - EndpointName1)); + private async Task GetEndpointCollection() + { + TrafficManagerProfileResource profileResource = await GetDefaultProfile(); + return profileResource.GetTrafficManagerEndpoints(); + } [RecordedTest] public async Task GetTest() { - TrafficManagerEndpointResource endpointResource = await DefaultEndpointResource.GetAsync(); + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); Assert.IsNotNull(endpointResource); Assert.IsTrue(endpointResource.HasData); @@ -46,7 +43,16 @@ public async Task ExistsTest() [RecordedTest] public async Task DeleteTest() { - await DefaultEndpointResource.DeleteAsync(WaitUntil.Completed); + // Verify the endpoint exists + await CheckExists(expected: true); + + // Get the endpoint via collection and delete it + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); + Assert.IsNotNull(endpointResource); + + // Delete the endpoint + await endpointResource.DeleteAsync(WaitUntil.Completed); await CheckExists(expected: false); } @@ -54,11 +60,13 @@ public async Task DeleteTest() [RecordedTest] public async Task UpdateTest() { - TrafficManagerEndpointResource endpointResource = await DefaultEndpointResource.GetAsync(); + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); endpointResource.Data.Target = NewEndpointTarget; - await endpointResource.UpdateAsync(endpointResource.Data); - endpointResource = await DefaultEndpointResource.GetAsync(); + await endpointCollection.CreateOrUpdateAsync(WaitUntil.Completed, EndpointTypeEnum, EndpointName1, endpointResource.Data); + + endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); Assert.IsNotNull(endpointResource); Assert.IsTrue(endpointResource.HasData); @@ -78,13 +86,11 @@ public async Task CreateTest() Weight = NewEndpointWeight }; - TrafficManagerProfileResource profileResource = await GetDefaultProfile(); - - TrafficManagerEndpointCollection endpointCollection = profileResource.GetTrafficManagerEndpoints(); + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); - await endpointCollection.CreateOrUpdateAsync(WaitUntil.Completed, EndpointTypeName, NewEndpointName, newEndpointData); + await endpointCollection.CreateOrUpdateAsync(WaitUntil.Completed, EndpointTypeEnum, NewEndpointName, newEndpointData); - TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeName, NewEndpointName); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, NewEndpointName); Assert.IsNotNull(endpointResource); Assert.IsTrue(endpointResource.HasData); @@ -97,15 +103,14 @@ public async Task CreateTest() [RecordedTest] public async Task UpdateOnCollectionTest() { - TrafficManagerProfileResource profileResource = await GetDefaultProfile(); - TrafficManagerEndpointCollection endpointCollection = profileResource.GetTrafficManagerEndpoints(); + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); - TrafficManagerEndpointResource endpointResource = await DefaultEndpointResource.GetAsync(); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); endpointResource.Data.Target = NewEndpointTarget; - await endpointCollection.CreateOrUpdateAsync(WaitUntil.Completed, EndpointTypeName, endpointResource.Data.Name, endpointResource.Data); + await endpointCollection.CreateOrUpdateAsync(WaitUntil.Completed, EndpointTypeEnum, endpointResource.Data.Name, endpointResource.Data); - endpointResource = await DefaultEndpointResource.GetAsync(); + endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); Assert.AreEqual(NewEndpointTarget, endpointResource.Data.Target); } @@ -113,10 +118,9 @@ public async Task UpdateOnCollectionTest() [RecordedTest] public async Task GetOnCollectionTest() { - TrafficManagerProfileResource profileResource = await GetDefaultProfile(); - TrafficManagerEndpointCollection endpointCollection = profileResource.GetTrafficManagerEndpoints(); + TrafficManagerEndpointCollection endpointCollection = await GetEndpointCollection(); - TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeName, EndpointName1); + TrafficManagerEndpointResource endpointResource = await endpointCollection.GetAsync(EndpointTypeEnum, EndpointName1); Assert.IsNotNull(endpointResource); Assert.IsTrue(endpointResource.HasData); @@ -132,11 +136,11 @@ private async Task CheckExists(bool expected) if (expected) { - Assert.IsTrue(await endpointCollection.ExistsAsync(EndpointTypeName, EndpointName1)); + Assert.IsTrue(await endpointCollection.ExistsAsync(EndpointTypeEnum, EndpointName1)); } else { - Assert.IsFalse(await endpointCollection.ExistsAsync(EndpointTypeName, EndpointName1)); + Assert.IsFalse(await endpointCollection.ExistsAsync(EndpointTypeEnum, EndpointName1)); } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTestBase.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTestBase.cs index 60e884209c8d..9e26b24027c3 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTestBase.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTestBase.cs @@ -16,8 +16,9 @@ public abstract class ProfileTestBase : TrafficManagerManagementTestBase protected internal const string ExpectedValue = "tagValue"; protected internal const string EndpointName1 = "endpoint1"; protected internal const string EndpointName2 = "endpoint2"; - protected internal const string EndpointTypeName = "externalEndpoints"; + protected internal const string EndpointTypeName = "ExternalEndpoints"; protected internal const string EndpointType = "Microsoft.Network/trafficManagerProfiles/" + EndpointTypeName; + protected internal const TrafficManagerEndpointType EndpointTypeEnum = TrafficManagerEndpointType.ExternalEndpoints; protected internal SubscriptionResource _subscription; protected internal TrafficManagerProfileCollection _profileCollection; diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTests.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTests.cs index 4e23554bda4f..009d79cbbfb0 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTests.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/ProfileTests.cs @@ -131,7 +131,7 @@ public async Task GetEndpointTest() { TrafficManagerProfileResource profileResource = await GetDefaultProfile(); - TrafficManagerEndpointResource endpointResource = await profileResource.GetTrafficManagerEndpointAsync("externalEndpoints", EndpointName1); + TrafficManagerEndpointResource endpointResource = await profileResource.GetTrafficManagerEndpointAsync(EndpointTypeEnum, EndpointName1); Assert.IsNotNull(endpointResource); Assert.AreEqual(EndpointName1, endpointResource.Data.Name); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/UserMetricsModelTests.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/UserMetricsModelTests.cs index 3b418fe66096..fad75c9a51b9 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/UserMetricsModelTests.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tests/Scenario/UserMetricsModelTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; @@ -32,7 +32,7 @@ public async Task DeleteTest() { await Create(); - TrafficManagerUserMetricsResource userMetricsModelResource = _subscription.GetTrafficManagerUserMetrics(); + TrafficManagerUserMetricsResource userMetricsModelResource = (await _subscription.GetTrafficManagerUserMetrics().GetAsync()).Value; userMetricsModelResource = await userMetricsModelResource.GetAsync(); Assert.IsNotEmpty(userMetricsModelResource.Data.Key); @@ -61,7 +61,7 @@ public async Task CreateTest() { await Delete(); - TrafficManagerUserMetricsResource userMetricsModelResource = _subscription.GetTrafficManagerUserMetrics(); + TrafficManagerUserMetricsResource userMetricsModelResource = (await _subscription.GetTrafficManagerUserMetrics().GetAsync()).Value; userMetricsModelResource = await userMetricsModelResource.GetAsync(); Assert.IsEmpty(userMetricsModelResource.Data.Key); @@ -75,19 +75,16 @@ public async Task CreateTest() private async Task Delete() { - TrafficManagerUserMetricsResource userMetricsModelResource = _subscription.GetTrafficManagerUserMetrics(); - - userMetricsModelResource = await userMetricsModelResource.GetAsync(); + TrafficManagerUserMetricsResource userMetricsModelResource = (await _subscription.GetTrafficManagerUserMetrics().GetAsync()).Value; await userMetricsModelResource.DeleteAsync(WaitUntil.Completed); } private async Task Create() { - TrafficManagerUserMetricsResource userMetricsModelResource = _subscription.GetTrafficManagerUserMetrics(); - userMetricsModelResource = await userMetricsModelResource.GetAsync(); + TrafficManagerUserMetricsResource userMetrics = _subscription.GetTrafficManagerUserMetrics(); - ArmOperation userMetricsModelResourceOperation = await userMetricsModelResource.CreateOrUpdateAsync(WaitUntil.Completed); + ArmOperation userMetricsModelResourceOperation = await userMetrics.CreateOrUpdateAsync(WaitUntil.Completed); Assert.IsTrue(userMetricsModelResourceOperation.HasCompleted); Assert.IsTrue(userMetricsModelResourceOperation.HasValue); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tsp-location.yaml b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tsp-location.yaml new file mode 100644 index 000000000000..0ca983a19903 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/trafficmanager/resource-manager/Microsoft.Network/TrafficManager +commit: 354fa1adb7ec1ba0ecbbaae403b10a5edeae099d +repo: Azure/azure-rest-api-specs +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"