diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net10.0.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net10.0.cs new file mode 100644 index 000000000000..392e3085c43a --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net10.0.cs @@ -0,0 +1,739 @@ +namespace Azure.ResourceManager.ServiceNetworking +{ + public partial class ApplicationGatewayForContainersSecurityPolicyCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ApplicationGatewayForContainersSecurityPolicyCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string securityPolicyName, Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string securityPolicyName, Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string securityPolicyName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ApplicationGatewayForContainersSecurityPolicyData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? PolicyType { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } + public System.Collections.Generic.IList Rules { get { throw null; } } + public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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 partial class ApplicationGatewayForContainersSecurityPolicyResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ApplicationGatewayForContainersSecurityPolicyResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) { 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; } + 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 RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationCollection` moving forward.")] + public partial class AssociationCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected AssociationCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string associationName, Azure.ResourceManager.ServiceNetworking.AssociationData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string associationName, Azure.ResourceManager.ServiceNetworking.AssociationData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string associationName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationData` moving forward.")] + public partial class AssociationData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AssociationData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.ServiceNetworking.Models.AssociationType? AssociationType { get { throw null; } set { } } + public Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ServiceNetworking.AssociationData 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.ServiceNetworking.AssociationData 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; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationResource` moving forward.")] + public partial class AssociationResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected AssociationResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.AssociationData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) { 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; } + 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 RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.AssociationData 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.ServiceNetworking.AssociationData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.AssociationPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.AssociationPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class AzureResourceManagerServiceNetworkingContext : System.ClientModel.Primitives.ModelReaderWriterContext + { + internal AzureResourceManagerServiceNetworkingContext() { } + public static Azure.ResourceManager.ServiceNetworking.AzureResourceManagerServiceNetworkingContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerFrontendCollection` moving forward.")] + public partial class FrontendCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected FrontendCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string frontendName, Azure.ResourceManager.ServiceNetworking.FrontendData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string frontendName, Azure.ResourceManager.ServiceNetworking.FrontendData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string frontendName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerFrontendData` moving forward.")] + public partial class FrontendData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FrontendData(Azure.Core.AzureLocation location) { } + public string Fqdn { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? ProvisioningState { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ServiceNetworking.FrontendData 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.ServiceNetworking.FrontendData 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; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerFrontendResource` moving forward.")] + public partial class FrontendResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected FrontendResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.FrontendData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) { 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; } + 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 RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.FrontendData 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.ServiceNetworking.FrontendData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.FrontendPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.FrontendPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public static partial class ServiceNetworkingExtensions + { + public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyResource GetApplicationGatewayForContainersSecurityPolicyResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerAssociationResource` moving forward.")] + public static Azure.ResourceManager.ServiceNetworking.AssociationResource GetAssociationResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerFrontendResource` moving forward.")] + public static Azure.ResourceManager.ServiceNetworking.FrontendResource GetFrontendResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.Response GetTrafficController(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationResource GetTrafficControllerAssociationResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static System.Threading.Tasks.Task> GetTrafficControllerAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendResource GetTrafficControllerFrontendResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerResource GetTrafficControllerResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerCollection GetTrafficControllers(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetTrafficControllers(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetTrafficControllersAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class TrafficControllerAssociationCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TrafficControllerAssociationCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string associationName, Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string associationName, Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string associationName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class TrafficControllerAssociationData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerAssociationData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } + public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } + public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerAssociationData 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.ServiceNetworking.TrafficControllerAssociationData 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 partial class TrafficControllerAssociationResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TrafficControllerAssociationResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) { 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; } + 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 RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData 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.ServiceNetworking.TrafficControllerAssociationData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class TrafficControllerCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TrafficControllerCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string trafficControllerName, Azure.ResourceManager.ServiceNetworking.TrafficControllerData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string trafficControllerName, Azure.ResourceManager.ServiceNetworking.TrafficControllerData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string trafficControllerName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class TrafficControllerData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerData(Azure.Core.AzureLocation location) { } + public System.Collections.Generic.IReadOnlyList Associations { get { throw null; } } + public System.Collections.Generic.IReadOnlyList ConfigurationEndpoints { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Frontends { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is now deprecated. Please use `TrafficControllerProvisioningState` moving forward.")] + public Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public System.Collections.Generic.IReadOnlyList SecurityPolicies { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations SecurityPolicyConfigurations { get { throw null; } set { } } + public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? TrafficControllerProvisioningState { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerData 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.ServiceNetworking.TrafficControllerData 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 partial class TrafficControllerFrontendCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TrafficControllerFrontendCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string frontendName, Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string frontendName, Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string frontendName, 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; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class TrafficControllerFrontendData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerFrontendData(Azure.Core.AzureLocation location) { } + public string Fqdn { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations SecurityPolicyConfigurations { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerFrontendData 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.ServiceNetworking.TrafficControllerFrontendData 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 partial class TrafficControllerFrontendResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TrafficControllerFrontendResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) { 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; } + 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 RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData 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.ServiceNetworking.TrafficControllerFrontendData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class TrafficControllerResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TrafficControllerResource() { } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName) { 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; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyCollection GetApplicationGatewayForContainersSecurityPolicies() { throw null; } + public virtual Azure.Response GetApplicationGatewayForContainersSecurityPolicy(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetApplicationGatewayForContainersSecurityPolicyAsync(string securityPolicyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerAssociation` moving forward.")] + public virtual Azure.Response GetAssociation(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerAssociationAsync` moving forward.")] + public virtual System.Threading.Tasks.Task> GetAssociationAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerAssociations` moving forward.")] + public virtual Azure.ResourceManager.ServiceNetworking.AssociationCollection GetAssociations() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerFrontend` moving forward.")] + public virtual Azure.Response GetFrontend(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerFrontendAsync` moving forward.")] + public virtual System.Threading.Tasks.Task> GetFrontendAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerFrontends` moving forward.")] + public virtual Azure.ResourceManager.ServiceNetworking.FrontendCollection GetFrontends() { throw null; } + public virtual Azure.Response GetTrafficControllerAssociation(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficControllerAssociationAsync(string associationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationCollection GetTrafficControllerAssociations() { throw null; } + public virtual Azure.Response GetTrafficControllerFrontend(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficControllerFrontendAsync(string frontendName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendCollection GetTrafficControllerFrontends() { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.ServiceNetworking.TrafficControllerData 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.ServiceNetworking.TrafficControllerData 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.Response Update(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.ServiceNetworking.Mocking +{ + public partial class MockableServiceNetworkingArmClient : Azure.ResourceManager.ArmResource + { + protected MockableServiceNetworkingArmClient() { } + public virtual Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyResource GetApplicationGatewayForContainersSecurityPolicyResource(Azure.Core.ResourceIdentifier id) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerAssociationResource` moving forward.")] + public virtual Azure.ResourceManager.ServiceNetworking.AssociationResource GetAssociationResource(Azure.Core.ResourceIdentifier id) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `GetTrafficControllerFrontendResource` moving forward.")] + public virtual Azure.ResourceManager.ServiceNetworking.FrontendResource GetFrontendResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationResource GetTrafficControllerAssociationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendResource GetTrafficControllerFrontendResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerResource GetTrafficControllerResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableServiceNetworkingResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableServiceNetworkingResourceGroupResource() { } + public virtual Azure.Response GetTrafficController(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTrafficControllerAsync(string trafficControllerName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ServiceNetworking.TrafficControllerCollection GetTrafficControllers() { throw null; } + } + public partial class MockableServiceNetworkingSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableServiceNetworkingSubscriptionResource() { } + public virtual Azure.Pageable GetTrafficControllers(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetTrafficControllersAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + public partial class ApplicationGatewayForContainersSecurityPolicyPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ApplicationGatewayForContainersSecurityPolicyPatch() { } + public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ApplicationGatewayForContainersSecurityPolicyType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ApplicationGatewayForContainersSecurityPolicyType(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType IPAccessRules { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType WAF { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } + public override string ToString() { throw null; } + } + public static partial class ArmServiceNetworkingModelFactory + { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType, Azure.Core.ResourceIdentifier wafPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType = default(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType?), Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?), Azure.Core.ResourceIdentifier wafPolicyId = null, System.Collections.Generic.IEnumerable rules = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch ApplicationGatewayForContainersSecurityPolicyPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties properties = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerAssociationData` moving forward.")] + public static Azure.ResourceManager.ServiceNetworking.AssociationData AssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.AssociationType? associationType, Azure.Core.ResourceIdentifier subnetId, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerFrontedData` moving forward.")] + public static Azure.ResourceManager.ServiceNetworking.FrontendData FrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule ServiceNetworkingIPAccessRule(string name = null, int priority = 0, System.Collections.Generic.IEnumerable sourceAddressPrefixes = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction action = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData TrafficControllerAssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch TrafficControllerAssociationPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, System.Collections.Generic.IEnumerable configurationEndpoints, System.Collections.Generic.IEnumerable frontends, System.Collections.Generic.IEnumerable associations, System.Collections.Generic.IEnumerable securityPolicies, Azure.Core.ResourceIdentifier wafSecurityPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IEnumerable configurationEndpoints = null, System.Collections.Generic.IEnumerable frontends = null, System.Collections.Generic.IEnumerable associations = null, System.Collections.Generic.IEnumerable securityPolicies = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, System.Collections.Generic.IEnumerable configurationEndpoints, System.Collections.Generic.IEnumerable frontends, System.Collections.Generic.IEnumerable associations, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string fqdn = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch TrafficControllerFrontendPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations frontendUpdateSecurityPolicyConfigurations = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch TrafficControllerPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations trafficControllerUpdateSecurityPolicyConfigurations = null) { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationPatch` moving forward.")] + public partial class AssociationPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AssociationPatch() { } + public Azure.ResourceManager.ServiceNetworking.Models.AssociationType? AssociationType { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ServiceNetworking.Models.AssociationPatch 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.ServiceNetworking.Models.AssociationPatch 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; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationType` moving forward.")] + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AssociationType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AssociationType(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.AssociationType Subnets { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.AssociationType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.AssociationType left, Azure.ResourceManager.ServiceNetworking.Models.AssociationType right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.AssociationType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.AssociationType left, Azure.ResourceManager.ServiceNetworking.Models.AssociationType right) { throw null; } + public override string ToString() { throw null; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerFrontendPatch` moving forward.")] + public partial class FrontendPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FrontendPatch() { } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.ServiceNetworking.Models.FrontendPatch 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.ServiceNetworking.Models.FrontendPatch 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; } + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `ServiceNetworkingProvisioningState` moving forward.")] + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Accepted { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Deleting { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Provisioning { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Succeeded { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState Updating { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SecurityPolicyConfigurations : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SecurityPolicyConfigurations() { } + public Azure.Core.ResourceIdentifier IPAccessRulesSecurityPolicyId { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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 partial class SecurityPolicyUpdateProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SecurityPolicyUpdateProperties() { } + public System.Collections.Generic.IList Rules { get { throw null; } } + public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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 partial class ServiceNetworkingIPAccessRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ServiceNetworkingIPAccessRule(string name, int priority, System.Collections.Generic.IEnumerable sourceAddressPrefixes, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction action) { } + public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction Action { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public int Priority { get { throw null; } set { } } + public System.Collections.Generic.IList SourceAddressPrefixes { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ServiceNetworkingIPAccessRuleAction : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ServiceNetworkingIPAccessRuleAction(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction Allow { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction Deny { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction? (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ServiceNetworkingProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ServiceNetworkingProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Accepted { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Deleting { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Provisioning { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Succeeded { get { throw null; } } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState Updating { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class TrafficControllerAssociationPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerAssociationPatch() { } + public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TrafficControllerAssociationType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TrafficControllerAssociationType(string value) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType Subnets { get { throw null; } } + public bool Equals(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class TrafficControllerFrontendPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerFrontendPatch() { } + public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations FrontendUpdateSecurityPolicyConfigurations { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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 partial class TrafficControllerPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TrafficControllerPatch() { } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations TrafficControllerUpdateSecurityPolicyConfigurations { get { throw null; } set { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net8.0.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net8.0.cs index 04f1068da789..392e3085c43a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net8.0.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.net8.0.cs @@ -24,7 +24,10 @@ public ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.AzureLocatio public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public System.Collections.Generic.IList Rules { get { throw null; } } public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -224,7 +227,10 @@ public TrafficControllerAssociationData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerAssociationData 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.ServiceNetworking.TrafficControllerAssociationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -287,7 +293,10 @@ public TrafficControllerData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? TrafficControllerProvisioningState { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerData 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.ServiceNetworking.TrafficControllerData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -317,7 +326,10 @@ public TrafficControllerFrontendData(Azure.Core.AzureLocation location) { } public string Fqdn { get { throw null; } } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations SecurityPolicyConfigurations { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerFrontendData 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.ServiceNetworking.TrafficControllerFrontendData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -441,7 +453,10 @@ public ApplicationGatewayForContainersSecurityPolicyPatch() { } public System.Collections.Generic.IDictionary Tags { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -463,21 +478,26 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } public override string ToString() { throw null; } } public static partial class ArmServiceNetworkingModelFactory { - public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType = default(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType?), Azure.Core.ResourceIdentifier wafPolicyId = null, System.Collections.Generic.IEnumerable rules = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType, Azure.Core.ResourceIdentifier wafPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType = default(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType?), Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?), Azure.Core.ResourceIdentifier wafPolicyId = null, System.Collections.Generic.IEnumerable rules = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch ApplicationGatewayForContainersSecurityPolicyPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties properties = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerAssociationData` moving forward.")] public static Azure.ResourceManager.ServiceNetworking.AssociationData AssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.AssociationType? associationType, Azure.Core.ResourceIdentifier subnetId, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerFrontedData` moving forward.")] public static Azure.ResourceManager.ServiceNetworking.FrontendData FrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } - public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData TrafficControllerAssociationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule ServiceNetworkingIPAccessRule(string name = null, int priority = 0, System.Collections.Generic.IEnumerable sourceAddressPrefixes = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction action = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData TrafficControllerAssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch TrafficControllerAssociationPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null) { throw null; } public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, System.Collections.Generic.IEnumerable configurationEndpoints, System.Collections.Generic.IEnumerable frontends, System.Collections.Generic.IEnumerable associations, System.Collections.Generic.IEnumerable securityPolicies, Azure.Core.ResourceIdentifier wafSecurityPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IEnumerable configurationEndpoints = null, System.Collections.Generic.IEnumerable frontends = null, System.Collections.Generic.IEnumerable associations = null, System.Collections.Generic.IEnumerable securityPolicies = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -485,6 +505,8 @@ public static partial class ArmServiceNetworkingModelFactory public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string fqdn = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch TrafficControllerFrontendPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations frontendUpdateSecurityPolicyConfigurations = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch TrafficControllerPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations trafficControllerUpdateSecurityPolicyConfigurations = null) { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationPatch` moving forward.")] @@ -563,7 +585,10 @@ public partial class SecurityPolicyConfigurations : System.ClientModel.Primitive public SecurityPolicyConfigurations() { } public Azure.Core.ResourceIdentifier IPAccessRulesSecurityPolicyId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -575,7 +600,10 @@ public partial class SecurityPolicyUpdateProperties : System.ClientModel.Primiti public SecurityPolicyUpdateProperties() { } public System.Collections.Generic.IList Rules { get { throw null; } } public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -589,7 +617,10 @@ public ServiceNetworkingIPAccessRule(string name, int priority, System.Collectio public string Name { get { throw null; } set { } } public int Priority { get { throw null; } set { } } public System.Collections.Generic.IList SourceAddressPrefixes { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -611,6 +642,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } public override string ToString() { throw null; } } @@ -634,6 +666,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -643,7 +676,10 @@ public TrafficControllerAssociationPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -664,6 +700,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } public override string ToString() { throw null; } } @@ -672,7 +709,10 @@ public partial class TrafficControllerFrontendPatch : System.ClientModel.Primiti public TrafficControllerFrontendPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations FrontendUpdateSecurityPolicyConfigurations { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -686,7 +726,10 @@ public TrafficControllerPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations TrafficControllerUpdateSecurityPolicyConfigurations { get { throw null; } set { } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.netstandard2.0.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.netstandard2.0.cs index 04f1068da789..392e3085c43a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.netstandard2.0.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/api/Azure.ResourceManager.ServiceNetworking.netstandard2.0.cs @@ -24,7 +24,10 @@ public ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.AzureLocatio public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public System.Collections.Generic.IList Rules { get { throw null; } } public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData 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.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -224,7 +227,10 @@ public TrafficControllerAssociationData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerAssociationData 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.ServiceNetworking.TrafficControllerAssociationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -287,7 +293,10 @@ public TrafficControllerData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? TrafficControllerProvisioningState { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerData 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.ServiceNetworking.TrafficControllerData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -317,7 +326,10 @@ public TrafficControllerFrontendData(Azure.Core.AzureLocation location) { } public string Fqdn { get { throw null; } } public Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations SecurityPolicyConfigurations { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData 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 virtual Azure.ResourceManager.Models.ResourceData 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.ServiceNetworking.TrafficControllerFrontendData 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.ServiceNetworking.TrafficControllerFrontendData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -441,7 +453,10 @@ public ApplicationGatewayForContainersSecurityPolicyPatch() { } public System.Collections.Generic.IDictionary Tags { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -463,21 +478,26 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType left, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType right) { throw null; } public override string ToString() { throw null; } } public static partial class ArmServiceNetworkingModelFactory { - public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType = default(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType?), Azure.Core.ResourceIdentifier wafPolicyId = null, System.Collections.Generic.IEnumerable rules = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType, Azure.Core.ResourceIdentifier wafPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType? policyType = default(Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyType?), Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?), Azure.Core.ResourceIdentifier wafPolicyId = null, System.Collections.Generic.IEnumerable rules = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ApplicationGatewayForContainersSecurityPolicyPatch ApplicationGatewayForContainersSecurityPolicyPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties properties = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerAssociationData` moving forward.")] public static Azure.ResourceManager.ServiceNetworking.AssociationData AssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.AssociationType? associationType, Azure.Core.ResourceIdentifier subnetId, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This method is now deprecated. Please use `TrafficControllerFrontedData` moving forward.")] public static Azure.ResourceManager.ServiceNetworking.FrontendData FrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ProvisioningState? provisioningState) { throw null; } - public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData TrafficControllerAssociationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule ServiceNetworkingIPAccessRule(string name = null, int priority = 0, System.Collections.Generic.IEnumerable sourceAddressPrefixes = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction action = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.ResourceManager.ServiceNetworking.TrafficControllerAssociationData TrafficControllerAssociationData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch TrafficControllerAssociationPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? associationType = default(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType?), Azure.Core.ResourceIdentifier subnetId = null) { throw null; } public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, System.Collections.Generic.IEnumerable configurationEndpoints, System.Collections.Generic.IEnumerable frontends, System.Collections.Generic.IEnumerable associations, System.Collections.Generic.IEnumerable securityPolicies, Azure.Core.ResourceIdentifier wafSecurityPolicyId, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } public static Azure.ResourceManager.ServiceNetworking.TrafficControllerData TrafficControllerData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), System.Collections.Generic.IEnumerable configurationEndpoints = null, System.Collections.Generic.IEnumerable frontends = null, System.Collections.Generic.IEnumerable associations = null, System.Collections.Generic.IEnumerable securityPolicies = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -485,6 +505,8 @@ public static partial class ArmServiceNetworkingModelFactory public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), string fqdn = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations securityPolicyConfigurations = null, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState = default(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.ResourceManager.ServiceNetworking.TrafficControllerFrontendData TrafficControllerFrontendData(Azure.Core.ResourceIdentifier id, string name, Azure.Core.ResourceType resourceType, Azure.ResourceManager.Models.SystemData systemData, System.Collections.Generic.IDictionary tags, Azure.Core.AzureLocation location, string fqdn, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? provisioningState) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch TrafficControllerFrontendPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations frontendUpdateSecurityPolicyConfigurations = null) { throw null; } + public static Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch TrafficControllerPatch(System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations trafficControllerUpdateSecurityPolicyConfigurations = null) { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("This class is now deprecated. Please use the new class `TrafficControllerAssociationPatch` moving forward.")] @@ -563,7 +585,10 @@ public partial class SecurityPolicyConfigurations : System.ClientModel.Primitive public SecurityPolicyConfigurations() { } public Azure.Core.ResourceIdentifier IPAccessRulesSecurityPolicyId { get { throw null; } set { } } public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations 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.ServiceNetworking.Models.SecurityPolicyConfigurations System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -575,7 +600,10 @@ public partial class SecurityPolicyUpdateProperties : System.ClientModel.Primiti public SecurityPolicyUpdateProperties() { } public System.Collections.Generic.IList Rules { get { throw null; } } public Azure.Core.ResourceIdentifier WafPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties 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.ServiceNetworking.Models.SecurityPolicyUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -589,7 +617,10 @@ public ServiceNetworkingIPAccessRule(string name, int priority, System.Collectio public string Name { get { throw null; } set { } } public int Priority { get { throw null; } set { } } public System.Collections.Generic.IList SourceAddressPrefixes { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule 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.ServiceNetworking.Models.ServiceNetworkingIPAccessRule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -611,6 +642,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingIPAccessRuleAction right) { throw null; } public override string ToString() { throw null; } } @@ -634,6 +666,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState left, Azure.ResourceManager.ServiceNetworking.Models.ServiceNetworkingProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -643,7 +676,10 @@ public TrafficControllerAssociationPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? AssociationType { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SubnetId { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch 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.ServiceNetworking.Models.TrafficControllerAssociationPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -664,6 +700,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType left, Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerAssociationType right) { throw null; } public override string ToString() { throw null; } } @@ -672,7 +709,10 @@ public partial class TrafficControllerFrontendPatch : System.ClientModel.Primiti public TrafficControllerFrontendPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations FrontendUpdateSecurityPolicyConfigurations { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch 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.ServiceNetworking.Models.TrafficControllerFrontendPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -686,7 +726,10 @@ public TrafficControllerPatch() { } public Azure.ResourceManager.ServiceNetworking.Models.SecurityPolicyConfigurations TrafficControllerUpdateSecurityPolicyConfigurations { get { throw null; } set { } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Core.ResourceIdentifier WafSecurityPolicyId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch 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.ServiceNetworking.Models.TrafficControllerPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/assets.json b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/assets.json index d22d268b56e2..d7b2ac54719b 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/assets.json +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/servicenetworking/Azure.ResourceManager.ServiceNetworking", - "Tag": "net/servicenetworking/Azure.ResourceManager.ServiceNetworking_ce05ecb868" + "Tag": "net/servicenetworking/Azure.ResourceManager.ServiceNetworking_bafbfe192b" } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Azure.ResourceManager.ServiceNetworking.csproj b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Azure.ResourceManager.ServiceNetworking.csproj index 5c03b1d1e2b9..2090d75769ef 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Azure.ResourceManager.ServiceNetworking.csproj +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Azure.ResourceManager.ServiceNetworking.csproj @@ -6,7 +6,6 @@ Azure.ResourceManager.ServiceNetworking Azure Resource Manager client SDK for Azure resource provider ServiceNetworking. azure;management;arm;resource manager;servicenetworking - true true diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/ArmServiceNetworkingModelFactory.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/ArmServiceNetworkingModelFactory.cs index a22c61a2a874..e1570ea76665 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/ArmServiceNetworkingModelFactory.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/ArmServiceNetworkingModelFactory.cs @@ -31,7 +31,7 @@ public static partial class ArmServiceNetworkingModelFactory /// A new instance for mocking. [EditorBrowsable(EditorBrowsableState.Never)] public static TrafficControllerData TrafficControllerData(ResourceIdentifier id, string name, ResourceType resourceType, ResourceManager.Models.SystemData systemData, IDictionary tags, AzureLocation location, IEnumerable configurationEndpoints, IEnumerable frontends, IEnumerable associations, ProvisioningState? provisioningState) - => TrafficControllerData(id, name, resourceType, systemData, tags, location, configurationEndpoints, frontends, associations, trafficControllerProvisioningState: provisioningState.ToString()); + => TrafficControllerData(id, name, resourceType, systemData, tags, location, configurationEndpoints, frontends, associations, securityPolicies: null, wafSecurityPolicyId: null, trafficControllerProvisioningState: provisioningState.ToString()); /// Initializes a new instance of . /// The id. @@ -124,6 +124,64 @@ public static TrafficControllerData TrafficControllerData(ResourceIdentifier id, } : null, trafficControllerProvisioningState); } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Type of the Traffic Controller Security Policy. + /// Web Application Firewall Policy of the Traffic Controller Security Policy. + /// Provisioning State of Traffic Controller SecurityPolicy Resource. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ApplicationGatewayForContainersSecurityPolicyType? policyType, ResourceIdentifier wafPolicyId, ServiceNetworkingProvisioningState? provisioningState) + { + return ApplicationGatewayForContainersSecurityPolicyData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, policyType: policyType, wafPolicyId: wafPolicyId, rules: default, provisioningState: provisioningState); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. + /// Provisioning State of Traffic Controller Frontend Resource. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static TrafficControllerFrontendData TrafficControllerFrontendData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string fqdn, ServiceNetworkingProvisioningState? provisioningState) + { + return TrafficControllerFrontendData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, fqdn: fqdn, securityPolicyConfigurations: null, provisioningState: provisioningState); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Association Type. + /// Association Subnet. + /// Provisioning State of Traffic Controller Association Resource. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static TrafficControllerAssociationData TrafficControllerAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, TrafficControllerAssociationType? associationType = null, ResourceIdentifier subnetId = null, ServiceNetworkingProvisioningState? provisioningState = null) + { + return new TrafficControllerAssociationData( + id, + name, + resourceType, + systemData, + additionalBinaryDataProperties: null, + tags, + location, + associationType is null && provisioningState is null && subnetId is null ? null : new AssociationProperties(associationType.Value, new AssociationSubnet(subnetId, null), provisioningState, null)); + } } #pragma warning restore 0618 } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationCollection.cs index 0cb91ed937d6..d48f768c9ac5 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationCollection.cs @@ -7,6 +7,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Globalization; using System.Threading; using System.Threading.Tasks; @@ -26,7 +27,7 @@ namespace Azure.ResourceManager.ServiceNetworking public partial class AssociationCollection : ArmCollection, IEnumerable, IAsyncEnumerable { private readonly ClientDiagnostics _associationAssociationsInterfaceClientDiagnostics; - private readonly AssociationsInterfaceRestOperations _associationAssociationsInterfaceRestClient; + private readonly AssociationsInterface _associationAssociationsInterfaceRestClient; /// Initializes a new instance of the class for mocking. protected AssociationCollection() @@ -38,18 +39,20 @@ protected AssociationCollection() /// The identifier of the parent resource that is the target of operations. internal AssociationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _associationAssociationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", AssociationResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(AssociationResource.ResourceType, out string associationAssociationsInterfaceApiVersion); - _associationAssociationsInterfaceRestClient = new AssociationsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, associationAssociationsInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + _associationAssociationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", AssociationResource.ResourceType.Namespace, Diagnostics); + _associationAssociationsInterfaceRestClient = new AssociationsInterface(_associationAssociationsInterfaceClientDiagnostics, Pipeline, Endpoint, associationAssociationsInterfaceApiVersion ?? "2023-11-01"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficControllerResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), id); + } } /// @@ -84,14 +87,27 @@ public virtual async Task> CreateOrUpdateAsync Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.CreateOrUpdate"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data.ToTrafficControllerAssociationData(), cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new AssociationOperationSource(Client),_associationAssociationsInterfaceClientDiagnostics, Pipeline, _associationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data.ToTrafficControllerAssociationData()).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, TrafficControllerAssociationData.ToRequestContent(data.ToTrafficControllerAssociationData()), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new AssociationOperationSource(Client), + _associationAssociationsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -133,14 +149,27 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUn Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.CreateOrUpdate"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.CreateOrUpdate"); scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data.ToTrafficControllerAssociationData(), cancellationToken); - var operation = new ServiceNetworkingArmOperation(new AssociationOperationSource(Client), _associationAssociationsInterfaceClientDiagnostics, Pipeline, _associationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data.ToTrafficControllerAssociationData()).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, TrafficControllerAssociationData.ToRequestContent(data.ToTrafficControllerAssociationData()), context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new AssociationOperationSource(Client), + _associationAssociationsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -179,13 +208,21 @@ public virtual async Task> GetAsync(string associa { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Get"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Get"); scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -224,13 +261,21 @@ public virtual Response Get(string associationName, Cancell { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Get"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Get"); scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -265,9 +310,11 @@ public virtual Response Get(string associationName, Cancell /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _associationAssociationsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _associationAssociationsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AssociationResource(Client, AssociationData.DeserializeAssociationData(e)), _associationAssociationsInterfaceClientDiagnostics, Pipeline, "AssociationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT(_associationAssociationsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new AssociationResource(Client, data)); } /// @@ -295,9 +342,11 @@ public virtual AsyncPageable GetAllAsync(CancellationToken /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _associationAssociationsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _associationAssociationsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AssociationResource(Client, AssociationData.DeserializeAssociationData(e)), _associationAssociationsInterfaceClientDiagnostics, Pipeline, "AssociationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AssociationInterfaceGetByTrafficControllerCollectionResultOfT(_associationAssociationsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new AssociationResource(Client, data)); } /// @@ -329,11 +378,29 @@ public virtual async Task> ExistsAsync(string associationName, Ca { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Exists"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Exists"); scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -372,11 +439,29 @@ public virtual Response Exists(string associationName, CancellationToken c { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Exists"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.Exists"); scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -415,13 +500,33 @@ public virtual async Task> GetIfExistsAsyn { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.GetIfExists"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.GetIfExists"); scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -460,13 +565,33 @@ public virtual NullableResponse GetIfExists(string associat { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.GetIfExists"); + using DiagnosticScope scope = _associationAssociationsInterfaceClientDiagnostics.CreateScope("AssociationCollection.GetIfExists"); scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +611,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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationData.cs index 738edb375b4e..e83e85c58efc 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationData.cs @@ -86,14 +86,24 @@ internal AssociationData() internal AssociationData(TrafficControllerAssociationData data) : base(data.Id, data.Name, data.ResourceType, data.SystemData, data.Tags, data.Location) { AssociationType = data.AssociationType.ToString(); - Subnet = data.Subnet; + Subnet = new WritableSubResource() { Id = new ResourceIdentifier(data.SubnetId) }; ProvisioningState = data.ProvisioningState.ToString(); _serializedAdditionalRawData = null; } internal TrafficControllerAssociationData ToTrafficControllerAssociationData() { - return new TrafficControllerAssociationData(Id, Name, ResourceType, SystemData, Tags, Location, AssociationType.ToString(), Subnet, ProvisioningState.ToString(), _serializedAdditionalRawData); + AssociationProperties properties = null; + if (AssociationType.HasValue) + { + var trafficControllerAssociationType = (TrafficControllerAssociationType)Enum.Parse(typeof(TrafficControllerAssociationType), AssociationType.Value.ToString()); + properties = new AssociationProperties(trafficControllerAssociationType); + + if (SubnetId != null) + properties.SubnetId = SubnetId; + } + + return new TrafficControllerAssociationData(Id, Name, ResourceType, SystemData, _serializedAdditionalRawData,Tags, Location, properties); } /// Association Type. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationResource.cs index 015af5360196..edfcdb274af8 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/AssociationResource.cs @@ -37,7 +37,7 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, } private readonly ClientDiagnostics _associationAssociationsInterfaceClientDiagnostics; - private readonly AssociationsInterfaceRestOperations _associationAssociationsInterfaceRestClient; + private readonly AssociationsInterface _associationAssociationsInterfaceRestClient; private readonly AssociationData _data; /// Gets the resource type for the operations. @@ -64,9 +64,9 @@ internal AssociationResource(ArmClient client, ResourceIdentifier id) : base(cli { _associationAssociationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); TryGetApiVersion(ResourceType, out string associationAssociationsInterfaceApiVersion); - _associationAssociationsInterfaceRestClient = new AssociationsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, associationAssociationsInterfaceApiVersion); + _associationAssociationsInterfaceRestClient = new AssociationsInterface(_associationAssociationsInterfaceClientDiagnostics, Pipeline, Endpoint, associationAssociationsInterfaceApiVersion); #if DEBUG - ValidateResourceId(Id); + ValidateResourceId(Id); #endif } @@ -119,7 +119,10 @@ public virtual async Task> GetAsync(CancellationTo scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); @@ -159,7 +162,10 @@ public virtual Response Get(CancellationToken cancellationT scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); @@ -200,8 +206,10 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_associationAssociationsInterfaceClientDiagnostics, Pipeline, _associationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var operation = new ServiceNetworkingArmOperation(_associationAssociationsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -242,8 +250,10 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_associationAssociationsInterfaceClientDiagnostics, Pipeline, _associationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var response = Pipeline.ProcessMessage(message, context); + var operation = new ServiceNetworkingArmOperation(_associationAssociationsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -287,7 +297,12 @@ public virtual async Task> UpdateAsync(Association scope.Start(); try { - var response = await _associationAssociationsInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch.ToTrafficControllerAssociationPatch(), cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerAssociationPatch.ToRequestContent(patch.ToTrafficControllerAssociationPatch()), context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -329,7 +344,12 @@ public virtual Response Update(AssociationPatch patch, Canc scope.Start(); try { - var response = _associationAssociationsInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch.ToTrafficControllerAssociationPatch(), cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerAssociationPatch.ToRequestContent(patch.ToTrafficControllerAssociationPatch()), context); + var result = Pipeline.ProcessMessage(message, context); + var response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new AssociationResource(Client, new AssociationData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -378,7 +398,10 @@ public virtual async Task> AddTagAsync(string key, var 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 _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -440,7 +463,10 @@ public virtual Response AddTag(string key, string value, Ca var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -501,7 +527,10 @@ public virtual async Task> SetTagsAsync(IDictionar var 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 _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -558,7 +587,10 @@ public virtual Response SetTags(IDictionary var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -614,7 +646,10 @@ public virtual async Task> RemoveTagAsync(string k var 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 _associationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -674,7 +709,10 @@ public virtual Response RemoveTag(string key, CancellationT var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _associationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _associationAssociationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); return Response.FromValue(new AssociationResource(Client, new AssociationData(originalResponse.Value)), originalResponse.GetRawResponse()); } else diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c66a7d5af111 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable +#pragma warning disable CS0618 // Type or member is obsolete + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + /// + /// Custom collection result for deprecated AssociationCollection.GetAll methods. + /// + internal partial class AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT : AsyncPageable + { + private readonly AssociationsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AssociationsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT(AssociationsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AssociationInterfaceGetByTrafficControllerAsyncCollectionResultOfT 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; + } + AssociationListResult result = AssociationListResult.FromResponse(response); + // Convert TrafficControllerAssociationData to AssociationData + var associationDataList = new List(); + if (result.Value != null) + { + foreach (var item in result.Value) + { + associationDataList.Add(new AssociationData(item)); + } + } + yield return Page.FromValues(associationDataList, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AssociationCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerCollectionResultOfT.cs new file mode 100644 index 000000000000..f51b5241b0f2 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/CollectionResults/AssociationInterfaceGetByTrafficControllerCollectionResultOfT.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable +#pragma warning disable CS0618 // Type or member is obsolete + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + /// + /// Custom collection result for deprecated AssociationCollection.GetAll methods. + /// + internal partial class AssociationInterfaceGetByTrafficControllerCollectionResultOfT : Pageable + { + private readonly AssociationsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of AssociationInterfaceGetByTrafficControllerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AssociationsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AssociationInterfaceGetByTrafficControllerCollectionResultOfT(AssociationsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of AssociationInterfaceGetByTrafficControllerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AssociationInterfaceGetByTrafficControllerCollectionResultOfT 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; + } + AssociationListResult result = AssociationListResult.FromResponse(response); + // Convert TrafficControllerAssociationData to AssociationData + var associationDataList = new List(); + if (result.Value != null) + { + foreach (var item in result.Value) + { + associationDataList.Add(new AssociationData(item)); + } + } + yield return Page.FromValues(associationDataList, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("AssociationCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendCollection.cs index 664eee05743c..758a9742e6e2 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendCollection.cs @@ -26,7 +26,7 @@ namespace Azure.ResourceManager.ServiceNetworking public partial class FrontendCollection : ArmCollection, IEnumerable, IAsyncEnumerable { private readonly ClientDiagnostics _frontendFrontendsInterfaceClientDiagnostics; - private readonly FrontendsInterfaceRestOperations _frontendFrontendsInterfaceRestClient; + private readonly FrontendsInterface _frontendFrontendsInterfaceRestClient; /// Initializes a new instance of the class for mocking. protected FrontendCollection() @@ -40,9 +40,9 @@ internal FrontendCollection(ArmClient client, ResourceIdentifier id) : base(clie { _frontendFrontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", FrontendResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(FrontendResource.ResourceType, out string frontendFrontendsInterfaceApiVersion); - _frontendFrontendsInterfaceRestClient = new FrontendsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, frontendFrontendsInterfaceApiVersion); + _frontendFrontendsInterfaceRestClient = new FrontendsInterface(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, Endpoint, frontendFrontendsInterfaceApiVersion); #if DEBUG - ValidateResourceId(Id); + ValidateResourceId(Id); #endif } @@ -88,8 +88,10 @@ public virtual async Task> CreateOrUpdateAsync(Wa scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data.ToTrafficControllerFrontendData(), cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new FrontendOperationSource(Client), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, _frontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data.ToTrafficControllerFrontendData()).Request, response, OperationFinalStateVia.AzureAsyncOperation); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, TrafficControllerFrontendData.ToRequestContent(data.ToTrafficControllerFrontendData()), context); + var response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var operation = new ServiceNetworkingArmOperation(new FrontendOperationSource(Client), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -137,8 +139,10 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data.ToTrafficControllerFrontendData(), cancellationToken); - var operation = new ServiceNetworkingArmOperation(new FrontendOperationSource(Client), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, _frontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data.ToTrafficControllerFrontendData()).Request, response, OperationFinalStateVia.AzureAsyncOperation); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, TrafficControllerFrontendData.ToRequestContent(data.ToTrafficControllerFrontendData()), context); + var response = Pipeline.ProcessMessage(message, context); + var operation = new ServiceNetworkingArmOperation(new FrontendOperationSource(Client), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; @@ -183,7 +187,10 @@ public virtual async Task> GetAsync(string frontendNa scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); @@ -228,7 +235,10 @@ public virtual Response Get(string frontendName, CancellationT scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + var result = Pipeline.ProcessMessage(message, context); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); @@ -265,9 +275,10 @@ public virtual Response Get(string frontendName, CancellationT /// An async collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _frontendFrontendsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _frontendFrontendsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FrontendResource(Client, FrontendData.DeserializeFrontendData(e)), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, "FrontendCollection.GetAll", "value", "nextLink", cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + return new AsyncPageableWrapper( + new FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT(_frontendFrontendsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), + data => new FrontendResource(Client, new FrontendData(data))); } /// @@ -295,9 +306,10 @@ public virtual AsyncPageable GetAllAsync(CancellationToken can /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _frontendFrontendsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _frontendFrontendsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FrontendResource(Client, FrontendData.DeserializeFrontendData(e)), _frontendFrontendsInterfaceClientDiagnostics, Pipeline, "FrontendCollection.GetAll", "value", "nextLink", cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + return new PageableWrapper( + new FrontendsInterfaceGetByTrafficControllerCollectionResultOfT(_frontendFrontendsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), + data => new FrontendResource(Client, new FrontendData(data))); } /// @@ -333,7 +345,22 @@ public virtual async Task> ExistsAsync(string frontendName, Cance scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + var result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -376,7 +403,22 @@ public virtual Response Exists(string frontendName, CancellationToken canc scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Pipeline.Send(message, context.CancellationToken); + var result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -419,7 +461,22 @@ public virtual async Task> GetIfExistsAsync(s scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + var result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) return new NoValueResponse(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); @@ -464,7 +521,22 @@ public virtual NullableResponse GetIfExists(string frontendNam scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Pipeline.Send(message, context.CancellationToken); + var result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) return new NoValueResponse(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendData.cs index 866c8c3ff9dc..473f46a09cdb 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendData.cs @@ -88,7 +88,15 @@ internal FrontendData(TrafficControllerFrontendData data) : base(data.Id, data.N internal TrafficControllerFrontendData ToTrafficControllerFrontendData() { - return new TrafficControllerFrontendData(Id, Name, ResourceType, SystemData, Tags, Location, Fqdn, null, ProvisioningState.HasValue ? (ServiceNetworkingProvisioningState?)Enum.Parse(typeof(ServiceNetworkingProvisioningState), ProvisioningState.Value.ToString()) : null, _serializedAdditionalRawData); + FrontendProperties properties = null; + if (!string.IsNullOrEmpty(Fqdn) || ProvisioningState.HasValue) + { + properties = new FrontendProperties(); + // Fqdn is read-only, so we can't set it in the properties + // ProvisioningState is also read-only + } + + return new TrafficControllerFrontendData(Id, Name, ResourceType, SystemData, _serializedAdditionalRawData, Tags, Location, properties); } /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendResource.cs index 16d440331ef2..e142bf7fb0fb 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/FrontendResource.cs @@ -37,7 +37,7 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, } private readonly ClientDiagnostics _frontendFrontendsInterfaceClientDiagnostics; - private readonly FrontendsInterfaceRestOperations _frontendFrontendsInterfaceRestClient; + private readonly FrontendsInterface _frontendFrontendsInterfaceRestClient; private readonly FrontendData _data; /// Gets the resource type for the operations. @@ -64,7 +64,7 @@ internal FrontendResource(ArmClient client, ResourceIdentifier id) : base(client { _frontendFrontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); TryGetApiVersion(ResourceType, out string frontendFrontendsInterfaceApiVersion); - _frontendFrontendsInterfaceRestClient = new FrontendsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, frontendFrontendsInterfaceApiVersion); + _frontendFrontendsInterfaceRestClient = new FrontendsInterface(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, Endpoint, frontendFrontendsInterfaceApiVersion); #if DEBUG ValidateResourceId(Id); #endif @@ -119,7 +119,10 @@ public virtual async Task> GetAsync(CancellationToken scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); @@ -159,7 +162,10 @@ public virtual Response Get(CancellationToken cancellationToke scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); @@ -200,8 +206,10 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, _frontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var operation = new ServiceNetworkingArmOperation(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); return operation; @@ -242,8 +250,10 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, _frontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var response = Pipeline.ProcessMessage(message, context); + var operation = new ServiceNetworkingArmOperation(_frontendFrontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletionResponse(cancellationToken); return operation; @@ -287,7 +297,12 @@ public virtual async Task> UpdateAsync(FrontendPatch scope.Start(); try { - var response = await _frontendFrontendsInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch.ToTrafficControllerFrontendPatch(), cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerFrontendPatch.ToRequestContent(patch.ToTrafficControllerFrontendPatch()), context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -329,7 +344,12 @@ public virtual Response Update(FrontendPatch patch, Cancellati scope.Start(); try { - var response = _frontendFrontendsInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch.ToTrafficControllerFrontendPatch(), cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerFrontendPatch.ToRequestContent(patch.ToTrafficControllerFrontendPatch()), context); + var result = Pipeline.ProcessMessage(message, context); + var response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); return Response.FromValue(new FrontendResource(Client, new FrontendData(response.Value)), response.GetRawResponse()); } catch (Exception e) @@ -378,7 +398,10 @@ public virtual async Task> AddTagAsync(string key, st var 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 _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var originalResponse = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); return Response.FromValue(new FrontendResource(Client, new FrontendData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -440,7 +463,10 @@ public virtual Response AddTag(string key, string value, Cance var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); return Response.FromValue(new FrontendResource(Client, new FrontendData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -501,7 +527,10 @@ public virtual async Task> SetTagsAsync(IDictionary SetTags(IDictionary ta var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); return Response.FromValue(new FrontendResource(Client, new FrontendData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -614,7 +646,10 @@ public virtual async Task> RemoveTagAsync(string key, var 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 _frontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + var originalResponse = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); return Response.FromValue(new FrontendResource(Client, new FrontendData(originalResponse.Value)), originalResponse.GetRawResponse()); } else @@ -674,7 +709,10 @@ public virtual Response RemoveTag(string key, CancellationToke var originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _frontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var context = new RequestContext { CancellationToken = cancellationToken }; + var message = _frontendFrontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + var result = Pipeline.ProcessMessage(message, context); + var originalResponse = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); return Response.FromValue(new FrontendResource(Client, new FrontendData(originalResponse.Value)), originalResponse.GetRawResponse()); } else diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationPatch.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationPatch.cs index b478071488e3..66180e435bba 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationPatch.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationPatch.cs @@ -77,7 +77,7 @@ internal AssociationPatch(TrafficControllerAssociationPatch patch) internal TrafficControllerAssociationPatch ToTrafficControllerAssociationPatch() { - return new TrafficControllerAssociationPatch(Tags, AssociationType.ToString(), Subnet, _serializedAdditionalRawData); + return new TrafficControllerAssociationPatch(Tags, new AssociationUpdateProperties(AssociationType.ToString(), new AssociationSubnetUpdate { Id = SubnetId }, _serializedAdditionalRawData), _serializedAdditionalRawData); } /// Resource tags. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationProperties.cs new file mode 100644 index 000000000000..6e85d127b49f --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Custom/Models/AssociationProperties.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using Azure.ResourceManager.ServiceNetworking.Models; +using Microsoft.TypeSpec.Generator.Customizations; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + [CodeGenType(nameof(AssociationProperties))] + internal partial class AssociationProperties + { + /// Association Type. + [CodeGenMember("AssociationType")] + public TrafficControllerAssociationType? AssociationType { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyCollection.cs index 7b690543896d..2fcb3b51fa4d 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyCollection.cs @@ -8,67 +8,66 @@ 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; namespace Azure.ResourceManager.ServiceNetworking { /// /// A class representing a collection of and their operations. /// Each in the collection will belong to the same instance of . - /// To get an instance call the GetApplicationGatewayForContainersSecurityPolicies method from an instance of . + /// To get a instance call the GetApplicationGatewayForContainersSecurityPolicies method from an instance of . /// public partial class ApplicationGatewayForContainersSecurityPolicyCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics; - private readonly SecurityPoliciesInterfaceRestOperations _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient; + private readonly ClientDiagnostics _securityPoliciesInterfaceClientDiagnostics; + private readonly SecurityPoliciesInterface _securityPoliciesInterfaceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ApplicationGatewayForContainersSecurityPolicyCollection for mocking. protected ApplicationGatewayForContainersSecurityPolicyCollection() { } - /// 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 ApplicationGatewayForContainersSecurityPolicyCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ApplicationGatewayForContainersSecurityPolicyResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ApplicationGatewayForContainersSecurityPolicyResource.ResourceType, out string applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceApiVersion); - _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient = new SecurityPoliciesInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ApplicationGatewayForContainersSecurityPolicyResource.ResourceType, out string applicationGatewayForContainersSecurityPolicyApiVersion); + _securityPoliciesInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ApplicationGatewayForContainersSecurityPolicyResource.ResourceType.Namespace, Diagnostics); + _securityPoliciesInterfaceRestClient = new SecurityPoliciesInterface(_securityPoliciesInterfaceClientDiagnostics, Pipeline, Endpoint, applicationGatewayForContainersSecurityPolicyApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficControllerResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), id); + } } /// /// Create a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// SecurityPoliciesInterface_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -76,21 +75,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// SecurityPolicy. /// Resource create parameters. /// 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 securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.CreateOrUpdate"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new ApplicationGatewayForContainersSecurityPolicyOperationSource(Client), _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new ApplicationGatewayForContainersSecurityPolicyOperationSource(Client), + _securityPoliciesInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,20 +116,16 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_CreateOrUpdate + /// Operation Id. + /// SecurityPoliciesInterface_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -125,21 +133,34 @@ public virtual async Task SecurityPolicy. /// Resource create parameters. /// 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 securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.CreateOrUpdate"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.CreateOrUpdate"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data, cancellationToken); - var operation = new ServiceNetworkingArmOperation(new ApplicationGatewayForContainersSecurityPolicyOperationSource(Client), _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new ApplicationGatewayForContainersSecurityPolicyOperationSource(Client), + _securityPoliciesInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Get + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Get"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Get"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Get"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Get"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response G /// List SecurityPolicy resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies. /// /// - /// Operation Id - /// SecurityPolicy_ListByTrafficController + /// Operation Id. + /// SecurityPoliciesInterface_ListByTrafficController. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// 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) => _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ApplicationGatewayForContainersSecurityPolicyResource(Client, ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(e)), _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, "ApplicationGatewayForContainersSecurityPolicyCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT(_securityPoliciesInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new ApplicationGatewayForContainersSecurityPolicyResource(Client, data)); } /// /// List SecurityPolicy resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies - /// - /// - /// Operation Id - /// SecurityPolicy_ListByTrafficController + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// SecurityPoliciesInterface_ListByTrafficController. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ApplicationGatewayForContainersSecurityPolicyResource(Client, ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(e)), _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, "ApplicationGatewayForContainersSecurityPolicyCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT(_securityPoliciesInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new ApplicationGatewayForContainersSecurityPolicyResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Exists"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Exists"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -346,36 +385,50 @@ public virtual async Task> ExistsAsync(string securityPolicyName, /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Get + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Exists"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.Exists"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -389,38 +442,54 @@ public virtual Response Exists(string securityPolicyName, CancellationToke /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetIfExists"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetIfExists"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -434,38 +503,54 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Get + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// SecurityPolicy. /// 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 securityPolicyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetIfExists"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetIfExists"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, securityPolicyName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.Serialization.cs index 515ceca95390..bc10121d0472 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.Serialization.cs @@ -10,17 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - public partial class ApplicationGatewayForContainersSecurityPolicyData : IUtf8JsonSerializable, IJsonModel + /// SecurityPolicy Subresource of Traffic Controller. + public partial class ApplicationGatewayForContainersSecurityPolicyData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ApplicationGatewayForContainersSecurityPolicyData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -32,187 +38,144 @@ void IJsonModel.Write(Utf8Jso /// 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(ApplicationGatewayForContainersSecurityPolicyData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(PolicyType)) - { - writer.WritePropertyName("policyType"u8); - writer.WriteStringValue(PolicyType.Value.ToString()); - } - if (Optional.IsDefined(WafPolicy)) - { - writer.WritePropertyName("wafPolicy"u8); - ((IJsonModel)WafPolicy).Write(writer, options); - } - if (Optional.IsDefined(IPAccessRulesPolicy)) - { - writer.WritePropertyName("ipAccessRulesPolicy"u8); - writer.WriteObjectValue(IPAccessRulesPolicy, options); - } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - writer.WriteEndObject(); } - ApplicationGatewayForContainersSecurityPolicyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ApplicationGatewayForContainersSecurityPolicyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ApplicationGatewayForContainersSecurityPolicyData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData 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(ApplicationGatewayForContainersSecurityPolicyData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement, options); } - internal static ApplicationGatewayForContainersSecurityPolicyData DeserializeApplicationGatewayForContainersSecurityPolicyData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ApplicationGatewayForContainersSecurityPolicyData DeserializeApplicationGatewayForContainersSecurityPolicyData(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; + ResourceType resourceType = default; SystemData systemData = default; - ApplicationGatewayForContainersSecurityPolicyType? policyType = default; - WritableSubResource wafPolicy = default; - IPAccessRulesPolicy ipAccessRulesPolicy = default; - ServiceNetworkingProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + SecurityPolicyProperties 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)) { - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("policyType"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - policyType = new ApplicationGatewayForContainersSecurityPolicyType(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, null); } - if (property0.NameEquals("wafPolicy"u8)) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - wafPolicy = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); - continue; - } - if (property0.NameEquals("ipAccessRulesPolicy"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - ipAccessRulesPolicy = IPAccessRulesPolicy.DeserializeIPAccessRulesPolicy(property0.Value, options); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new ServiceNetworkingProvisioningState(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SecurityPolicyProperties.DeserializeSecurityPolicyProperties(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 ApplicationGatewayForContainersSecurityPolicyData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - policyType, - wafPolicy, - ipAccessRulesPolicy, - provisioningState, - serializedAdditionalRawData); + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -222,15 +185,20 @@ BinaryData IPersistableModel. } } - ApplicationGatewayForContainersSecurityPolicyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ApplicationGatewayForContainersSecurityPolicyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ApplicationGatewayForContainersSecurityPolicyData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement, options); } default: @@ -238,6 +206,26 @@ ApplicationGatewayForContainersSecurityPolicyData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ApplicationGatewayForContainersSecurityPolicyData applicationGatewayForContainersSecurityPolicyData) + { + if (applicationGatewayForContainersSecurityPolicyData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(applicationGatewayForContainersSecurityPolicyData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static ApplicationGatewayForContainersSecurityPolicyData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.cs index d4a0debc112e..07ff13cbefd8 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyData.cs @@ -9,111 +9,86 @@ using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - /// - /// A class representing the ApplicationGatewayForContainersSecurityPolicy data model. - /// SecurityPolicy Subresource of Traffic Controller. - /// + /// SecurityPolicy Subresource of Traffic Controller. public partial class ApplicationGatewayForContainersSecurityPolicyData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public ApplicationGatewayForContainersSecurityPolicyData(AzureLocation location) : base(location) { } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Type of the Traffic Controller Security Policy. - /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - /// Provisioning State of Traffic Controller SecurityPolicy Resource. - /// Keeps track of any properties unknown to the library. - internal ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ApplicationGatewayForContainersSecurityPolicyType? policyType, WritableSubResource wafPolicy, IPAccessRulesPolicy ipAccessRulesPolicy, ServiceNetworkingProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, SecurityPolicyProperties properties) : base(id, name, resourceType, systemData, tags, location) { - PolicyType = policyType; - WafPolicy = wafPolicy; - IPAccessRulesPolicy = ipAccessRulesPolicy; - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal ApplicationGatewayForContainersSecurityPolicyData() + /// The resource-specific properties for this resource. + internal SecurityPolicyProperties Properties { get; set; } + + /// Type of the Traffic Controller Security Policy. + public ApplicationGatewayForContainersSecurityPolicyType? PolicyType { + get + { + return Properties is null ? default : Properties.PolicyType; + } } - /// Type of the Traffic Controller Security Policy. - public ApplicationGatewayForContainersSecurityPolicyType? PolicyType { get; } - /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - internal WritableSubResource WafPolicy { get; set; } - /// Gets or sets Id. + /// Provisioning State of Traffic Controller SecurityPolicy Resource. + public ServiceNetworkingProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } + + /// Resource ID of the WAF. public ResourceIdentifier WafPolicyId { - get => WafPolicy is null ? default : WafPolicy.Id; + get + { + return Properties is null ? default : Properties.WafPolicyId; + } set { - if (WafPolicy is null) - WafPolicy = new WritableSubResource(); - WafPolicy.Id = value; + if (Properties is null) + { + Properties = new SecurityPolicyProperties(); + } + Properties.WafPolicyId = value; } } - /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - internal IPAccessRulesPolicy IPAccessRulesPolicy { get; set; } /// Ip Access Policy Rules List. public IList Rules { get { - if (IPAccessRulesPolicy is null) - IPAccessRulesPolicy = new IPAccessRulesPolicy(); - return IPAccessRulesPolicy.Rules; + if (Properties is null) + { + Properties = new SecurityPolicyProperties(); + } + return Properties.Rules; } } - - /// Provisioning State of Traffic Controller SecurityPolicy Resource. - public ServiceNetworkingProvisioningState? ProvisioningState { get; } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.Serialization.cs index 94faea671968..5b660a382bab 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.ServiceNetworking { + /// public partial class ApplicationGatewayForContainersSecurityPolicyResource : IJsonModel { - private static ApplicationGatewayForContainersSecurityPolicyData s_dataDeserializationInstance; - private static ApplicationGatewayForContainersSecurityPolicyData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new ApplicationGatewayForContainersSecurityPolicyData(); + + /// 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); - ApplicationGatewayForContainersSecurityPolicyData 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. + ApplicationGatewayForContainersSecurityPolicyData 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, AzureResourceManagerServiceNetworkingContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. ApplicationGatewayForContainersSecurityPolicyData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerServiceNetworkingContext.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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.cs index f0f55df95092..38532e940e97 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ApplicationGatewayForContainersSecurityPolicyResource.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.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { /// - /// A Class representing an ApplicationGatewayForContainersSecurityPolicy along with the instance operations that can be performed on it. - /// If you have a you can construct an - /// from an instance of using the GetApplicationGatewayForContainersSecurityPolicyResource method. - /// Otherwise you can get one from its parent resource using the GetApplicationGatewayForContainersSecurityPolicy method. + /// A class representing a ApplicationGatewayForContainersSecurityPolicy 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 GetApplicationGatewayForContainersSecurityPolicies method. /// public partial class ApplicationGatewayForContainersSecurityPolicyResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The trafficControllerName. - /// The securityPolicyName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics; - private readonly SecurityPoliciesInterfaceRestOperations _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient; + private readonly ClientDiagnostics _securityPoliciesInterfaceClientDiagnostics; + private readonly SecurityPoliciesInterface _securityPoliciesInterfaceRestClient; private readonly ApplicationGatewayForContainersSecurityPolicyData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.ServiceNetworking/trafficControllers/securityPolicies"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of ApplicationGatewayForContainersSecurityPolicyResource for mocking. protected ApplicationGatewayForContainersSecurityPolicyResource() { } - /// 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 ApplicationGatewayForContainersSecurityPolicyResource(ArmClient client, ApplicationGatewayForContainersSecurityPolicyData data) : this(client, data.Id) @@ -56,71 +46,93 @@ internal ApplicationGatewayForContainersSecurityPolicyResource(ArmClient client, _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 ApplicationGatewayForContainersSecurityPolicyResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceApiVersion); - _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient = new SecurityPoliciesInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string applicationGatewayForContainersSecurityPolicyApiVersion); + _securityPoliciesInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); + _securityPoliciesInterfaceRestClient = new SecurityPoliciesInterface(_securityPoliciesInterfaceClientDiagnostics, Pipeline, Endpoint, applicationGatewayForContainersSecurityPolicyApiVersion ?? "2025-03-01-preview"); + 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 ApplicationGatewayForContainersSecurityPolicyData 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 trafficControllerName. + /// The securityPolicyName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}"; + 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); + } } /// /// Get a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Get + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Get"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Get"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +146,41 @@ public virtual async Task /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Get + /// Operation Id. + /// SecurityPoliciesInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Get"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Get"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,39 +191,49 @@ public virtual Response G } /// - /// Delete a SecurityPolicy + /// Update a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Delete + /// Operation Id. + /// SecurityPoliciesInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) { - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Update"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ApplicationGatewayForContainersSecurityPolicyPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -213,39 +243,49 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a SecurityPolicy + /// Update a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Delete + /// Operation Id. + /// SecurityPoliciesInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Update(ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) { - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Update"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics, Pipeline, _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, ApplicationGatewayForContainersSecurityPolicyPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -255,39 +295,46 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a SecurityPolicy + /// Delete a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Update + /// Operation Id. + /// SecurityPoliciesInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual async Task> UpdateAsync(ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Update"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Delete"); scope.Start(); try { - var response = await _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_securityPoliciesInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -297,39 +344,46 @@ public virtual async Task - /// Update a SecurityPolicy + /// Delete a SecurityPolicy /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName}. /// /// - /// Operation Id - /// SecurityPolicy_Update + /// Operation Id. + /// SecurityPoliciesInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual Response Update(ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Update"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.Delete"); scope.Start(); try { - var response = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_securityPoliciesInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -338,27 +392,7 @@ public virtual Response U } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -368,29 +402,35 @@ public virtual async Task 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 _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); - foreach (var tag in current.Tags) + ApplicationGatewayForContainersSecurityPolicyData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + 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) @@ -400,27 +440,7 @@ public virtual async Task - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -430,29 +450,35 @@ public virtual Response A Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.AddTag"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.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 = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); - foreach (var tag in current.Tags) + ApplicationGatewayForContainersSecurityPolicyData current = Get(cancellationToken: cancellationToken).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + 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) @@ -462,54 +488,40 @@ public virtual Response A } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.SetTags"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.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 _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + ApplicationGatewayForContainersSecurityPolicyData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); 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) @@ -519,54 +531,40 @@ public virtual async Task - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.SetTags"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.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 = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + ApplicationGatewayForContainersSecurityPolicyData current = Get(cancellationToken: cancellationToken).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); 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) @@ -576,27 +574,7 @@ public virtual Response S } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -604,29 +582,35 @@ public virtual async Task 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 _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); - foreach (var tag in current.Tags) + ApplicationGatewayForContainersSecurityPolicyData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + 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) @@ -636,27 +620,7 @@ public virtual async Task - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -664,29 +628,35 @@ public virtual Response R { Argument.AssertNotNull(key, nameof(key)); - using var scope = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.RemoveTag"); + using DiagnosticScope scope = _securityPoliciesInterfaceClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyResource.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 = _applicationGatewayForContainersSecurityPolicySecurityPoliciesInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _securityPoliciesInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(ApplicationGatewayForContainersSecurityPolicyData.FromResponse(result), result); + return Response.FromValue(new ApplicationGatewayForContainersSecurityPolicyResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); - foreach (var tag in current.Tags) + ApplicationGatewayForContainersSecurityPolicyData current = Get(cancellationToken: cancellationToken).Value.Data; + ApplicationGatewayForContainersSecurityPolicyPatch patch = new ApplicationGatewayForContainersSecurityPolicyPatch(); + 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) diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ArmServiceNetworkingModelFactory.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ArmServiceNetworkingModelFactory.cs index f62c238576c1..8cf30843dce7 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ArmServiceNetworkingModelFactory.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ArmServiceNetworkingModelFactory.cs @@ -7,111 +7,121 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmServiceNetworkingModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + + /// Resource tags. /// Association Type. - /// Association Subnet. - /// Provisioning State of Traffic Controller Association Resource. - /// A new instance for mocking. - public static TrafficControllerAssociationData TrafficControllerAssociationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, TrafficControllerAssociationType? associationType = null, ResourceIdentifier subnetId = null, ServiceNetworkingProvisioningState? provisioningState = null) + /// Association ID. + /// A new instance for mocking. + public static TrafficControllerAssociationPatch TrafficControllerAssociationPatch(IDictionary tags = default, TrafficControllerAssociationType? associationType = default, ResourceIdentifier subnetId = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); - return new TrafficControllerAssociationData( - id, - name, - resourceType, - systemData, - tags, - location, - associationType, - subnetId != null ? ResourceManagerModelFactory.WritableSubResource(subnetId) : null, - provisioningState, - serializedAdditionalRawData: null); + return new TrafficControllerAssociationPatch(tags, associationType is null && subnetId is null ? default : new AssociationUpdateProperties(associationType, new AssociationSubnetUpdate(subnetId, null), null), additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. /// Frontend Security Policy Configuration. /// Provisioning State of Traffic Controller Frontend Resource. /// A new instance for mocking. - public static TrafficControllerFrontendData TrafficControllerFrontendData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string fqdn = null, SecurityPolicyConfigurations securityPolicyConfigurations = null, ServiceNetworkingProvisioningState? provisioningState = null) + public static TrafficControllerFrontendData TrafficControllerFrontendData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, string fqdn = default, SecurityPolicyConfigurations securityPolicyConfigurations = default, ServiceNetworkingProvisioningState? provisioningState = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new TrafficControllerFrontendData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - fqdn, - securityPolicyConfigurations, - provisioningState, - serializedAdditionalRawData: null); + fqdn is null && securityPolicyConfigurations is null && provisioningState is null ? default : new FrontendProperties(fqdn, securityPolicyConfigurations, provisioningState, null)); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Resource tags. + /// Frontend Security Policy Configuration. + /// A new instance for mocking. + public static TrafficControllerFrontendPatch TrafficControllerFrontendPatch(IDictionary tags = default, SecurityPolicyConfigurations frontendUpdateSecurityPolicyConfigurations = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new TrafficControllerFrontendPatch(tags, frontendUpdateSecurityPolicyConfigurations is null ? default : new FrontendUpdateProperties(frontendUpdateSecurityPolicyConfigurations, null), additionalBinaryDataProperties: null); + } + + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// Type of the Traffic Controller Security Policy. - /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. /// Provisioning State of Traffic Controller SecurityPolicy Resource. + /// Resource ID of the WAF. + /// Ip Access Policy Rules List. /// A new instance for mocking. - public static ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ApplicationGatewayForContainersSecurityPolicyType? policyType = null, ResourceIdentifier wafPolicyId = null, IEnumerable rules = null, ServiceNetworkingProvisioningState? provisioningState = null) + public static ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, ApplicationGatewayForContainersSecurityPolicyType? policyType = default, ServiceNetworkingProvisioningState? provisioningState = default, ResourceIdentifier wafPolicyId = default, IEnumerable rules = default) { - tags ??= new Dictionary(); - rules ??= new List(); + tags ??= new ChangeTrackingDictionary(); return new ApplicationGatewayForContainersSecurityPolicyData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - policyType, - wafPolicyId != null ? ResourceManagerModelFactory.WritableSubResource(wafPolicyId) : null, - rules != null ? new IPAccessRulesPolicy(rules?.ToList(), serializedAdditionalRawData: null) : null, - provisioningState, - serializedAdditionalRawData: null); + policyType is null && provisioningState is null && wafPolicyId is null && rules is null ? default : new SecurityPolicyProperties(policyType, new WafPolicy(wafPolicyId, null), new ServiceNetworkingIPAccessRulesPolicy((rules ?? new ChangeTrackingList()).ToList(), null), provisioningState, null)); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Ip Access Policy Rules. + /// Name of the Ip Access Rule. + /// The priority of the rule. The value can be between 1 and 500. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule. + /// Source Address Prefixed Applied by the Rule. Asterisk '*' can also be used to match all source IPs. + /// Action of the Rule. + /// A new instance for mocking. + public static ServiceNetworkingIPAccessRule ServiceNetworkingIPAccessRule(string name = default, int priority = default, IEnumerable sourceAddressPrefixes = default, ServiceNetworkingIPAccessRuleAction action = default) + { + sourceAddressPrefixes ??= new ChangeTrackingList(); + + return new ServiceNetworkingIPAccessRule(name, priority, sourceAddressPrefixes.ToList(), action, additionalBinaryDataProperties: null); + } + + /// The type used for update operations of the SecurityPolicy. + /// Resource tags. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static ApplicationGatewayForContainersSecurityPolicyPatch ApplicationGatewayForContainersSecurityPolicyPatch(IDictionary tags = default, SecurityPolicyUpdateProperties properties = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new ApplicationGatewayForContainersSecurityPolicyPatch(tags, properties, additionalBinaryDataProperties: null); + } + + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Resource tags. + /// The geo-location where the resource lives. /// Configuration Endpoints. /// Frontends References List. /// Associations References List. @@ -119,61 +129,36 @@ public static ApplicationGatewayForContainersSecurityPolicyData ApplicationGatew /// Security Policy Configuration. /// The status of the last operation. /// A new instance for mocking. - public static TrafficControllerData TrafficControllerData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, IEnumerable configurationEndpoints = null, IEnumerable frontends = null, IEnumerable associations = null, IEnumerable securityPolicies = null, SecurityPolicyConfigurations securityPolicyConfigurations = null, ServiceNetworkingProvisioningState? trafficControllerProvisioningState = null) + public static TrafficControllerData TrafficControllerData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, IEnumerable configurationEndpoints = default, IEnumerable frontends = default, IEnumerable associations = default, IEnumerable securityPolicies = default, SecurityPolicyConfigurations securityPolicyConfigurations = default, ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default) { - tags ??= new Dictionary(); - configurationEndpoints ??= new List(); - frontends ??= new List(); - associations ??= new List(); - securityPolicies ??= new List(); + tags ??= new ChangeTrackingDictionary(); return new TrafficControllerData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - configurationEndpoints?.ToList(), - frontends?.ToList(), - associations?.ToList(), - securityPolicies?.ToList(), - securityPolicyConfigurations, - trafficControllerProvisioningState, - serializedAdditionalRawData: null); + configurationEndpoints is null && frontends is null && associations is null && securityPolicies is null && securityPolicyConfigurations is null && trafficControllerProvisioningState is null ? default : new TrafficControllerProperties( + (configurationEndpoints ?? new ChangeTrackingList()).ToList(), + (frontends ?? new ChangeTrackingList()).ToList(), + (associations ?? new ChangeTrackingList()).ToList(), + (securityPolicies ?? new ChangeTrackingList()).ToList(), + securityPolicyConfigurations, + trafficControllerProvisioningState, + null)); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Type of the Traffic Controller Security Policy. - /// Web Application Firewall Policy of the Traffic Controller Security Policy. - /// Provisioning State of Traffic Controller SecurityPolicy Resource. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static ApplicationGatewayForContainersSecurityPolicyData ApplicationGatewayForContainersSecurityPolicyData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ApplicationGatewayForContainersSecurityPolicyType? policyType, ResourceIdentifier wafPolicyId, ServiceNetworkingProvisioningState? provisioningState) + /// Resource tags. + /// Security Policy Configuration. + /// A new instance for mocking. + public static TrafficControllerPatch TrafficControllerPatch(IDictionary tags = default, SecurityPolicyConfigurations trafficControllerUpdateSecurityPolicyConfigurations = default) { - return ApplicationGatewayForContainersSecurityPolicyData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, policyType: policyType, wafPolicyId: wafPolicyId, rules: default, provisioningState: provisioningState); - } + tags ??= new ChangeTrackingDictionary(); - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. - /// Provisioning State of Traffic Controller Frontend Resource. - /// A new instance for mocking. - [EditorBrowsable(EditorBrowsableState.Never)] - public static TrafficControllerFrontendData TrafficControllerFrontendData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string fqdn, ServiceNetworkingProvisioningState? provisioningState) - { - return TrafficControllerFrontendData(id: id, name: name, resourceType: resourceType, systemData: systemData, tags: tags, location: location, fqdn: fqdn, securityPolicyConfigurations: default, provisioningState: provisioningState); + return new TrafficControllerPatch(tags, trafficControllerUpdateSecurityPolicyConfigurations is null ? default : new TrafficControllerUpdateProperties(trafficControllerUpdateSecurityPolicyConfigurations, null), additionalBinaryDataProperties: null); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..1450a6f76b0e --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT : AsyncPageable + { + private readonly AssociationsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AssociationsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT(AssociationsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT 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; + } + AssociationListResult result = AssociationListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerCollectionResultOfT.cs new file mode 100644 index 000000000000..d4149885cdc1 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/AssociationsInterfaceGetByTrafficControllerCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class AssociationsInterfaceGetByTrafficControllerCollectionResultOfT : Pageable + { + private readonly AssociationsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of AssociationsInterfaceGetByTrafficControllerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AssociationsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public AssociationsInterfaceGetByTrafficControllerCollectionResultOfT(AssociationsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of AssociationsInterfaceGetByTrafficControllerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AssociationsInterfaceGetByTrafficControllerCollectionResultOfT 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; + } + AssociationListResult result = AssociationListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..6e8ac5f09b59 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT : AsyncPageable + { + private readonly FrontendsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The FrontendsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT(FrontendsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT 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; + } + FrontendListResult result = FrontendListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerCollectionResultOfT.cs new file mode 100644 index 000000000000..2c2026c9edd9 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/FrontendsInterfaceGetByTrafficControllerCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class FrontendsInterfaceGetByTrafficControllerCollectionResultOfT : Pageable + { + private readonly FrontendsInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of FrontendsInterfaceGetByTrafficControllerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The FrontendsInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public FrontendsInterfaceGetByTrafficControllerCollectionResultOfT(FrontendsInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of FrontendsInterfaceGetByTrafficControllerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of FrontendsInterfaceGetByTrafficControllerCollectionResultOfT 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; + } + FrontendListResult result = FrontendListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..a07186dfb297 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT : AsyncPageable + { + private readonly SecurityPoliciesInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SecurityPoliciesInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT(SecurityPoliciesInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SecurityPoliciesInterfaceGetByTrafficControllerAsyncCollectionResultOfT 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; + } + SecurityPolicyListResult result = SecurityPolicyListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT.cs new file mode 100644 index 000000000000..ecfa485a29a4 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// 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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT : Pageable + { + private readonly SecurityPoliciesInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _trafficControllerName; + private readonly RequestContext _context; + + /// Initializes a new instance of SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SecurityPoliciesInterface 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. + /// traffic controller name for path. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT(SecurityPoliciesInterface client, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _trafficControllerName = trafficControllerName; + _context = context; + } + + /// Gets the pages of SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SecurityPoliciesInterfaceGetByTrafficControllerCollectionResultOfT 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; + } + SecurityPolicyListResult result = SecurityPolicyListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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.CreateNextGetByTrafficControllerRequest(nextLink, _subscriptionId, _resourceGroupName, _trafficControllerName, _context) : _client.CreateGetByTrafficControllerRequest(_subscriptionId, _resourceGroupName, _trafficControllerName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("ApplicationGatewayForContainersSecurityPolicyCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..11af76fe0983 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT.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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly TrafficControllerInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TrafficControllerInterface 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 TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT(TrafficControllerInterface client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT 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; + } + TrafficControllerListResult result = TrafficControllerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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("TrafficControllerCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..d327c9e3ca01 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT.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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly TrafficControllerInterface _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TrafficControllerInterface 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 TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT(TrafficControllerInterface client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT 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; + } + TrafficControllerListResult result = TrafficControllerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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("TrafficControllerCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..99e76cd49d89 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT.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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly TrafficControllerInterface _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TrafficControllerInterface 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 TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT(TrafficControllerInterface client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT 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; + } + TrafficControllerListResult result = TrafficControllerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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("MockableServiceNetworkingSubscriptionResource.GetTrafficControllers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..a19b7abc2141 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/CollectionResults/TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT.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.ServiceNetworking.Models; + +namespace Azure.ResourceManager.ServiceNetworking +{ + internal partial class TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly TrafficControllerInterface _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The TrafficControllerInterface 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 TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT(TrafficControllerInterface client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT 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; + } + TrafficControllerListResult result = TrafficControllerListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)result.Value, nextPage?.AbsoluteUri, 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("MockableServiceNetworkingSubscriptionResource.GetTrafficControllers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingArmClient.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingArmClient.cs index d702211170a0..de637aad3698 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingArmClient.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableServiceNetworkingArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableServiceNetworkingArmClient for mocking. protected MockableServiceNetworkingArmClient() { } - /// 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 MockableServiceNetworkingArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableServiceNetworkingArmClient(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 TrafficControllerAssociationResource GetTrafficControllerAssociationResource(ResourceIdentifier id) @@ -46,10 +35,7 @@ public virtual TrafficControllerAssociationResource GetTrafficControllerAssociat return new TrafficControllerAssociationResource(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 TrafficControllerFrontendResource GetTrafficControllerFrontendResource(ResourceIdentifier id) @@ -58,10 +44,7 @@ public virtual TrafficControllerFrontendResource GetTrafficControllerFrontendRes return new TrafficControllerFrontendResource(Client, id); } - /// - /// Gets an object representing an along with the instance operations that can be performed on it but with no data. - /// You can use to create an 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 ApplicationGatewayForContainersSecurityPolicyResource GetApplicationGatewayForContainersSecurityPolicyResource(ResourceIdentifier id) @@ -70,10 +53,7 @@ public virtual ApplicationGatewayForContainersSecurityPolicyResource GetApplicat return new ApplicationGatewayForContainersSecurityPolicyResource(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 TrafficControllerResource GetTrafficControllerResource(ResourceIdentifier id) diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingResourceGroupResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingResourceGroupResource.cs index 5d3da1e5fdb4..880382012773 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingResourceGroupResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingResourceGroupResource.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.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableServiceNetworkingResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableServiceNetworkingResourceGroupResource for mocking. protected MockableServiceNetworkingResourceGroupResource() { } - /// 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 MockableServiceNetworkingResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of TrafficControllerResources in the ResourceGroupResource. - /// An object representing collection of TrafficControllerResources and their operations over a TrafficControllerResource. + /// Gets a collection of TrafficControllers in the . + /// An object representing collection of TrafficControllers and their operations over a TrafficControllerResource. public virtual TrafficControllerCollection GetTrafficControllers() { return GetCachedClient(client => new TrafficControllerCollection(client, Id)); @@ -44,20 +42,16 @@ public virtual TrafficControllerCollection GetTrafficControllers() /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -68,6 +62,8 @@ public virtual TrafficControllerCollection GetTrafficControllers() [ForwardsClientCalls] public virtual async Task> GetTrafficControllerAsync(string trafficControllerName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); + return await GetTrafficControllers().GetAsync(trafficControllerName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +71,16 @@ public virtual async Task> GetTrafficControl /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -99,6 +91,8 @@ public virtual async Task> GetTrafficControl [ForwardsClientCalls] public virtual Response GetTrafficController(string trafficControllerName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); + return GetTrafficControllers().Get(trafficControllerName, cancellationToken); } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingSubscriptionResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingSubscriptionResource.cs index ae9777a643f7..03126838489f 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingSubscriptionResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/MockableServiceNetworkingSubscriptionResource.cs @@ -6,87 +6,79 @@ #nullable disable using System.Threading; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableServiceNetworkingSubscriptionResource : ArmResource { - private ClientDiagnostics _trafficControllerTrafficControllerInterfaceClientDiagnostics; - private TrafficControllerInterfaceRestOperations _trafficControllerTrafficControllerInterfaceRestClient; + private ClientDiagnostics _trafficControllerInterfaceClientDiagnostics; + private TrafficControllerInterface _trafficControllerInterfaceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableServiceNetworkingSubscriptionResource for mocking. protected MockableServiceNetworkingSubscriptionResource() { } - /// 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 MockableServiceNetworkingSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics TrafficControllerTrafficControllerInterfaceClientDiagnostics => _trafficControllerTrafficControllerInterfaceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerResource.ResourceType.Namespace, Diagnostics); - private TrafficControllerInterfaceRestOperations TrafficControllerTrafficControllerInterfaceRestClient => _trafficControllerTrafficControllerInterfaceRestClient ??= new TrafficControllerInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(TrafficControllerResource.ResourceType)); + private ClientDiagnostics TrafficControllerInterfaceClientDiagnostics => _trafficControllerInterfaceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private TrafficControllerInterface TrafficControllerInterfaceRestClient => _trafficControllerInterfaceRestClient ??= new TrafficControllerInterface(TrafficControllerInterfaceClientDiagnostics, Pipeline, Endpoint, "2025-03-01-preview"); /// /// List TrafficController resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers - /// - /// - /// Operation Id - /// TrafficController_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// 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 GetTrafficControllersAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => TrafficControllerTrafficControllerInterfaceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TrafficControllerTrafficControllerInterfaceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerResource(Client, TrafficControllerData.DeserializeTrafficControllerData(e)), TrafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, "MockableServiceNetworkingSubscriptionResource.GetTrafficControllers", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TrafficControllerInterfaceGetBySubscriptionAsyncCollectionResultOfT(TrafficControllerInterfaceRestClient, Id.SubscriptionId, context), data => new TrafficControllerResource(Client, data)); } /// /// List TrafficController resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers - /// - /// - /// Operation Id - /// TrafficController_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -94,9 +86,11 @@ public virtual AsyncPageable GetTrafficControllersAsy /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetTrafficControllers(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => TrafficControllerTrafficControllerInterfaceRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => TrafficControllerTrafficControllerInterfaceRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerResource(Client, TrafficControllerData.DeserializeTrafficControllerData(e)), TrafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, "MockableServiceNetworkingSubscriptionResource.GetTrafficControllers", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TrafficControllerInterfaceGetBySubscriptionCollectionResultOfT(TrafficControllerInterfaceRestClient, Id.SubscriptionId, context), data => new TrafficControllerResource(Client, data)); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/ServiceNetworkingExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/ServiceNetworkingExtensions.cs index 15863156005f..9e109bf1946d 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/ServiceNetworkingExtensions.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Extensions/ServiceNetworkingExtensions.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.ServiceNetworking.Mocking; @@ -17,30 +19,32 @@ namespace Azure.ResourceManager.ServiceNetworking /// A class to add extension methods to Azure.ResourceManager.ServiceNetworking. public static partial class ServiceNetworkingExtensions { + /// private static MockableServiceNetworkingArmClient GetMockableServiceNetworkingArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableServiceNetworkingArmClient(client0)); + return client.GetCachedClient(client0 => new MockableServiceNetworkingArmClient(client0, ResourceIdentifier.Root)); } - private static MockableServiceNetworkingResourceGroupResource GetMockableServiceNetworkingResourceGroupResource(ArmResource resource) + /// + private static MockableServiceNetworkingResourceGroupResource GetMockableServiceNetworkingResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableServiceNetworkingResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableServiceNetworkingResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableServiceNetworkingSubscriptionResource GetMockableServiceNetworkingSubscriptionResource(ArmResource resource) + /// + private static MockableServiceNetworkingSubscriptionResource GetMockableServiceNetworkingSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableServiceNetworkingSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableServiceNetworkingSubscriptionResource(client, subscriptionResource.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. @@ -52,14 +56,13 @@ public static TrafficControllerAssociationResource GetTrafficControllerAssociati } /// - /// 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. @@ -71,14 +74,13 @@ public static TrafficControllerFrontendResource GetTrafficControllerFrontendReso } /// - /// Gets an object representing an along with the instance operations that can be performed on it but with no data. - /// You can use to create an 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. @@ -90,14 +92,13 @@ public static ApplicationGatewayForContainersSecurityPolicyResource GetApplicati } /// - /// 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. @@ -109,15 +110,15 @@ public static TrafficControllerResource GetTrafficControllerResource(this ArmCli } /// - /// Gets a collection of TrafficControllerResources in the ResourceGroupResource. + /// Gets a collection of TrafficControllers 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 TrafficControllerResources and their operations over a TrafficControllerResource. + /// An object representing collection of TrafficControllers and their operations over a TrafficControllerResource. public static TrafficControllerCollection GetTrafficControllers(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -127,34 +128,15 @@ public static TrafficControllerCollection GetTrafficControllers(this ResourceGro /// /// Get a TrafficController - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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. /// traffic controller name for path. /// 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> GetTrafficControllerAsync(this ResourceGroupResource resourceGroupResource, string trafficControllerName, CancellationToken cancellationToken = default) { @@ -165,34 +147,15 @@ public static async Task> GetTrafficControll /// /// Get a TrafficController - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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. /// traffic controller name for path. /// 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 GetTrafficController(this ResourceGroupResource resourceGroupResource, string trafficControllerName, CancellationToken cancellationToken = default) { @@ -203,33 +166,15 @@ public static Response GetTrafficController(this Reso /// /// List TrafficController resources by subscription ID - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers - /// - /// - /// Operation Id - /// TrafficController_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-03-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. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetTrafficControllersAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -239,30 +184,12 @@ public static AsyncPageable GetTrafficControllersAsyn /// /// List TrafficController resources by subscription ID - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.ServiceNetworking/trafficControllers - /// - /// - /// Operation Id - /// TrafficController_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-03-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. /// A collection of that may take multiple service requests to iterate over. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Argument.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Argument.cs index 02af73aa2535..8521132cdd81 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Argument.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..d79f4162e334 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingDictionary.cs index 841b3f9692e6..79da65c10671 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingList.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingList.cs index 5f375910ebc7..80e86e72beb8 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..7cd80a22be56 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ErrorResult.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..c9b553932ded --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ModelSerializationExtensions.cs index b9d675f651d6..a54e893377dd 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Optional.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Optional.cs index ed9dfaa52df5..15e4546032dd 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Optional.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/PageableWrapper.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..1eb2242483bc --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..9b10d3f0ad1e --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// 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.ServiceNetworking +{ + 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); + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/RequestContextExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..82cd683ddde7 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/SerializationFormat.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..05301e7de26f --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/TypeFormatters.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..7a777f2ae4a0 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/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.ServiceNetworking +{ + 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Utf8JsonRequestContent.cs index 1d7af39949ba..4660f49fd191 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ApplicationGatewayForContainersSecurityPolicyOperationSource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ApplicationGatewayForContainersSecurityPolicyOperationSource.cs index 662f1deff84b..470889dd0c44 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ApplicationGatewayForContainersSecurityPolicyOperationSource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ApplicationGatewayForContainersSecurityPolicyOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.ServiceNetworking { - internal class ApplicationGatewayForContainersSecurityPolicyOperationSource : IOperationSource + /// + internal partial class ApplicationGatewayForContainersSecurityPolicyOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal ApplicationGatewayForContainersSecurityPolicyOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// ApplicationGatewayForContainersSecurityPolicyResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + ApplicationGatewayForContainersSecurityPolicyData data = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement, ModelSerializationExtensions.WireOptions); return new ApplicationGatewayForContainersSecurityPolicyResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); - return await Task.FromResult(new ApplicationGatewayForContainersSecurityPolicyResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + ApplicationGatewayForContainersSecurityPolicyData data = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new ApplicationGatewayForContainersSecurityPolicyResource(_client, data); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperation.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperation.cs index b0410c794780..a888af284af0 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperation.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperation.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.ServiceNetworking { -#pragma warning disable SA1649 // File name should match first type name - internal class ServiceNetworkingArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class ServiceNetworkingArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected ServiceNetworkingArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal ServiceNetworkingArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal ServiceNetworkingArmOperation(Response response, RehydrationToken? rehy _operationId = GetOperationId(rehydrationToken); } + /// + /// 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 ServiceNetworkingArmOperation(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,48 +58,49 @@ internal ServiceNetworkingArmOperation(ClientDiagnostics clientDiagnostics, Http _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "ServiceNetworkingArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "ServiceNetworkingArmOperation", + null, + new SequentialDelayStrategy()); } + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. private string GetOperationId(RehydrationToken? rehydrationToken) { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); + return rehydrationToken?.Id; } - /// - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperationOfT.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperationOfT.cs index 8514bfee19b4..7785874c4184 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperationOfT.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/ServiceNetworkingArmOperationOfT.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.ServiceNetworking { -#pragma warning disable SA1649 // File name should match first type name - internal class ServiceNetworkingArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class ServiceNetworkingArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected ServiceNetworkingArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal ServiceNetworkingArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal ServiceNetworkingArmOperation(Response response, RehydrationToken? r _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 ServiceNetworkingArmOperation(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 ServiceNetworkingArmOperation(IOperationSource source, ClientDiagnos _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "ServiceNetworkingArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "ServiceNetworkingArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerAssociationOperationSource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerAssociationOperationSource.cs index d374a6c4818a..36a435bcc7ac 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerAssociationOperationSource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerAssociationOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.ServiceNetworking { - internal class TrafficControllerAssociationOperationSource : IOperationSource + /// + internal partial class TrafficControllerAssociationOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal TrafficControllerAssociationOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// TrafficControllerAssociationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + TrafficControllerAssociationData data = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement, ModelSerializationExtensions.WireOptions); return new TrafficControllerAssociationResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); - return await Task.FromResult(new TrafficControllerAssociationResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + TrafficControllerAssociationData data = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TrafficControllerAssociationResource(_client, data); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerFrontendOperationSource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerFrontendOperationSource.cs index 9471fbf47542..3097e219e628 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerFrontendOperationSource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerFrontendOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.ServiceNetworking { - internal class TrafficControllerFrontendOperationSource : IOperationSource + /// + internal partial class TrafficControllerFrontendOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal TrafficControllerFrontendOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// TrafficControllerFrontendResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + TrafficControllerFrontendData data = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement, ModelSerializationExtensions.WireOptions); return new TrafficControllerFrontendResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); - return await Task.FromResult(new TrafficControllerFrontendResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + TrafficControllerFrontendData data = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TrafficControllerFrontendResource(_client, data); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerOperationSource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerOperationSource.cs index d759b0fe9c71..25c8562664e8 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerOperationSource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/LongRunningOperation/TrafficControllerOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.ServiceNetworking { - internal class TrafficControllerOperationSource : IOperationSource + /// + internal partial class TrafficControllerOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal TrafficControllerOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// TrafficControllerResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + TrafficControllerData data = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement, ModelSerializationExtensions.WireOptions); return new TrafficControllerResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerServiceNetworkingContext.Default); - return await Task.FromResult(new TrafficControllerResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + TrafficControllerData data = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new TrafficControllerResource(_client, data); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.Serialization.cs index 34de6b91c356..717a2e60dd9a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class ApplicationGatewayForContainersSecurityPolicyPatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the SecurityPolicy. + public partial class ApplicationGatewayForContainersSecurityPolicyPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8Js /// 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(ApplicationGatewayForContainersSecurityPolicyPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,6 +42,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -50,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - 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,68 +73,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ApplicationGatewayForContainersSecurityPolicyPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ApplicationGatewayForContainersSecurityPolicyPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ApplicationGatewayForContainersSecurityPolicyPatch 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(ApplicationGatewayForContainersSecurityPolicyPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeApplicationGatewayForContainersSecurityPolicyPatch(document.RootElement, options); } - internal static ApplicationGatewayForContainersSecurityPolicyPatch DeserializeApplicationGatewayForContainersSecurityPolicyPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ApplicationGatewayForContainersSecurityPolicyPatch DeserializeApplicationGatewayForContainersSecurityPolicyPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; SecurityPolicyUpdateProperties properties = 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("tags"u8)) + if (prop.NameEquals("tags"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()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + 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("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = SecurityPolicyUpdateProperties.DeserializeSecurityPolicyUpdateProperties(property.Value, options); + properties = SecurityPolicyUpdateProperties.DeserializeSecurityPolicyUpdateProperties(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 ApplicationGatewayForContainersSecurityPolicyPatch(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new ApplicationGatewayForContainersSecurityPolicyPatch(tags ?? new ChangeTrackingDictionary(), properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -138,15 +157,20 @@ BinaryData IPersistableModel } } - ApplicationGatewayForContainersSecurityPolicyPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ApplicationGatewayForContainersSecurityPolicyPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ApplicationGatewayForContainersSecurityPolicyPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeApplicationGatewayForContainersSecurityPolicyPatch(document.RootElement, options); } default: @@ -154,6 +178,19 @@ ApplicationGatewayForContainersSecurityPolicyPatch IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(ApplicationGatewayForContainersSecurityPolicyPatch applicationGatewayForContainersSecurityPolicyPatch) + { + if (applicationGatewayForContainersSecurityPolicyPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(applicationGatewayForContainersSecurityPolicyPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.cs index 0f3ce11356b0..0613276d32df 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The type used for update operations of the SecurityPolicy. public partial class ApplicationGatewayForContainersSecurityPolicyPatch { - /// - /// 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 ApplicationGatewayForContainersSecurityPolicyPatch() @@ -54,16 +26,17 @@ public ApplicationGatewayForContainersSecurityPolicyPatch() /// Initializes a new instance of . /// Resource tags. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal ApplicationGatewayForContainersSecurityPolicyPatch(IDictionary tags, SecurityPolicyUpdateProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ApplicationGatewayForContainersSecurityPolicyPatch(IDictionary tags, SecurityPolicyUpdateProperties properties, IDictionary additionalBinaryDataProperties) { Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Resource tags. public IDictionary Tags { get; } + /// The resource-specific properties for this resource. public SecurityPolicyUpdateProperties Properties { get; set; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyType.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyType.cs index 2ea28087e940..8559fe903af6 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyType.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ApplicationGatewayForContainersSecurityPolicyType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.ServiceNetworking.Models public readonly partial struct ApplicationGatewayForContainersSecurityPolicyType : IEquatable { private readonly string _value; + /// Policy of Type WAF. + private const string WAFValue = "waf"; + /// Policy of Type IpAccessRules. + private const string IPAccessRulesValue = "ipAccessRules"; /// Initializes a new instance of . + /// The value. /// is null. public ApplicationGatewayForContainersSecurityPolicyType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string WAFValue = "waf"; - private const string IPAccessRulesValue = "ipAccessRules"; + _value = value; + } /// Policy of Type WAF. public static ApplicationGatewayForContainersSecurityPolicyType WAF { get; } = new ApplicationGatewayForContainersSecurityPolicyType(WAFValue); + /// Policy of Type IpAccessRules. public static ApplicationGatewayForContainersSecurityPolicyType IPAccessRules { get; } = new ApplicationGatewayForContainersSecurityPolicyType(IPAccessRulesValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ApplicationGatewayForContainersSecurityPolicyType left, ApplicationGatewayForContainersSecurityPolicyType 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 !=(ApplicationGatewayForContainersSecurityPolicyType left, ApplicationGatewayForContainersSecurityPolicyType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ApplicationGatewayForContainersSecurityPolicyType(string value) => new ApplicationGatewayForContainersSecurityPolicyType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ApplicationGatewayForContainersSecurityPolicyType?(string value) => value == null ? null : new ApplicationGatewayForContainersSecurityPolicyType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ApplicationGatewayForContainersSecurityPolicyType other && Equals(other); - /// + + /// public bool Equals(ApplicationGatewayForContainersSecurityPolicyType 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.Serialization.cs index 708d672dc437..e8ba26b4506b 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class AssociationListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a Association list operation. + internal partial class AssociationListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal AssociationListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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(AssociationListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (TrafficControllerAssociationData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AssociationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AssociationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AssociationListResult 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(AssociationListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAssociationListResult(document.RootElement, options); } - internal static AssociationListResult DeserializeAssociationListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AssociationListResult DeserializeAssociationListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(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 AssociationListResult(value, nextLink, serializedAdditionalRawData); + return new AssociationListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - AssociationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + AssociationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AssociationListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAssociationListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ AssociationListResult IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AssociationListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssociationListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.cs index f2998a530bee..d7768a4c0f66 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The response of a Association list operation. internal partial class AssociationListResult { - /// - /// 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 Association items on this page. - /// is null. internal AssociationListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The Association items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal AssociationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AssociationListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AssociationListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Association items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.Serialization.cs new file mode 100644 index 000000000000..d4f641b757d0 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.Serialization.cs @@ -0,0 +1,172 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + internal partial class AssociationProperties : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AssociationProperties() + { + } + + /// 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(AssociationProperties)} does not support writing '{format}' format."); + } + writer.WritePropertyName("associationType"u8); + writer.WriteStringValue(AssociationType.Value.ToString()); + if (Optional.IsDefined(Subnet)) + { + writer.WritePropertyName("subnet"u8); + writer.WriteObjectValue(Subnet, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.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. + AssociationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AssociationProperties 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(AssociationProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssociationProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AssociationProperties DeserializeAssociationProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TrafficControllerAssociationType? associationType = default; + AssociationSubnet subnet = default; + ServiceNetworkingProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("associationType"u8)) + { + associationType = new TrafficControllerAssociationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("subnet"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subnet = AssociationSubnet.DeserializeAssociationSubnet(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ServiceNetworkingProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AssociationProperties(associationType, subnet, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(AssociationProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AssociationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AssociationProperties 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 DeserializeAssociationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssociationProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.cs new file mode 100644 index 000000000000..20dcb90fad36 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationProperties.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + internal partial class AssociationProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Association Type. + public AssociationProperties(TrafficControllerAssociationType? associationType) + { + AssociationType = associationType; + } + + /// Initializes a new instance of . + /// Association Type. + /// Association Subnet. + /// Provisioning State of Traffic Controller Association Resource. + /// Keeps track of any properties unknown to the library. + internal AssociationProperties(TrafficControllerAssociationType? associationType, AssociationSubnet subnet, ServiceNetworkingProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + AssociationType = associationType; + Subnet = subnet; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Association Subnet. + internal AssociationSubnet Subnet { get; set; } + + /// Provisioning State of Traffic Controller Association Resource. + public ServiceNetworkingProvisioningState? ProvisioningState { get; } + + /// Association ID. + public ResourceIdentifier SubnetId + { + get + { + return Subnet is null ? default : Subnet.Id; + } + set + { + Subnet = new AssociationSubnet(value); + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.Serialization.cs new file mode 100644 index 000000000000..c685940976cb --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.Serialization.cs @@ -0,0 +1,144 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Association Subnet. + internal partial class AssociationSubnet : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AssociationSubnet() + { + } + + /// 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(AssociationSubnet)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + 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. + AssociationSubnet IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AssociationSubnet 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(AssociationSubnet)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssociationSubnet(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AssociationSubnet DeserializeAssociationSubnet(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AssociationSubnet(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(AssociationSubnet)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AssociationSubnet IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AssociationSubnet 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 DeserializeAssociationSubnet(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssociationSubnet)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.cs new file mode 100644 index 000000000000..c2c6616404dc --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnet.cs @@ -0,0 +1,43 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Association Subnet. + internal partial class AssociationSubnet + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Association ID. + /// is null. + public AssociationSubnet(ResourceIdentifier id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// Association ID. + /// Keeps track of any properties unknown to the library. + internal AssociationSubnet(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Association ID. + public ResourceIdentifier Id { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.Serialization.cs new file mode 100644 index 000000000000..7c8dd145ae1b --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.Serialization.cs @@ -0,0 +1,146 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Association Subnet. + internal partial class AssociationSubnetUpdate : IJsonModel + { + /// 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(AssociationSubnetUpdate)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + 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. + AssociationSubnetUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AssociationSubnetUpdate 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(AssociationSubnetUpdate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssociationSubnetUpdate(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AssociationSubnetUpdate DeserializeAssociationSubnetUpdate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AssociationSubnetUpdate(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(AssociationSubnetUpdate)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AssociationSubnetUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AssociationSubnetUpdate 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 DeserializeAssociationSubnetUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssociationSubnetUpdate)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.cs new file mode 100644 index 000000000000..17b0719fc578 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationSubnetUpdate.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Association Subnet. + internal partial class AssociationSubnetUpdate + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AssociationSubnetUpdate() + { + } + + /// Initializes a new instance of . + /// Association ID. + /// Keeps track of any properties unknown to the library. + internal AssociationSubnetUpdate(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Association ID. + public ResourceIdentifier Id { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.Serialization.cs new file mode 100644 index 000000000000..74ce9d2edd50 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.Serialization.cs @@ -0,0 +1,160 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// The updatable properties of the Association. + internal partial class AssociationUpdateProperties : IJsonModel + { + /// 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(AssociationUpdateProperties)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(AssociationType)) + { + writer.WritePropertyName("associationType"u8); + writer.WriteStringValue(AssociationType.Value.ToString()); + } + if (Optional.IsDefined(Subnet)) + { + writer.WritePropertyName("subnet"u8); + writer.WriteObjectValue(Subnet, 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. + AssociationUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AssociationUpdateProperties 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(AssociationUpdateProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssociationUpdateProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AssociationUpdateProperties DeserializeAssociationUpdateProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TrafficControllerAssociationType? associationType = default; + AssociationSubnetUpdate subnet = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("associationType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + associationType = new TrafficControllerAssociationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("subnet"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subnet = AssociationSubnetUpdate.DeserializeAssociationSubnetUpdate(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AssociationUpdateProperties(associationType, subnet, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(AssociationUpdateProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AssociationUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AssociationUpdateProperties 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 DeserializeAssociationUpdateProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssociationUpdateProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.cs new file mode 100644 index 000000000000..994145fe7ce2 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AssociationUpdateProperties.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// The updatable properties of the Association. + internal partial class AssociationUpdateProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AssociationUpdateProperties() + { + } + + /// Initializes a new instance of . + /// Association Type. + /// Association Subnet. + /// Keeps track of any properties unknown to the library. + internal AssociationUpdateProperties(TrafficControllerAssociationType? associationType, AssociationSubnetUpdate subnet, IDictionary additionalBinaryDataProperties) + { + AssociationType = associationType; + Subnet = subnet; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Association Type. + public TrafficControllerAssociationType? AssociationType { get; set; } + + /// Association Subnet. + internal AssociationSubnetUpdate Subnet { get; set; } + + /// Association ID. + public ResourceIdentifier SubnetId + { + get + { + return Subnet is null ? default : Subnet.Id; + } + set + { + if (Subnet is null) + { + Subnet = new AssociationSubnetUpdate(); + } + Subnet.Id = value; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AzureResourceManagerServiceNetworkingContext.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AzureResourceManagerServiceNetworkingContext.cs index cbe14658065f..dda32e86b76d 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AzureResourceManagerServiceNetworkingContext.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/AzureResourceManagerServiceNetworkingContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; @@ -14,20 +15,27 @@ namespace Azure.ResourceManager.ServiceNetworking { /// /// 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(ApplicationGatewayForContainersSecurityPolicyData))] [ModelReaderWriterBuildable(typeof(ApplicationGatewayForContainersSecurityPolicyPatch))] [ModelReaderWriterBuildable(typeof(ApplicationGatewayForContainersSecurityPolicyResource))] [ModelReaderWriterBuildable(typeof(AssociationListResult))] + [ModelReaderWriterBuildable(typeof(AssociationProperties))] + [ModelReaderWriterBuildable(typeof(AssociationSubnet))] + [ModelReaderWriterBuildable(typeof(AssociationSubnetUpdate))] + [ModelReaderWriterBuildable(typeof(AssociationUpdateProperties))] [ModelReaderWriterBuildable(typeof(FrontendListResult))] + [ModelReaderWriterBuildable(typeof(FrontendProperties))] [ModelReaderWriterBuildable(typeof(FrontendUpdateProperties))] - [ModelReaderWriterBuildable(typeof(IPAccessRulesPolicy))] [ModelReaderWriterBuildable(typeof(ResponseError))] [ModelReaderWriterBuildable(typeof(SecurityPolicyConfigurations))] [ModelReaderWriterBuildable(typeof(SecurityPolicyListResult))] + [ModelReaderWriterBuildable(typeof(SecurityPolicyProperties))] [ModelReaderWriterBuildable(typeof(SecurityPolicyUpdateProperties))] [ModelReaderWriterBuildable(typeof(ServiceNetworkingIPAccessRule))] + [ModelReaderWriterBuildable(typeof(ServiceNetworkingIPAccessRulesPolicy))] + [ModelReaderWriterBuildable(typeof(ServiceNetworkingIPAccessRulesSecurityPolicy))] [ModelReaderWriterBuildable(typeof(SubResource))] [ModelReaderWriterBuildable(typeof(SystemData))] [ModelReaderWriterBuildable(typeof(TrafficControllerAssociationData))] @@ -39,9 +47,11 @@ namespace Azure.ResourceManager.ServiceNetworking [ModelReaderWriterBuildable(typeof(TrafficControllerFrontendResource))] [ModelReaderWriterBuildable(typeof(TrafficControllerListResult))] [ModelReaderWriterBuildable(typeof(TrafficControllerPatch))] + [ModelReaderWriterBuildable(typeof(TrafficControllerProperties))] [ModelReaderWriterBuildable(typeof(TrafficControllerResource))] [ModelReaderWriterBuildable(typeof(TrafficControllerUpdateProperties))] - [ModelReaderWriterBuildable(typeof(WritableSubResource))] + [ModelReaderWriterBuildable(typeof(WafPolicy))] + [ModelReaderWriterBuildable(typeof(WafSecurityPolicy))] public partial class AzureResourceManagerServiceNetworkingContext : ModelReaderWriterContext { } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.Serialization.cs index 88d4a8306a5a..167efc7b489f 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class FrontendListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a Frontend list operation. + internal partial class FrontendListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal FrontendListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// 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(FrontendListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (TrafficControllerFrontendData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FrontendListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + FrontendListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FrontendListResult 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(FrontendListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeFrontendListResult(document.RootElement, options); } - internal static FrontendListResult DeserializeFrontendListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FrontendListResult DeserializeFrontendListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(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 FrontendListResult(value, nextLink, serializedAdditionalRawData); + return new FrontendListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - FrontendListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + FrontendListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FrontendListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeFrontendListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ FrontendListResult IPersistableModel.Create(BinaryData data, } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static FrontendListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFrontendListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.cs index 71eadee88e8d..8af15069cd10 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The response of a Frontend list operation. internal partial class FrontendListResult { - /// - /// 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 Frontend items on this page. - /// is null. internal FrontendListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The Frontend items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal FrontendListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal FrontendListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal FrontendListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Frontend items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.Serialization.cs new file mode 100644 index 000000000000..de63eca3a2cc --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.Serialization.cs @@ -0,0 +1,171 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Frontend Properties. + internal partial class FrontendProperties : IJsonModel + { + /// 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(FrontendProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Fqdn)) + { + writer.WritePropertyName("fqdn"u8); + writer.WriteStringValue(Fqdn); + } + if (Optional.IsDefined(SecurityPolicyConfigurations)) + { + writer.WritePropertyName("securityPolicyConfigurations"u8); + writer.WriteObjectValue(SecurityPolicyConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.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. + FrontendProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FrontendProperties 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(FrontendProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFrontendProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FrontendProperties DeserializeFrontendProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fqdn = default; + SecurityPolicyConfigurations securityPolicyConfigurations = default; + ServiceNetworkingProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("fqdn"u8)) + { + fqdn = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("securityPolicyConfigurations"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ServiceNetworkingProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FrontendProperties(fqdn, securityPolicyConfigurations, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(FrontendProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + FrontendProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FrontendProperties 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 DeserializeFrontendProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FrontendProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.cs new file mode 100644 index 000000000000..758875c59930 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendProperties.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Frontend Properties. + internal partial class FrontendProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public FrontendProperties() + { + } + + /// Initializes a new instance of . + /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. + /// Frontend Security Policy Configuration. + /// Provisioning State of Traffic Controller Frontend Resource. + /// Keeps track of any properties unknown to the library. + internal FrontendProperties(string fqdn, SecurityPolicyConfigurations securityPolicyConfigurations, ServiceNetworkingProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + Fqdn = fqdn; + SecurityPolicyConfigurations = securityPolicyConfigurations; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. + public string Fqdn { get; } + + /// Frontend Security Policy Configuration. + public SecurityPolicyConfigurations SecurityPolicyConfigurations { get; set; } + + /// Provisioning State of Traffic Controller Frontend Resource. + public ServiceNetworkingProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.Serialization.cs index 0cc5da74707f..6d5e25275b9b 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class FrontendUpdateProperties : IUtf8JsonSerializable, IJsonModel + /// The updatable properties of the Frontend. + internal partial class FrontendUpdateProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +29,25 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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(FrontendUpdateProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SecurityPolicyConfigurations)) { writer.WritePropertyName("securityPolicyConfigurations"u8); writer.WriteObjectValue(SecurityPolicyConfigurations, options); } - 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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - FrontendUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + FrontendUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FrontendUpdateProperties 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(FrontendUpdateProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeFrontendUpdateProperties(document.RootElement, options); } - internal static FrontendUpdateProperties DeserializeFrontendUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FrontendUpdateProperties DeserializeFrontendUpdateProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } SecurityPolicyConfigurations securityPolicyConfigurations = 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("securityPolicyConfigurations"u8)) + if (prop.NameEquals("securityPolicyConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(property.Value, options); + securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(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 FrontendUpdateProperties(securityPolicyConfigurations, serializedAdditionalRawData); + return new FrontendUpdateProperties(securityPolicyConfigurations, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - FrontendUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + FrontendUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FrontendUpdateProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeFrontendUpdateProperties(document.RootElement, options); } default: @@ -128,6 +139,7 @@ FrontendUpdateProperties IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.cs index 1abf11b8aab3..e3737dc747e2 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/FrontendUpdateProperties.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.ServiceNetworking.Models /// The updatable properties of the Frontend. internal partial class FrontendUpdateProperties { - /// - /// 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 FrontendUpdateProperties() @@ -52,11 +23,11 @@ public FrontendUpdateProperties() /// Initializes a new instance of . /// Frontend Security Policy Configuration. - /// Keeps track of any properties unknown to the library. - internal FrontendUpdateProperties(SecurityPolicyConfigurations securityPolicyConfigurations, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal FrontendUpdateProperties(SecurityPolicyConfigurations securityPolicyConfigurations, IDictionary additionalBinaryDataProperties) { SecurityPolicyConfigurations = securityPolicyConfigurations; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Frontend Security Policy Configuration. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.Serialization.cs deleted file mode 100644 index cbbfc27c9756..000000000000 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.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.ServiceNetworking.Models -{ - internal partial class IPAccessRulesPolicy : 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(IPAccessRulesPolicy)} does not support writing '{format}' format."); - } - - if (Optional.IsCollectionDefined(Rules)) - { - writer.WritePropertyName("rules"u8); - writer.WriteStartArray(); - foreach (var item in Rules) - { - 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 - } - } - } - - IPAccessRulesPolicy 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(IPAccessRulesPolicy)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeIPAccessRulesPolicy(document.RootElement, options); - } - - internal static IPAccessRulesPolicy DeserializeIPAccessRulesPolicy(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - IList rules = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("rules"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(ServiceNetworkingIPAccessRule.DeserializeServiceNetworkingIPAccessRule(item, options)); - } - rules = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new IPAccessRulesPolicy(rules ?? 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, AzureResourceManagerServiceNetworkingContext.Default); - default: - throw new FormatException($"The model {nameof(IPAccessRulesPolicy)} does not support writing '{options.Format}' format."); - } - } - - IPAccessRulesPolicy 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 DeserializeIPAccessRulesPolicy(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(IPAccessRulesPolicy)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - } -} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.cs deleted file mode 100644 index 6123f3692ffb..000000000000 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/IPAccessRulesPolicy.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.ServiceNetworking.Models -{ - /// Ip Access Policy. - internal partial class IPAccessRulesPolicy - { - /// - /// 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 . - public IPAccessRulesPolicy() - { - Rules = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// Ip Access Policy Rules List. - /// Keeps track of any properties unknown to the library. - internal IPAccessRulesPolicy(IList rules, IDictionary serializedAdditionalRawData) - { - Rules = rules; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Ip Access Policy Rules List. - public IList Rules { get; } - } -} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.Serialization.cs index d243a9d2d10c..52d3bf9b7c0c 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.Serialization.cs @@ -8,17 +8,16 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text; using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class SecurityPolicyConfigurations : IUtf8JsonSerializable, IJsonModel + /// SecurityPolicyConfigurations Subresource of Traffic Controller. + public partial class SecurityPolicyConfigurations : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,31 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(SecurityPolicyConfigurations)} does not support writing '{format}' format."); } - if (Optional.IsDefined(WafSecurityPolicy)) { writer.WritePropertyName("wafSecurityPolicy"u8); - ((IJsonModel)WafSecurityPolicy).Write(writer, options); + writer.WriteObjectValue(WafSecurityPolicy, options); } if (Optional.IsDefined(IPAccessRulesSecurityPolicy)) { writer.WritePropertyName("ipAccessRulesSecurityPolicy"u8); - ((IJsonModel)IPAccessRulesSecurityPolicy).Write(writer, options); + writer.WriteObjectValue(IPAccessRulesSecurityPolicy, options); } - 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); } @@ -63,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SecurityPolicyConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SecurityPolicyConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SecurityPolicyConfigurations 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(SecurityPolicyConfigurations)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSecurityPolicyConfigurations(document.RootElement, options); } - internal static SecurityPolicyConfigurations DeserializeSecurityPolicyConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SecurityPolicyConfigurations DeserializeSecurityPolicyConfigurations(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - WritableSubResource wafSecurityPolicy = default; - WritableSubResource ipAccessRulesSecurityPolicy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + WafSecurityPolicy wafSecurityPolicy = default; + ServiceNetworkingIPAccessRulesSecurityPolicy ipAccessRulesSecurityPolicy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("wafSecurityPolicy"u8)) + if (prop.NameEquals("wafSecurityPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - wafSecurityPolicy = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); + wafSecurityPolicy = WafSecurityPolicy.DeserializeWafSecurityPolicy(prop.Value, options); continue; } - if (property.NameEquals("ipAccessRulesSecurityPolicy"u8)) + if (prop.NameEquals("ipAccessRulesSecurityPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - ipAccessRulesSecurityPolicy = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); + ipAccessRulesSecurityPolicy = ServiceNetworkingIPAccessRulesSecurityPolicy.DeserializeServiceNetworkingIPAccessRulesSecurityPolicy(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 SecurityPolicyConfigurations(wafSecurityPolicy, ipAccessRulesSecurityPolicy, serializedAdditionalRawData); + return new SecurityPolicyConfigurations(wafSecurityPolicy, ipAccessRulesSecurityPolicy, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -129,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - SecurityPolicyConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SecurityPolicyConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SecurityPolicyConfigurations 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSecurityPolicyConfigurations(document.RootElement, options); } default: @@ -145,6 +154,7 @@ SecurityPolicyConfigurations IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.cs index 540534712601..d15dac8294fa 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyConfigurations.cs @@ -8,44 +8,14 @@ using System; using System.Collections.Generic; using Azure.Core; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.ServiceNetworking.Models { /// SecurityPolicyConfigurations Subresource of Traffic Controller. public partial class SecurityPolicyConfigurations { - /// - /// 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 SecurityPolicyConfigurations() @@ -55,39 +25,43 @@ public SecurityPolicyConfigurations() /// Initializes a new instance of . /// Contains reference to a WAF-type security policy. /// Contains reference to a IpAccessRules-type security policy. - /// Keeps track of any properties unknown to the library. - internal SecurityPolicyConfigurations(WritableSubResource wafSecurityPolicy, WritableSubResource ipAccessRulesSecurityPolicy, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SecurityPolicyConfigurations(WafSecurityPolicy wafSecurityPolicy, ServiceNetworkingIPAccessRulesSecurityPolicy ipAccessRulesSecurityPolicy, IDictionary additionalBinaryDataProperties) { WafSecurityPolicy = wafSecurityPolicy; IPAccessRulesSecurityPolicy = ipAccessRulesSecurityPolicy; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Contains reference to a WAF-type security policy. - internal WritableSubResource WafSecurityPolicy { get; set; } - /// Gets or sets Id. + internal WafSecurityPolicy WafSecurityPolicy { get; set; } + + /// Contains reference to a IpAccessRules-type security policy. + internal ServiceNetworkingIPAccessRulesSecurityPolicy IPAccessRulesSecurityPolicy { get; set; } + + /// Resource ID of the Waf Security Policy. public ResourceIdentifier WafSecurityPolicyId { - get => WafSecurityPolicy is null ? default : WafSecurityPolicy.Id; + get + { + return WafSecurityPolicy is null ? default : WafSecurityPolicy.Id; + } set { - if (WafSecurityPolicy is null) - WafSecurityPolicy = new WritableSubResource(); - WafSecurityPolicy.Id = value; + WafSecurityPolicy = new WafSecurityPolicy(value); } } - /// Contains reference to a IpAccessRules-type security policy. - internal WritableSubResource IPAccessRulesSecurityPolicy { get; set; } - /// Gets or sets Id. + /// Resource ID of the Ip Access Rules Security Policy. public ResourceIdentifier IPAccessRulesSecurityPolicyId { - get => IPAccessRulesSecurityPolicy is null ? default : IPAccessRulesSecurityPolicy.Id; + get + { + return IPAccessRulesSecurityPolicy is null ? default : IPAccessRulesSecurityPolicy.Id; + } set { - if (IPAccessRulesSecurityPolicy is null) - IPAccessRulesSecurityPolicy = new WritableSubResource(); - IPAccessRulesSecurityPolicy.Id = value; + IPAccessRulesSecurityPolicy = new ServiceNetworkingIPAccessRulesSecurityPolicy(value); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.Serialization.cs index d12b9ddf34e2..4f35cac642d9 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class SecurityPolicyListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a SecurityPolicy list operation. + internal partial class SecurityPolicyListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SecurityPolicyListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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(SecurityPolicyListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (ApplicationGatewayForContainersSecurityPolicyData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SecurityPolicyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SecurityPolicyListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SecurityPolicyListResult 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(SecurityPolicyListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSecurityPolicyListResult(document.RootElement, options); } - internal static SecurityPolicyListResult DeserializeSecurityPolicyListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SecurityPolicyListResult DeserializeSecurityPolicyListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(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 SecurityPolicyListResult(value, nextLink, serializedAdditionalRawData); + return new SecurityPolicyListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - SecurityPolicyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SecurityPolicyListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SecurityPolicyListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSecurityPolicyListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ SecurityPolicyListResult IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SecurityPolicyListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSecurityPolicyListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.cs index ff071a13744f..e92f2e05e138 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The response of a SecurityPolicy list operation. internal partial class SecurityPolicyListResult { - /// - /// 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 SecurityPolicy items on this page. - /// is null. internal SecurityPolicyListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The SecurityPolicy items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal SecurityPolicyListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SecurityPolicyListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SecurityPolicyListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The SecurityPolicy items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.Serialization.cs new file mode 100644 index 000000000000..f7db406d5db8 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.Serialization.cs @@ -0,0 +1,190 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// SecurityPolicy Properties. + internal partial class SecurityPolicyProperties : IJsonModel + { + /// 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(SecurityPolicyProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(PolicyType)) + { + writer.WritePropertyName("policyType"u8); + writer.WriteStringValue(PolicyType.Value.ToString()); + } + if (Optional.IsDefined(WafPolicy)) + { + writer.WritePropertyName("wafPolicy"u8); + writer.WriteObjectValue(WafPolicy, options); + } + if (Optional.IsDefined(IpAccessRulesPolicy)) + { + writer.WritePropertyName("ipAccessRulesPolicy"u8); + writer.WriteObjectValue(IpAccessRulesPolicy, options); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.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. + SecurityPolicyProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SecurityPolicyProperties 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(SecurityPolicyProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSecurityPolicyProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SecurityPolicyProperties DeserializeSecurityPolicyProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApplicationGatewayForContainersSecurityPolicyType? policyType = default; + WafPolicy wafPolicy = default; + ServiceNetworkingIPAccessRulesPolicy ipAccessRulesPolicy = default; + ServiceNetworkingProvisioningState? provisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("policyType"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + policyType = new ApplicationGatewayForContainersSecurityPolicyType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("wafPolicy"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wafPolicy = WafPolicy.DeserializeWafPolicy(prop.Value, options); + continue; + } + if (prop.NameEquals("ipAccessRulesPolicy"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ipAccessRulesPolicy = ServiceNetworkingIPAccessRulesPolicy.DeserializeServiceNetworkingIPAccessRulesPolicy(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ServiceNetworkingProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SecurityPolicyProperties(policyType, wafPolicy, ipAccessRulesPolicy, provisioningState, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(SecurityPolicyProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SecurityPolicyProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SecurityPolicyProperties 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 DeserializeSecurityPolicyProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SecurityPolicyProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.cs new file mode 100644 index 000000000000..1cb75e4f57fd --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyProperties.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 Azure.Core; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// SecurityPolicy Properties. + internal partial class SecurityPolicyProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SecurityPolicyProperties() + { + } + + /// Initializes a new instance of . + /// Type of the Traffic Controller Security Policy. + /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. + /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. + /// Provisioning State of Traffic Controller SecurityPolicy Resource. + /// Keeps track of any properties unknown to the library. + internal SecurityPolicyProperties(ApplicationGatewayForContainersSecurityPolicyType? policyType, WafPolicy wafPolicy, ServiceNetworkingIPAccessRulesPolicy ipAccessRulesPolicy, ServiceNetworkingProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) + { + PolicyType = policyType; + WafPolicy = wafPolicy; + IpAccessRulesPolicy = ipAccessRulesPolicy; + ProvisioningState = provisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the Traffic Controller Security Policy. + public ApplicationGatewayForContainersSecurityPolicyType? PolicyType { get; } + + /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. + internal WafPolicy WafPolicy { get; set; } + + /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. + internal ServiceNetworkingIPAccessRulesPolicy IpAccessRulesPolicy { get; set; } + + /// Provisioning State of Traffic Controller SecurityPolicy Resource. + public ServiceNetworkingProvisioningState? ProvisioningState { get; } + + /// Resource ID of the WAF. + public ResourceIdentifier WafPolicyId + { + get + { + return WafPolicy is null ? default : WafPolicy.Id; + } + set + { + WafPolicy = new WafPolicy(value); + } + } + + /// Ip Access Policy Rules List. + public IList Rules + { + get + { + if (IpAccessRulesPolicy is null) + { + IpAccessRulesPolicy = new ServiceNetworkingIPAccessRulesPolicy(); + } + return IpAccessRulesPolicy.Rules; + } + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.Serialization.cs index a22589618243..17012d4c78bf 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.Serialization.cs @@ -8,17 +8,16 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text; using System.Text.Json; -using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class SecurityPolicyUpdateProperties : IUtf8JsonSerializable, IJsonModel + /// The updatable properties of the SecurityPolicy. + public partial class SecurityPolicyUpdateProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,31 +29,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod /// 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(SecurityPolicyUpdateProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(WafPolicy)) { writer.WritePropertyName("wafPolicy"u8); - ((IJsonModel)WafPolicy).Write(writer, options); + writer.WriteObjectValue(WafPolicy, options); } - if (Optional.IsDefined(IPAccessRulesPolicy)) + if (Optional.IsDefined(IpAccessRulesPolicy)) { writer.WritePropertyName("ipAccessRulesPolicy"u8); - writer.WriteObjectValue(IPAccessRulesPolicy, options); + writer.WriteObjectValue(IpAccessRulesPolicy, options); } - 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); } @@ -63,63 +61,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SecurityPolicyUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SecurityPolicyUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SecurityPolicyUpdateProperties 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(SecurityPolicyUpdateProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSecurityPolicyUpdateProperties(document.RootElement, options); } - internal static SecurityPolicyUpdateProperties DeserializeSecurityPolicyUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SecurityPolicyUpdateProperties DeserializeSecurityPolicyUpdateProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - WritableSubResource wafPolicy = default; - IPAccessRulesPolicy ipAccessRulesPolicy = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + WafPolicy wafPolicy = default; + ServiceNetworkingIPAccessRulesPolicy ipAccessRulesPolicy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("wafPolicy"u8)) + if (prop.NameEquals("wafPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - wafPolicy = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); + wafPolicy = WafPolicy.DeserializeWafPolicy(prop.Value, options); continue; } - if (property.NameEquals("ipAccessRulesPolicy"u8)) + if (prop.NameEquals("ipAccessRulesPolicy"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - ipAccessRulesPolicy = IPAccessRulesPolicy.DeserializeIPAccessRulesPolicy(property.Value, options); + ipAccessRulesPolicy = ServiceNetworkingIPAccessRulesPolicy.DeserializeServiceNetworkingIPAccessRulesPolicy(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 SecurityPolicyUpdateProperties(wafPolicy, ipAccessRulesPolicy, serializedAdditionalRawData); + return new SecurityPolicyUpdateProperties(wafPolicy, ipAccessRulesPolicy, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -129,15 +133,20 @@ BinaryData IPersistableModel.Write(ModelReaderWr } } - SecurityPolicyUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + SecurityPolicyUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SecurityPolicyUpdateProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSecurityPolicyUpdateProperties(document.RootElement, options); } default: @@ -145,6 +154,7 @@ SecurityPolicyUpdateProperties IPersistableModel } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.cs index 7c99cdaa75ef..ad008ef84da9 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/SecurityPolicyUpdateProperties.cs @@ -8,44 +8,14 @@ using System; using System.Collections.Generic; using Azure.Core; -using Azure.ResourceManager.Resources.Models; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The updatable properties of the SecurityPolicy. public partial class SecurityPolicyUpdateProperties { - /// - /// 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 SecurityPolicyUpdateProperties() @@ -55,38 +25,43 @@ public SecurityPolicyUpdateProperties() /// Initializes a new instance of . /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - /// Keeps track of any properties unknown to the library. - internal SecurityPolicyUpdateProperties(WritableSubResource wafPolicy, IPAccessRulesPolicy ipAccessRulesPolicy, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SecurityPolicyUpdateProperties(WafPolicy wafPolicy, ServiceNetworkingIPAccessRulesPolicy ipAccessRulesPolicy, IDictionary additionalBinaryDataProperties) { WafPolicy = wafPolicy; - IPAccessRulesPolicy = ipAccessRulesPolicy; - _serializedAdditionalRawData = serializedAdditionalRawData; + IpAccessRulesPolicy = ipAccessRulesPolicy; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Web Application Firewall Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - internal WritableSubResource WafPolicy { get; set; } - /// Gets or sets Id. + internal WafPolicy WafPolicy { get; set; } + + /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. + internal ServiceNetworkingIPAccessRulesPolicy IpAccessRulesPolicy { get; set; } + + /// Resource ID of the WAF. public ResourceIdentifier WafPolicyId { - get => WafPolicy is null ? default : WafPolicy.Id; + get + { + return WafPolicy is null ? default : WafPolicy.Id; + } set { - if (WafPolicy is null) - WafPolicy = new WritableSubResource(); - WafPolicy.Id = value; + WafPolicy = new WafPolicy(value); } } - /// Ip Access Policy of the Traffic Controller Security Policy. Single Security Policy can have only one policy type set. - internal IPAccessRulesPolicy IPAccessRulesPolicy { get; set; } /// Ip Access Policy Rules List. public IList Rules { get { - if (IPAccessRulesPolicy is null) - IPAccessRulesPolicy = new IPAccessRulesPolicy(); - return IPAccessRulesPolicy.Rules; + if (IpAccessRulesPolicy is null) + { + IpAccessRulesPolicy = new ServiceNetworkingIPAccessRulesPolicy(); + } + return IpAccessRulesPolicy.Rules; } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.Serialization.cs index 50ce27a23c8c..e2296be09791 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class ServiceNetworkingIPAccessRule : IUtf8JsonSerializable, IJsonModel + /// Ip Access Policy Rules. + public partial class ServiceNetworkingIPAccessRule : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal ServiceNetworkingIPAccessRule() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,34 +34,38 @@ 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(ServiceNetworkingIPAccessRule)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("priority"u8); writer.WriteNumberValue(Priority); writer.WritePropertyName("sourceAddressPrefixes"u8); writer.WriteStartArray(); - foreach (var item in SourceAddressPrefixes) + foreach (string item in SourceAddressPrefixes) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); writer.WritePropertyName("action"u8); writer.WriteStringValue(Action.ToString()); - 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); } @@ -64,22 +74,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ServiceNetworkingIPAccessRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + ServiceNetworkingIPAccessRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRule 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(ServiceNetworkingIPAccessRule)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeServiceNetworkingIPAccessRule(document.RootElement, options); } - internal static ServiceNetworkingIPAccessRule DeserializeServiceNetworkingIPAccessRule(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ServiceNetworkingIPAccessRule DeserializeServiceNetworkingIPAccessRule(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,48 +103,56 @@ internal static ServiceNetworkingIPAccessRule DeserializeServiceNetworkingIPAcce int priority = default; IList sourceAddressPrefixes = default; ServiceNetworkingIPAccessRuleAction action = 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("priority"u8)) + if (prop.NameEquals("priority"u8)) { - priority = property.Value.GetInt32(); + priority = prop.Value.GetInt32(); continue; } - if (property.NameEquals("sourceAddressPrefixes"u8)) + if (prop.NameEquals("sourceAddressPrefixes"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } sourceAddressPrefixes = array; continue; } - if (property.NameEquals("action"u8)) + if (prop.NameEquals("action"u8)) { - action = new ServiceNetworkingIPAccessRuleAction(property.Value.GetString()); + action = new ServiceNetworkingIPAccessRuleAction(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 ServiceNetworkingIPAccessRule(name, priority, sourceAddressPrefixes, action, serializedAdditionalRawData); + return new ServiceNetworkingIPAccessRule(name, priority, sourceAddressPrefixes, action, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -139,15 +162,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - ServiceNetworkingIPAccessRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + ServiceNetworkingIPAccessRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRule 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeServiceNetworkingIPAccessRule(document.RootElement, options); } default: @@ -155,6 +183,7 @@ ServiceNetworkingIPAccessRule IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.cs index f358fd5988d6..18d20db5ed1c 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRule.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// Ip Access Policy Rules. public partial class ServiceNetworkingIPAccessRule { - /// - /// 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 . /// Name of the Ip Access Rule. @@ -68,27 +40,25 @@ public ServiceNetworkingIPAccessRule(string name, int priority, IEnumerable The priority of the rule. The value can be between 1 and 500. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule. /// Source Address Prefixed Applied by the Rule. Asterisk '*' can also be used to match all source IPs. /// Action of the Rule. - /// Keeps track of any properties unknown to the library. - internal ServiceNetworkingIPAccessRule(string name, int priority, IList sourceAddressPrefixes, ServiceNetworkingIPAccessRuleAction action, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal ServiceNetworkingIPAccessRule(string name, int priority, IList sourceAddressPrefixes, ServiceNetworkingIPAccessRuleAction action, IDictionary additionalBinaryDataProperties) { Name = name; Priority = priority; SourceAddressPrefixes = sourceAddressPrefixes; Action = action; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ServiceNetworkingIPAccessRule() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Name of the Ip Access Rule. public string Name { get; set; } + /// The priority of the rule. The value can be between 1 and 500. The priority number must be unique for each rule in the collection. The lower the priority number, the higher the priority of the rule. public int Priority { get; set; } + /// Source Address Prefixed Applied by the Rule. Asterisk '*' can also be used to match all source IPs. public IList SourceAddressPrefixes { get; } + /// Action of the Rule. public ServiceNetworkingIPAccessRuleAction Action { get; set; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRuleAction.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRuleAction.cs index 6be20043a127..50db72832826 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRuleAction.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRuleAction.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.ServiceNetworking.Models public readonly partial struct ServiceNetworkingIPAccessRuleAction : IEquatable { private readonly string _value; + /// Allow Source Ip Prefixes. + private const string AllowValue = "allow"; + /// Deny Source Ip Prefixes. + private const string DenyValue = "deny"; /// Initializes a new instance of . + /// The value. /// is null. public ServiceNetworkingIPAccessRuleAction(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string AllowValue = "allow"; - private const string DenyValue = "deny"; + _value = value; + } /// Allow Source Ip Prefixes. public static ServiceNetworkingIPAccessRuleAction Allow { get; } = new ServiceNetworkingIPAccessRuleAction(AllowValue); + /// Deny Source Ip Prefixes. public static ServiceNetworkingIPAccessRuleAction Deny { get; } = new ServiceNetworkingIPAccessRuleAction(DenyValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ServiceNetworkingIPAccessRuleAction left, ServiceNetworkingIPAccessRuleAction 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 !=(ServiceNetworkingIPAccessRuleAction left, ServiceNetworkingIPAccessRuleAction right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ServiceNetworkingIPAccessRuleAction(string value) => new ServiceNetworkingIPAccessRuleAction(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ServiceNetworkingIPAccessRuleAction?(string value) => value == null ? null : new ServiceNetworkingIPAccessRuleAction(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ServiceNetworkingIPAccessRuleAction other && Equals(other); - /// + + /// public bool Equals(ServiceNetworkingIPAccessRuleAction 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.Serialization.cs new file mode 100644 index 000000000000..a2d54314fc74 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.Serialization.cs @@ -0,0 +1,155 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Ip Access Policy. + internal partial class ServiceNetworkingIPAccessRulesPolicy : IJsonModel + { + /// 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(ServiceNetworkingIPAccessRulesPolicy)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Rules)) + { + writer.WritePropertyName("rules"u8); + writer.WriteStartArray(); + foreach (ServiceNetworkingIPAccessRule item in Rules) + { + 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. + ServiceNetworkingIPAccessRulesPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRulesPolicy 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(ServiceNetworkingIPAccessRulesPolicy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeServiceNetworkingIPAccessRulesPolicy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ServiceNetworkingIPAccessRulesPolicy DeserializeServiceNetworkingIPAccessRulesPolicy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList rules = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("rules"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ServiceNetworkingIPAccessRule.DeserializeServiceNetworkingIPAccessRule(item, options)); + } + rules = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ServiceNetworkingIPAccessRulesPolicy(rules ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(ServiceNetworkingIPAccessRulesPolicy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ServiceNetworkingIPAccessRulesPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRulesPolicy 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 DeserializeServiceNetworkingIPAccessRulesPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ServiceNetworkingIPAccessRulesPolicy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.cs new file mode 100644 index 000000000000..f73510cec711 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesPolicy.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Ip Access Policy. + internal partial class ServiceNetworkingIPAccessRulesPolicy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ServiceNetworkingIPAccessRulesPolicy() + { + Rules = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Ip Access Policy Rules List. + /// Keeps track of any properties unknown to the library. + internal ServiceNetworkingIPAccessRulesPolicy(IList rules, IDictionary additionalBinaryDataProperties) + { + Rules = rules; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Ip Access Policy Rules List. + public IList Rules { get; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.Serialization.cs new file mode 100644 index 000000000000..a0795dfd8f2d --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.Serialization.cs @@ -0,0 +1,144 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// IpAccessRules Security Policy. + internal partial class ServiceNetworkingIPAccessRulesSecurityPolicy : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ServiceNetworkingIPAccessRulesSecurityPolicy() + { + } + + /// 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(ServiceNetworkingIPAccessRulesSecurityPolicy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + 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. + ServiceNetworkingIPAccessRulesSecurityPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRulesSecurityPolicy 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(ServiceNetworkingIPAccessRulesSecurityPolicy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeServiceNetworkingIPAccessRulesSecurityPolicy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ServiceNetworkingIPAccessRulesSecurityPolicy DeserializeServiceNetworkingIPAccessRulesSecurityPolicy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ServiceNetworkingIPAccessRulesSecurityPolicy(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(ServiceNetworkingIPAccessRulesSecurityPolicy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ServiceNetworkingIPAccessRulesSecurityPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ServiceNetworkingIPAccessRulesSecurityPolicy 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 DeserializeServiceNetworkingIPAccessRulesSecurityPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ServiceNetworkingIPAccessRulesSecurityPolicy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.cs new file mode 100644 index 000000000000..f0833d43907b --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingIPAccessRulesSecurityPolicy.cs @@ -0,0 +1,43 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// IpAccessRules Security Policy. + internal partial class ServiceNetworkingIPAccessRulesSecurityPolicy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID of the Ip Access Rules Security Policy. + /// is null. + public ServiceNetworkingIPAccessRulesSecurityPolicy(ResourceIdentifier id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// Resource ID of the Ip Access Rules Security Policy. + /// Keeps track of any properties unknown to the library. + internal ServiceNetworkingIPAccessRulesSecurityPolicy(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource ID of the Ip Access Rules Security Policy. + public ResourceIdentifier Id { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingProvisioningState.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingProvisioningState.cs index 5c4490c6cfa0..68f5e39dd096 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingProvisioningState.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/ServiceNetworkingProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { @@ -14,53 +15,82 @@ namespace Azure.ResourceManager.ServiceNetworking.Models public readonly partial struct ServiceNetworkingProvisioningState : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public ServiceNetworkingProvisioningState(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// Resource in Provisioning State. private const string ProvisioningValue = "Provisioning"; + /// Resource in Updating State. private const string UpdatingValue = "Updating"; + /// Resource in Deleting State. private const string DeletingValue = "Deleting"; + /// Resource in Accepted State. private const string AcceptedValue = "Accepted"; + /// Resource in Succeeded State. private const string SucceededValue = "Succeeded"; + /// Resource in Failed State. private const string FailedValue = "Failed"; + /// Resource in Canceled State. private const string CanceledValue = "Canceled"; + /// Initializes a new instance of . + /// The value. + /// is null. + public ServiceNetworkingProvisioningState(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// Resource in Provisioning State. public static ServiceNetworkingProvisioningState Provisioning { get; } = new ServiceNetworkingProvisioningState(ProvisioningValue); + /// Resource in Updating State. public static ServiceNetworkingProvisioningState Updating { get; } = new ServiceNetworkingProvisioningState(UpdatingValue); + /// Resource in Deleting State. public static ServiceNetworkingProvisioningState Deleting { get; } = new ServiceNetworkingProvisioningState(DeletingValue); + /// Resource in Accepted State. public static ServiceNetworkingProvisioningState Accepted { get; } = new ServiceNetworkingProvisioningState(AcceptedValue); + /// Resource in Succeeded State. public static ServiceNetworkingProvisioningState Succeeded { get; } = new ServiceNetworkingProvisioningState(SucceededValue); + /// Resource in Failed State. public static ServiceNetworkingProvisioningState Failed { get; } = new ServiceNetworkingProvisioningState(FailedValue); + /// Resource in Canceled State. public static ServiceNetworkingProvisioningState Canceled { get; } = new ServiceNetworkingProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ServiceNetworkingProvisioningState left, ServiceNetworkingProvisioningState 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 !=(ServiceNetworkingProvisioningState left, ServiceNetworkingProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ServiceNetworkingProvisioningState(string value) => new ServiceNetworkingProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator ServiceNetworkingProvisioningState?(string value) => value == null ? null : new ServiceNetworkingProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ServiceNetworkingProvisioningState other && Equals(other); - /// + + /// public bool Equals(ServiceNetworkingProvisioningState 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.Serialization.cs index cc49cae70378..234ad8e8d30e 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.Serialization.cs @@ -8,17 +8,17 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text; using System.Text.Json; using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class TrafficControllerAssociationPatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the Association. + public partial class TrafficControllerAssociationPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficControllerAssociationPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -43,32 +42,29 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(AssociationType)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("associationType"u8); - writer.WriteStringValue(AssociationType.Value.ToString()); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (Optional.IsDefined(Subnet)) - { - writer.WritePropertyName("subnet"u8); - ((IJsonModel)Subnet).Write(writer, options); - } - writer.WriteEndObject(); - 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,90 +73,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficControllerAssociationPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerAssociationPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerAssociationPatch 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(TrafficControllerAssociationPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerAssociationPatch(document.RootElement, options); } - internal static TrafficControllerAssociationPatch DeserializeTrafficControllerAssociationPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerAssociationPatch DeserializeTrafficControllerAssociationPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; - TrafficControllerAssociationType? associationType = default; - WritableSubResource subnet = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + AssociationUpdateProperties properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"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()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + 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("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("associationType"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - associationType = new TrafficControllerAssociationType(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("subnet"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - subnet = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); - continue; - } - } + properties = AssociationUpdateProperties.DeserializeAssociationUpdateProperties(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 TrafficControllerAssociationPatch(tags ?? new ChangeTrackingDictionary(), associationType, subnet, serializedAdditionalRawData); + return new TrafficControllerAssociationPatch(tags ?? new ChangeTrackingDictionary(), properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -170,15 +157,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - TrafficControllerAssociationPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerAssociationPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerAssociationPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerAssociationPatch(document.RootElement, options); } default: @@ -186,6 +178,19 @@ TrafficControllerAssociationPatch IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerAssociationPatch trafficControllerAssociationPatch) + { + if (trafficControllerAssociationPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerAssociationPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.cs index d2f1322fbcad..7c7f9addc0c8 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationPatch.cs @@ -8,44 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; -using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The type used for update operations of the Association. public partial class TrafficControllerAssociationPatch { - /// - /// 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 TrafficControllerAssociationPatch() @@ -55,32 +26,52 @@ public TrafficControllerAssociationPatch() /// Initializes a new instance of . /// Resource tags. - /// Association Type. - /// Association Subnet. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerAssociationPatch(IDictionary tags, TrafficControllerAssociationType? associationType, WritableSubResource subnet, IDictionary serializedAdditionalRawData) + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal TrafficControllerAssociationPatch(IDictionary tags, AssociationUpdateProperties properties, IDictionary additionalBinaryDataProperties) { Tags = tags; - AssociationType = associationType; - Subnet = subnet; - _serializedAdditionalRawData = serializedAdditionalRawData; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Resource tags. public IDictionary Tags { get; } + + /// The resource-specific properties for this resource. + internal AssociationUpdateProperties Properties { get; set; } + /// Association Type. - public TrafficControllerAssociationType? AssociationType { get; set; } - /// Association Subnet. - internal WritableSubResource Subnet { get; set; } - /// Gets or sets Id. + public TrafficControllerAssociationType? AssociationType + { + get + { + return Properties is null ? default : Properties.AssociationType; + } + set + { + if (Properties is null) + { + Properties = new AssociationUpdateProperties(); + } + Properties.AssociationType = value.Value; + } + } + + /// Association ID. public ResourceIdentifier SubnetId { - get => Subnet is null ? default : Subnet.Id; + get + { + return Properties is null ? default : Properties.SubnetId; + } set { - if (Subnet is null) - Subnet = new WritableSubResource(); - Subnet.Id = value; + if (Properties is null) + { + Properties = new AssociationUpdateProperties(); + } + Properties.SubnetId = value; } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationType.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationType.cs index e271a0dee3c4..b6eb937ed28c 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationType.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerAssociationType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { @@ -14,35 +15,52 @@ namespace Azure.ResourceManager.ServiceNetworking.Models public readonly partial struct TrafficControllerAssociationType : IEquatable { private readonly string _value; + /// Association of Type Subnet. + private const string SubnetsValue = "subnets"; /// Initializes a new instance of . + /// The value. /// is null. public TrafficControllerAssociationType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SubnetsValue = "subnets"; + _value = value; + } /// Association of Type Subnet. public static TrafficControllerAssociationType Subnets { get; } = new TrafficControllerAssociationType(SubnetsValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TrafficControllerAssociationType left, TrafficControllerAssociationType 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 !=(TrafficControllerAssociationType left, TrafficControllerAssociationType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TrafficControllerAssociationType(string value) => new TrafficControllerAssociationType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TrafficControllerAssociationType?(string value) => value == null ? null : new TrafficControllerAssociationType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TrafficControllerAssociationType other && Equals(other); - /// + + /// public bool Equals(TrafficControllerAssociationType 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.Serialization.cs index f2b1dbefb2e7..ac6a9b5d51b5 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class TrafficControllerFrontendPatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the Frontend. + public partial class TrafficControllerFrontendPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod /// 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(TrafficControllerFrontendPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,6 +42,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -50,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - 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,68 +73,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficControllerFrontendPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerFrontendPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerFrontendPatch 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(TrafficControllerFrontendPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerFrontendPatch(document.RootElement, options); } - internal static TrafficControllerFrontendPatch DeserializeTrafficControllerFrontendPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerFrontendPatch DeserializeTrafficControllerFrontendPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; FrontendUpdateProperties properties = 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("tags"u8)) + if (prop.NameEquals("tags"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()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + 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("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = FrontendUpdateProperties.DeserializeFrontendUpdateProperties(property.Value, options); + properties = FrontendUpdateProperties.DeserializeFrontendUpdateProperties(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 TrafficControllerFrontendPatch(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new TrafficControllerFrontendPatch(tags ?? new ChangeTrackingDictionary(), properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -138,15 +157,20 @@ BinaryData IPersistableModel.Write(ModelReaderWr } } - TrafficControllerFrontendPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerFrontendPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerFrontendPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerFrontendPatch(document.RootElement, options); } default: @@ -154,6 +178,19 @@ TrafficControllerFrontendPatch IPersistableModel } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerFrontendPatch trafficControllerFrontendPatch) + { + if (trafficControllerFrontendPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerFrontendPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.cs index 837b8c74342a..ff96827ffb43 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerFrontendPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The type used for update operations of the Frontend. public partial class TrafficControllerFrontendPatch { - /// - /// 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 TrafficControllerFrontendPatch() @@ -54,26 +26,33 @@ public TrafficControllerFrontendPatch() /// Initializes a new instance of . /// Resource tags. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerFrontendPatch(IDictionary tags, FrontendUpdateProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficControllerFrontendPatch(IDictionary tags, FrontendUpdateProperties properties, IDictionary additionalBinaryDataProperties) { Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Resource tags. public IDictionary Tags { get; } + /// The resource-specific properties for this resource. internal FrontendUpdateProperties Properties { get; set; } + /// Frontend Security Policy Configuration. public SecurityPolicyConfigurations FrontendUpdateSecurityPolicyConfigurations { - get => Properties is null ? default : Properties.SecurityPolicyConfigurations; + get + { + return Properties is null ? default : Properties.SecurityPolicyConfigurations; + } set { if (Properties is null) + { Properties = new FrontendUpdateProperties(); + } Properties.SecurityPolicyConfigurations = value; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.Serialization.cs index 3cecb996b720..8571bbcd979d 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class TrafficControllerListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a TrafficController list operation. + internal partial class TrafficControllerListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TrafficControllerListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ 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(TrafficControllerListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (TrafficControllerData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficControllerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerListResult 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(TrafficControllerListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerListResult(document.RootElement, options); } - internal static TrafficControllerListResult DeserializeTrafficControllerListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerListResult DeserializeTrafficControllerListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(TrafficControllerData.DeserializeTrafficControllerData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(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 TrafficControllerListResult(value, nextLink, serializedAdditionalRawData); + return new TrafficControllerListResult(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - TrafficControllerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerListResult(document.RootElement, options); } default: @@ -146,6 +163,14 @@ TrafficControllerListResult IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TrafficControllerListResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficControllerListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.cs index e98c4d08de18..8bd7b5ea198d 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The response of a TrafficController list operation. internal partial class TrafficControllerListResult { - /// - /// 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 TrafficController items on this page. - /// is null. internal TrafficControllerListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The TrafficController items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficControllerListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TrafficControllerListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The TrafficController items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.Serialization.cs index 73784c939e33..ff523517018f 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - public partial class TrafficControllerPatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the TrafficController. + public partial class TrafficControllerPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader /// 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(TrafficControllerPatch)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -41,6 +42,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -50,15 +56,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - 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,68 +73,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficControllerPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerPatch 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(TrafficControllerPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerPatch(document.RootElement, options); } - internal static TrafficControllerPatch DeserializeTrafficControllerPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerPatch DeserializeTrafficControllerPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IDictionary tags = default; TrafficControllerUpdateProperties properties = 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("tags"u8)) + if (prop.NameEquals("tags"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()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + 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("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = TrafficControllerUpdateProperties.DeserializeTrafficControllerUpdateProperties(property.Value, options); + properties = TrafficControllerUpdateProperties.DeserializeTrafficControllerUpdateProperties(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 TrafficControllerPatch(tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new TrafficControllerPatch(tags ?? new ChangeTrackingDictionary(), properties, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -138,15 +157,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOpti } } - TrafficControllerPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerPatch(document.RootElement, options); } default: @@ -154,6 +178,19 @@ TrafficControllerPatch IPersistableModel.Create(BinaryDa } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerPatch trafficControllerPatch) + { + if (trafficControllerPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.cs index e1770775deb4..470122be393a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerPatch.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { /// The type used for update operations of the TrafficController. public partial class TrafficControllerPatch { - /// - /// 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 TrafficControllerPatch() @@ -54,26 +26,33 @@ public TrafficControllerPatch() /// Initializes a new instance of . /// Resource tags. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerPatch(IDictionary tags, TrafficControllerUpdateProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficControllerPatch(IDictionary tags, TrafficControllerUpdateProperties properties, IDictionary additionalBinaryDataProperties) { Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Resource tags. public IDictionary Tags { get; } + /// The resource-specific properties for this resource. internal TrafficControllerUpdateProperties Properties { get; set; } + /// Security Policy Configuration. public SecurityPolicyConfigurations TrafficControllerUpdateSecurityPolicyConfigurations { - get => Properties is null ? default : Properties.SecurityPolicyConfigurations; + get + { + return Properties is null ? default : Properties.SecurityPolicyConfigurations; + } set { if (Properties is null) + { Properties = new TrafficControllerUpdateProperties(); + } Properties.SecurityPolicyConfigurations = value; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.Serialization.cs new file mode 100644 index 000000000000..ae2a192089de --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.Serialization.cs @@ -0,0 +1,317 @@ +// 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; +using System.Text.Json; +using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Traffic Controller Properties. + internal partial class TrafficControllerProperties : IJsonModel + { + /// 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(TrafficControllerProperties)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ConfigurationEndpoints)) + { + writer.WritePropertyName("configurationEndpoints"u8); + writer.WriteStartArray(); + foreach (string item in ConfigurationEndpoints) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Frontends)) + { + writer.WritePropertyName("frontends"u8); + writer.WriteStartArray(); + foreach (SubResource item in Frontends) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item).Write(writer, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Associations)) + { + writer.WritePropertyName("associations"u8); + writer.WriteStartArray(); + foreach (SubResource item in Associations) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item).Write(writer, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(SecurityPolicies)) + { + writer.WritePropertyName("securityPolicies"u8); + writer.WriteStartArray(); + foreach (SubResource item in SecurityPolicies) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + ((IJsonModel)item).Write(writer, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(SecurityPolicyConfigurations)) + { + writer.WritePropertyName("securityPolicyConfigurations"u8); + writer.WriteObjectValue(SecurityPolicyConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(TrafficControllerProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(TrafficControllerProvisioningState.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. + TrafficControllerProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerProperties 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(TrafficControllerProperties)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrafficControllerProperties(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerProperties DeserializeTrafficControllerProperties(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList configurationEndpoints = default; + IReadOnlyList frontends = default; + IReadOnlyList associations = default; + IReadOnlyList securityPolicies = default; + SecurityPolicyConfigurations securityPolicyConfigurations = default; + ServiceNetworkingProvisioningState? trafficControllerProvisioningState = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("configurationEndpoints"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()); + } + } + configurationEndpoints = array; + continue; + } + if (prop.NameEquals("frontends"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(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default)); + } + } + frontends = array; + continue; + } + if (prop.NameEquals("associations"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(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default)); + } + } + associations = array; + continue; + } + if (prop.NameEquals("securityPolicies"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(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default)); + } + } + securityPolicies = array; + continue; + } + if (prop.NameEquals("securityPolicyConfigurations"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(prop.Value, options); + continue; + } + if (prop.NameEquals("provisioningState"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + trafficControllerProvisioningState = new ServiceNetworkingProvisioningState(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TrafficControllerProperties( + configurationEndpoints ?? new ChangeTrackingList(), + frontends ?? new ChangeTrackingList(), + associations ?? new ChangeTrackingList(), + securityPolicies ?? new ChangeTrackingList(), + securityPolicyConfigurations, + trafficControllerProvisioningState, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(TrafficControllerProperties)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerProperties 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 DeserializeTrafficControllerProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TrafficControllerProperties)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.cs new file mode 100644 index 000000000000..a9319d36d693 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerProperties.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Resources.Models; +using Azure.ResourceManager.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Traffic Controller Properties. + internal partial class TrafficControllerProperties + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public TrafficControllerProperties() + { + ConfigurationEndpoints = new ChangeTrackingList(); + Frontends = new ChangeTrackingList(); + Associations = new ChangeTrackingList(); + SecurityPolicies = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Configuration Endpoints. + /// Frontends References List. + /// Associations References List. + /// Security Policies References List. + /// Security Policy Configuration. + /// The status of the last operation. + /// Keeps track of any properties unknown to the library. + internal TrafficControllerProperties(IReadOnlyList configurationEndpoints, IReadOnlyList frontends, IReadOnlyList associations, IReadOnlyList securityPolicies, SecurityPolicyConfigurations securityPolicyConfigurations, ServiceNetworkingProvisioningState? trafficControllerProvisioningState, IDictionary additionalBinaryDataProperties) + { + ConfigurationEndpoints = configurationEndpoints; + Frontends = frontends; + Associations = associations; + SecurityPolicies = securityPolicies; + SecurityPolicyConfigurations = securityPolicyConfigurations; + TrafficControllerProvisioningState = trafficControllerProvisioningState; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Configuration Endpoints. + public IReadOnlyList ConfigurationEndpoints { get; } = new ChangeTrackingList(); + + /// Frontends References List. + public IReadOnlyList Frontends { get; } = new ChangeTrackingList(); + + /// Associations References List. + public IReadOnlyList Associations { get; } = new ChangeTrackingList(); + + /// Security Policies References List. + public IReadOnlyList SecurityPolicies { get; } = new ChangeTrackingList(); + + /// Security Policy Configuration. + public SecurityPolicyConfigurations SecurityPolicyConfigurations { get; set; } + + /// The status of the last operation. + public ServiceNetworkingProvisioningState? TrafficControllerProvisioningState { get; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.Serialization.cs index b361dc651e04..8f97e200a302 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.ServiceNetworking; namespace Azure.ResourceManager.ServiceNetworking.Models { - internal partial class TrafficControllerUpdateProperties : IUtf8JsonSerializable, IJsonModel + /// The updatable properties of the TrafficController. + internal partial class TrafficControllerUpdateProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,26 +29,25 @@ void IJsonModel.Write(Utf8JsonWriter 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(TrafficControllerUpdateProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(SecurityPolicyConfigurations)) { writer.WritePropertyName("securityPolicyConfigurations"u8); writer.WriteObjectValue(SecurityPolicyConfigurations, options); } - 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); } @@ -56,53 +56,59 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TrafficControllerUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TrafficControllerUpdateProperties 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(TrafficControllerUpdateProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerUpdateProperties(document.RootElement, options); } - internal static TrafficControllerUpdateProperties DeserializeTrafficControllerUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerUpdateProperties DeserializeTrafficControllerUpdateProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } SecurityPolicyConfigurations securityPolicyConfigurations = 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("securityPolicyConfigurations"u8)) + if (prop.NameEquals("securityPolicyConfigurations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(property.Value, options); + securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(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 TrafficControllerUpdateProperties(securityPolicyConfigurations, serializedAdditionalRawData); + return new TrafficControllerUpdateProperties(securityPolicyConfigurations, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -112,15 +118,20 @@ BinaryData IPersistableModel.Write(ModelReade } } - TrafficControllerUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TrafficControllerUpdateProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerUpdateProperties(document.RootElement, options); } default: @@ -128,6 +139,7 @@ TrafficControllerUpdateProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.cs index 3f49130a4e16..ab3470db5330 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/TrafficControllerUpdateProperties.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.ServiceNetworking.Models /// The updatable properties of the TrafficController. internal partial class TrafficControllerUpdateProperties { - /// - /// 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 TrafficControllerUpdateProperties() @@ -52,11 +23,11 @@ public TrafficControllerUpdateProperties() /// Initializes a new instance of . /// Security Policy Configuration. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerUpdateProperties(SecurityPolicyConfigurations securityPolicyConfigurations, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TrafficControllerUpdateProperties(SecurityPolicyConfigurations securityPolicyConfigurations, IDictionary additionalBinaryDataProperties) { SecurityPolicyConfigurations = securityPolicyConfigurations; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Security Policy Configuration. diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.Serialization.cs new file mode 100644 index 000000000000..f4d22a8021c5 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.Serialization.cs @@ -0,0 +1,144 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Web Application Firewall Policy. + internal partial class WafPolicy : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WafPolicy() + { + } + + /// 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(WafPolicy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + 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. + WafPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WafPolicy 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(WafPolicy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWafPolicy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WafPolicy DeserializeWafPolicy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WafPolicy(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(WafPolicy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WafPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WafPolicy 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 DeserializeWafPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WafPolicy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.cs new file mode 100644 index 000000000000..e776fb929caf --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafPolicy.cs @@ -0,0 +1,43 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Web Application Firewall Policy. + internal partial class WafPolicy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID of the WAF. + /// is null. + public WafPolicy(ResourceIdentifier id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// Resource ID of the WAF. + /// Keeps track of any properties unknown to the library. + internal WafPolicy(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource ID of the WAF. + public ResourceIdentifier Id { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.Serialization.cs new file mode 100644 index 000000000000..aa5b7039ac03 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.Serialization.cs @@ -0,0 +1,144 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Web Application Firewall Security Policy. + internal partial class WafSecurityPolicy : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WafSecurityPolicy() + { + } + + /// 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(WafSecurityPolicy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + 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. + WafSecurityPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WafSecurityPolicy 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(WafSecurityPolicy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWafSecurityPolicy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WafSecurityPolicy DeserializeWafSecurityPolicy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WafSecurityPolicy(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// 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, AzureResourceManagerServiceNetworkingContext.Default); + default: + throw new FormatException($"The model {nameof(WafSecurityPolicy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WafSecurityPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WafSecurityPolicy 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 DeserializeWafSecurityPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WafSecurityPolicy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.cs new file mode 100644 index 000000000000..4655ebc2aec2 --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/Models/WafSecurityPolicy.cs @@ -0,0 +1,43 @@ +// 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.ServiceNetworking; + +namespace Azure.ResourceManager.ServiceNetworking.Models +{ + /// Web Application Firewall Security Policy. + internal partial class WafSecurityPolicy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Resource ID of the Waf Security Policy. + /// is null. + public WafSecurityPolicy(ResourceIdentifier id) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// Resource ID of the Waf Security Policy. + /// Keeps track of any properties unknown to the library. + internal WafSecurityPolicy(ResourceIdentifier id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Resource ID of the Waf Security Policy. + public ResourceIdentifier Id { get; set; } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ProviderConstants.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ProviderConstants.cs index 466b191b25e0..b9f91b93774b 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ProviderConstants.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.ServiceNetworking { - 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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/AssociationsInterfaceRestOperations.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/AssociationsInterfaceRestOperations.cs index 9845355b6549..b767313c22c2 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/AssociationsInterfaceRestOperations.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/AssociationsInterfaceRestOperations.cs @@ -6,143 +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; -using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - internal partial class AssociationsInterfaceRestOperations + internal partial class AssociationsInterface { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of AssociationsInterfaceRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public AssociationsInterfaceRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of AssociationsInterface for mocking. + protected AssociationsInterface() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) + /// Initializes a new instance of AssociationsInterface. + /// 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 AssociationsInterface(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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/associations/", false); - uri.AppendPath(associationName, 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 trafficControllerName, string associationName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/associations/", false); - uri.AppendPath(associationName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// 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 trafficControllerName, string associationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerAssociationData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerAssociationData)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; } - /// Get a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// 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 trafficControllerName, string associationName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerAssociationData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerAssociationData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, TrafficControllerAssociationData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/associations/", false); uri.AppendPath(associationName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, TrafficControllerAssociationData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, 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); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/associations/", false); uri.AppendPath(associationName, true); 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 a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// Resource create parameters. - /// 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 trafficControllerName, string associationName, TrafficControllerAssociationData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// Resource create parameters. - /// 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 trafficControllerName, string associationName, TrafficControllerAssociationData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, TrafficControllerAssociationPatch 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/associations/", false); - uri.AppendPath(associationName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, TrafficControllerAssociationPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, 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); @@ -272,104 +98,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/associations/", false); uri.AppendPath(associationName, true); 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(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// The resource properties to be updated. - /// 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 trafficControllerName, string associationName, TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerAssociationData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// The resource properties to be updated. - /// 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 trafficControllerName, string associationName, TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerAssociationData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/associations/", false); - uri.AppendPath(associationName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) - { - 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); @@ -380,86 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/associations/", false); uri.AppendPath(associationName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// 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 trafficControllerName, string associationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Association. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Name of Association. - /// 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 trafficControllerName, string associationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, associationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateGetByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/associations", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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); @@ -469,152 +140,24 @@ internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, uri.AppendPath(trafficControllerName, true); uri.AppendPath("/associations", 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; } - /// List Association resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerAsync(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AssociationListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AssociationListResult.DeserializeAssociationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Association resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficController(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AssociationListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AssociationListResult.DeserializeAssociationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateNextGetByTrafficControllerRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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; } - - /// List Association resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AssociationListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AssociationListResult.DeserializeAssociationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Association resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficControllerNextPage(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AssociationListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AssociationListResult.DeserializeAssociationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/FrontendsInterfaceRestOperations.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/FrontendsInterfaceRestOperations.cs index ac50e77cec9a..1930605a58e5 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/FrontendsInterfaceRestOperations.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/FrontendsInterfaceRestOperations.cs @@ -6,143 +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; -using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - internal partial class FrontendsInterfaceRestOperations + internal partial class FrontendsInterface { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of FrontendsInterfaceRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public FrontendsInterfaceRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of FrontendsInterface for mocking. + protected FrontendsInterface() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) + /// Initializes a new instance of FrontendsInterface. + /// 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 FrontendsInterface(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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/frontends/", false); - uri.AppendPath(frontendName, 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 trafficControllerName, string frontendName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/frontends/", false); - uri.AppendPath(frontendName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// 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 trafficControllerName, string frontendName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerFrontendData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerFrontendData)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; } - /// Get a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// 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 trafficControllerName, string frontendName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerFrontendData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerFrontendData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, TrafficControllerFrontendData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/frontends/", false); uri.AppendPath(frontendName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, TrafficControllerFrontendData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, 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); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/frontends/", false); uri.AppendPath(frontendName, true); 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 a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// Resource create parameters. - /// 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 trafficControllerName, string frontendName, TrafficControllerFrontendData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// Resource create parameters. - /// 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 trafficControllerName, string frontendName, TrafficControllerFrontendData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, TrafficControllerFrontendPatch 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/frontends/", false); - uri.AppendPath(frontendName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, TrafficControllerFrontendPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, 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); @@ -272,104 +98,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/frontends/", false); uri.AppendPath(frontendName, true); 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(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// The resource properties to be updated. - /// 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 trafficControllerName, string frontendName, TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerFrontendData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// The resource properties to be updated. - /// 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 trafficControllerName, string frontendName, TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerFrontendData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/frontends/", false); - uri.AppendPath(frontendName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) - { - 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); @@ -380,86 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/frontends/", false); uri.AppendPath(frontendName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// 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 trafficControllerName, string frontendName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Frontend. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Frontends. - /// 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 trafficControllerName, string frontendName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, frontendName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateGetByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/frontends", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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); @@ -469,152 +140,24 @@ internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, uri.AppendPath(trafficControllerName, true); uri.AppendPath("/frontends", 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; } - /// List Frontend resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerAsync(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - FrontendListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = FrontendListResult.DeserializeFrontendListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Frontend resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficController(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - FrontendListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = FrontendListResult.DeserializeFrontendListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateNextGetByTrafficControllerRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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; } - - /// List Frontend resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - FrontendListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = FrontendListResult.DeserializeFrontendListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Frontend resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficControllerNextPage(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - FrontendListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = FrontendListResult.DeserializeFrontendListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/SecurityPoliciesInterfaceRestOperations.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/SecurityPoliciesInterfaceRestOperations.cs index c868a153f094..67c597431eb3 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/SecurityPoliciesInterfaceRestOperations.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/SecurityPoliciesInterfaceRestOperations.cs @@ -6,143 +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; -using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - internal partial class SecurityPoliciesInterfaceRestOperations + internal partial class SecurityPoliciesInterface { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SecurityPoliciesInterfaceRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SecurityPoliciesInterfaceRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of SecurityPoliciesInterface for mocking. + protected SecurityPoliciesInterface() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) + /// Initializes a new instance of SecurityPoliciesInterface. + /// 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 SecurityPoliciesInterface(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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/securityPolicies/", false); - uri.AppendPath(securityPolicyName, 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 trafficControllerName, string securityPolicyName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/securityPolicies/", false); - uri.AppendPath(securityPolicyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// 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 trafficControllerName, string securityPolicyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ApplicationGatewayForContainersSecurityPolicyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)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; } - /// Get a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// 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 trafficControllerName, string securityPolicyName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ApplicationGatewayForContainersSecurityPolicyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((ApplicationGatewayForContainersSecurityPolicyData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data) - { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -153,15 +54,17 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/securityPolicies/", false); uri.AppendPath(securityPolicyName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, 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); @@ -172,96 +75,19 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/securityPolicies/", false); uri.AppendPath(securityPolicyName, true); 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 a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// Resource create parameters. - /// 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 trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// Resource create parameters. - /// 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 trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyPatch 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/securityPolicies/", false); - uri.AppendPath(securityPolicyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, 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); @@ -272,104 +98,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/securityPolicies/", false); uri.AppendPath(securityPolicyName, true); 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(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// The resource properties to be updated. - /// 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 trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - ApplicationGatewayForContainersSecurityPolicyData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// The resource properties to be updated. - /// 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 trafficControllerName, string securityPolicyName, ApplicationGatewayForContainersSecurityPolicyPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - ApplicationGatewayForContainersSecurityPolicyData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = ApplicationGatewayForContainersSecurityPolicyData.DeserializeApplicationGatewayForContainersSecurityPolicyData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/securityPolicies/", false); - uri.AppendPath(securityPolicyName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, string securityPolicyName) - { - 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); @@ -380,86 +121,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/securityPolicies/", false); uri.AppendPath(securityPolicyName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// 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 trafficControllerName, string securityPolicyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a SecurityPolicy. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// SecurityPolicy. - /// 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 trafficControllerName, string securityPolicyName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName, securityPolicyName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateGetByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendPath("/securityPolicies", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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); @@ -469,152 +140,24 @@ internal HttpMessage CreateListByTrafficControllerRequest(string subscriptionId, uri.AppendPath(trafficControllerName, true); uri.AppendPath("/securityPolicies", 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; } - /// List SecurityPolicy resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerAsync(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SecurityPolicyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SecurityPolicyListResult.DeserializeSecurityPolicyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List SecurityPolicy resources by TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficController(string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerRequest(subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SecurityPolicyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SecurityPolicyListResult.DeserializeSecurityPolicyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByTrafficControllerNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByTrafficControllerNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName) + internal HttpMessage CreateNextGetByTrafficControllerRequest(Uri nextPage, string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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; } - - /// List SecurityPolicy resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByTrafficControllerNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SecurityPolicyListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SecurityPolicyListResult.DeserializeSecurityPolicyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List SecurityPolicy resources by TrafficController. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByTrafficControllerNextPage(string nextLink, string subscriptionId, string resourceGroupName, string trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateListByTrafficControllerNextPageRequest(nextLink, subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SecurityPolicyListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SecurityPolicyListResult.DeserializeSecurityPolicyListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/TrafficControllerInterfaceRestOperations.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/TrafficControllerInterfaceRestOperations.cs index 009613aa8d09..7edcb3a9b5c0 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/TrafficControllerInterfaceRestOperations.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/RestOperations/TrafficControllerInterfaceRestOperations.cs @@ -6,135 +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; -using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - internal partial class TrafficControllerInterfaceRestOperations + internal partial class TrafficControllerInterface { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of TrafficControllerInterfaceRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public TrafficControllerInterfaceRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of TrafficControllerInterface for mocking. + protected TrafficControllerInterface() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-03-01-preview"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// 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 trafficControllerName, CancellationToken cancellationToken = default) + /// Initializes a new instance of TrafficControllerInterface. + /// 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 TrafficControllerInterface(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// 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 trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((TrafficControllerData)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, string resourceGroupName, string trafficControllerName, TrafficControllerData data) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -143,15 +52,17 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers/", false); uri.AppendPath(trafficControllerName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, TrafficControllerData data) + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, 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); @@ -160,90 +71,19 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers/", false); uri.AppendPath(trafficControllerName, true); 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 a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Resource create parameters. - /// 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 trafficControllerName, TrafficControllerData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// Resource create parameters. - /// 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 trafficControllerName, TrafficControllerData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName, TrafficControllerPatch 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, TrafficControllerPatch patch) - { - 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); @@ -252,98 +92,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers/", false); uri.AppendPath(trafficControllerName, true); 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(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Update a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The resource properties to be updated. - /// 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 trafficControllerName, TrafficControllerPatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// The resource properties to be updated. - /// 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 trafficControllerName, TrafficControllerPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, trafficControllerName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerData.DeserializeTrafficControllerData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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.ServiceNetworking/trafficControllers/", false); - uri.AppendPath(trafficControllerName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - 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); @@ -352,80 +113,16 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers/", false); uri.AppendPath(trafficControllerName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// 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 trafficControllerName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a TrafficController. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// traffic controller name for path. - /// 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 trafficControllerName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, trafficControllerName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) - { - 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.ServiceNetworking/trafficControllers", 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(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -433,298 +130,52 @@ internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, str uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers", 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; } - /// List TrafficController resources by resource group. - /// The ID of the target subscription. The value must be an UUID. - /// 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) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - 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: - { - TrafficControllerListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List TrafficController resources by resource group. - /// The ID of the target subscription. The value must be an UUID. - /// 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) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + internal HttpMessage CreateGetBySubscriptionRequest(string subscriptionId, 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); uri.AppendPath("/providers/Microsoft.ServiceNetworking/trafficControllers", 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); - return message; - } - - /// List TrafficController resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// 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: - { - TrafficControllerListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List TrafficController resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// 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) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List TrafficController resources by resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// 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> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List TrafficController resources by resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// 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 ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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; } - - /// List TrafficController resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List TrafficController resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TrafficControllerListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TrafficControllerListResult.DeserializeTrafficControllerListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationCollection.cs index 95f374feec94..eb351c47075e 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationCollection.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; namespace Azure.ResourceManager.ServiceNetworking { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.ServiceNetworking /// public partial class TrafficControllerAssociationCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _trafficControllerAssociationAssociationsInterfaceClientDiagnostics; - private readonly AssociationsInterfaceRestOperations _trafficControllerAssociationAssociationsInterfaceRestClient; + private readonly ClientDiagnostics _associationsInterfaceClientDiagnostics; + private readonly AssociationsInterface _associationsInterfaceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerAssociationCollection for mocking. protected TrafficControllerAssociationCollection() { } - /// 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 TrafficControllerAssociationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerAssociationAssociationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerAssociationResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficControllerAssociationResource.ResourceType, out string trafficControllerAssociationAssociationsInterfaceApiVersion); - _trafficControllerAssociationAssociationsInterfaceRestClient = new AssociationsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerAssociationAssociationsInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficControllerAssociationResource.ResourceType, out string trafficControllerAssociationApiVersion); + _associationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerAssociationResource.ResourceType.Namespace, Diagnostics); + _associationsInterfaceRestClient = new AssociationsInterface(_associationsInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerAssociationApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficControllerResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), id); + } } /// /// Create a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// AssociationsInterface_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -76,21 +75,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// Name of Association. /// Resource create parameters. /// 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 associationName, TrafficControllerAssociationData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.CreateOrUpdate"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerAssociationOperationSource(Client), _trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, _trafficControllerAssociationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, TrafficControllerAssociationData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerAssociationOperationSource(Client), + _associationsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,20 +116,16 @@ public virtual async Task> Cr /// Create a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_CreateOrUpdate + /// Operation Id. + /// AssociationsInterface_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -125,21 +133,34 @@ public virtual async Task> Cr /// Name of Association. /// Resource create parameters. /// 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 associationName, TrafficControllerAssociationData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.CreateOrUpdate"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.CreateOrUpdate"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data, cancellationToken); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerAssociationOperationSource(Client), _trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, _trafficControllerAssociationAssociationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, TrafficControllerAssociationData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerAssociationOperationSource(Client), + _associationsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation CreateOrUpdate /// Get a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Get + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Get"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Get"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task> GetAsy /// Get a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Get"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Get"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response Get(string associa /// List Association resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations. /// /// - /// Operation Id - /// Association_ListByTrafficController + /// Operation Id. + /// AssociationsInterface_ListByTrafficController. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// 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) => _trafficControllerAssociationAssociationsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerAssociationAssociationsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerAssociationResource(Client, TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(e)), _trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, "TrafficControllerAssociationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AssociationsInterfaceGetByTrafficControllerAsyncCollectionResultOfT(_associationsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new TrafficControllerAssociationResource(Client, data)); } /// /// List Association resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations - /// - /// - /// Operation Id - /// Association_ListByTrafficController + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// AssociationsInterface_ListByTrafficController. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable GetAllAsync(C /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _trafficControllerAssociationAssociationsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerAssociationAssociationsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerAssociationResource(Client, TrafficControllerAssociationData.DeserializeTrafficControllerAssociationData(e)), _trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, "TrafficControllerAssociationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AssociationsInterfaceGetByTrafficControllerCollectionResultOfT(_associationsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new TrafficControllerAssociationResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Exists"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Exists"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -346,36 +385,50 @@ public virtual async Task> ExistsAsync(string associationName, Ca /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Get + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Exists"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.Exists"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -389,38 +442,54 @@ public virtual Response Exists(string associationName, CancellationToken c /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetIfExists"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -434,38 +503,54 @@ public virtual async Task /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Get + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Name of Association. /// 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 associationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetIfExists"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationCollection.GetIfExists"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerAssociationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.Serialization.cs index 6a399e7790ff..dbfff98571bc 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.Serialization.cs @@ -10,17 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - public partial class TrafficControllerAssociationData : IUtf8JsonSerializable, IJsonModel + /// Association Subresource of Traffic Controller. + public partial class TrafficControllerAssociationData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TrafficControllerAssociationData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -32,171 +38,144 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// 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(TrafficControllerAssociationData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(AssociationType)) - { - writer.WritePropertyName("associationType"u8); - writer.WriteStringValue(AssociationType.Value.ToString()); - } - if (Optional.IsDefined(Subnet)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("subnet"u8); - ((IJsonModel)Subnet).Write(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - writer.WriteEndObject(); } - TrafficControllerAssociationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerAssociationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficControllerAssociationData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData 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(TrafficControllerAssociationData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerAssociationData(document.RootElement, options); } - internal static TrafficControllerAssociationData DeserializeTrafficControllerAssociationData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerAssociationData DeserializeTrafficControllerAssociationData(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; + ResourceType resourceType = default; SystemData systemData = default; - TrafficControllerAssociationType? associationType = default; - WritableSubResource subnet = default; - ServiceNetworkingProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + AssociationProperties 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)) { - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("associationType"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - associationType = new TrafficControllerAssociationType(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("subnet"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - subnet = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default); - continue; + dictionary.Add(prop0.Name, null); } - if (property0.NameEquals("provisioningState"u8)) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new ServiceNetworkingProvisioningState(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AssociationProperties.DeserializeAssociationProperties(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 TrafficControllerAssociationData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - associationType, - subnet, - provisioningState, - serializedAdditionalRawData); + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -206,15 +185,20 @@ BinaryData IPersistableModel.Write(ModelReader } } - TrafficControllerAssociationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerAssociationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficControllerAssociationData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerAssociationData(document.RootElement, options); } default: @@ -222,6 +206,26 @@ TrafficControllerAssociationData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerAssociationData trafficControllerAssociationData) + { + if (trafficControllerAssociationData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerAssociationData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TrafficControllerAssociationData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficControllerAssociationData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.cs index 2303960e1cd3..47e297aac39f 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationData.cs @@ -9,96 +9,81 @@ using System.Collections.Generic; using Azure.Core; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - /// - /// A class representing the TrafficControllerAssociation data model. - /// Association Subresource of Traffic Controller - /// + /// Association Subresource of Traffic Controller. public partial class TrafficControllerAssociationData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public TrafficControllerAssociationData(AzureLocation location) : base(location) { } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Association Type. - /// Association Subnet. - /// Provisioning State of Traffic Controller Association Resource. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, TrafficControllerAssociationType? associationType, WritableSubResource subnet, ServiceNetworkingProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal TrafficControllerAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, AssociationProperties properties) : base(id, name, resourceType, systemData, tags, location) { - AssociationType = associationType; - Subnet = subnet; - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal TrafficControllerAssociationData() + /// The resource-specific properties for this resource. + internal AssociationProperties Properties { get; set; } + + /// Provisioning State of Traffic Controller Association Resource. + public ServiceNetworkingProvisioningState? ProvisioningState { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } } - /// Association Type. - public TrafficControllerAssociationType? AssociationType { get; set; } - /// Association Subnet. - internal WritableSubResource Subnet { get; set; } - /// Gets or sets Id. + /// Association ID. public ResourceIdentifier SubnetId { - get => Subnet is null ? default : Subnet.Id; + get + { + return Properties is null ? default : Properties.SubnetId; + } set { - if (Subnet is null) - Subnet = new WritableSubResource(); - Subnet.Id = value; + if (Properties is null) + { + Properties = new AssociationProperties(); + } + Properties.SubnetId = value; } } - /// Provisioning State of Traffic Controller Association Resource. - public ServiceNetworkingProvisioningState? ProvisioningState { get; } + /// Association Type. + public TrafficControllerAssociationType? AssociationType + { + get + { + return Properties is null ? default : Properties.AssociationType; + } + set + { + if (Properties is null) + { + Properties = new AssociationProperties(); + } + Properties.AssociationType = value.Value; + } + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.Serialization.cs index 8082b2d49526..b547a5c4c67b 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.ServiceNetworking { + /// public partial class TrafficControllerAssociationResource : IJsonModel { - private static TrafficControllerAssociationData s_dataDeserializationInstance; - private static TrafficControllerAssociationData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficControllerAssociationData(); + + /// 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); - TrafficControllerAssociationData 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. + TrafficControllerAssociationData 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, AzureResourceManagerServiceNetworkingContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficControllerAssociationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerServiceNetworkingContext.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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.cs index 533d43338a05..b3338c3edb5a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerAssociationResource.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.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { /// - /// A Class representing a TrafficControllerAssociation 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 GetTrafficControllerAssociationResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficControllerAssociation method. + /// A class representing a TrafficControllerAssociation 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 GetTrafficControllerAssociations method. /// public partial class TrafficControllerAssociationResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The trafficControllerName. - /// The associationName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficControllerAssociationAssociationsInterfaceClientDiagnostics; - private readonly AssociationsInterfaceRestOperations _trafficControllerAssociationAssociationsInterfaceRestClient; + private readonly ClientDiagnostics _associationsInterfaceClientDiagnostics; + private readonly AssociationsInterface _associationsInterfaceRestClient; private readonly TrafficControllerAssociationData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.ServiceNetworking/trafficControllers/associations"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerAssociationResource for mocking. protected TrafficControllerAssociationResource() { } - /// 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 TrafficControllerAssociationResource(ArmClient client, TrafficControllerAssociationData data) : this(client, data.Id) @@ -56,71 +46,93 @@ internal TrafficControllerAssociationResource(ArmClient client, TrafficControlle _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 TrafficControllerAssociationResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerAssociationAssociationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficControllerAssociationAssociationsInterfaceApiVersion); - _trafficControllerAssociationAssociationsInterfaceRestClient = new AssociationsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerAssociationAssociationsInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficControllerAssociationApiVersion); + _associationsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); + _associationsInterfaceRestClient = new AssociationsInterface(_associationsInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerAssociationApiVersion ?? "2025-03-01-preview"); + 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 TrafficControllerAssociationData 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 trafficControllerName. + /// The associationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string associationName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}"; + 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); + } } /// /// Get a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Get + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Get"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Get"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +146,41 @@ public virtual async Task> GetAsy /// Get a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Get + /// Operation Id. + /// AssociationsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Get"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Get"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,39 +191,49 @@ public virtual Response Get(CancellationTo } /// - /// Delete a Association + /// Update a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Delete + /// Operation Id. + /// AssociationsInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Update"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, _trafficControllerAssociationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerAssociationPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -213,39 +243,49 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a Association + /// Update a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Delete + /// Operation Id. + /// AssociationsInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Update(TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Update"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_trafficControllerAssociationAssociationsInterfaceClientDiagnostics, Pipeline, _trafficControllerAssociationAssociationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerAssociationPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -255,39 +295,46 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a Association + /// Delete a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Update + /// Operation Id. + /// AssociationsInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual async Task> UpdateAsync(TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Update"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Delete"); scope.Start(); try { - var response = await _trafficControllerAssociationAssociationsInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_associationsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -297,39 +344,46 @@ public virtual async Task> Update } /// - /// Update a Association + /// Delete a Association /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName}. /// /// - /// Operation Id - /// Association_Update + /// Operation Id. + /// AssociationsInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual Response Update(TrafficControllerAssociationPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Update"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.Delete"); scope.Start(); try { - var response = _trafficControllerAssociationAssociationsInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); - return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_associationsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -338,27 +392,7 @@ public virtual Response Update(TrafficCont } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -368,29 +402,35 @@ public virtual async Task> AddTag Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.AddTag"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerAssociationPatch(); - foreach (var tag in current.Tags) + TrafficControllerAssociationData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); + 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) @@ -400,27 +440,7 @@ public virtual async Task> AddTag } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -430,29 +450,35 @@ public virtual Response AddTag(string key, Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.AddTag"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerAssociationPatch(); - foreach (var tag in current.Tags) + TrafficControllerAssociationData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); + 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) @@ -462,54 +488,40 @@ public virtual Response AddTag(string key, } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.SetTags"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerAssociationPatch(); + TrafficControllerAssociationData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); 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) @@ -519,54 +531,40 @@ public virtual async Task> SetTag } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.SetTags"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerAssociationPatch(); + TrafficControllerAssociationData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); 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) @@ -576,27 +574,7 @@ public virtual Response SetTags(IDictionar } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -604,29 +582,35 @@ public virtual async Task> Remove { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.RemoveTag"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 _trafficControllerAssociationAssociationsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerAssociationPatch(); - foreach (var tag in current.Tags) + TrafficControllerAssociationData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); + 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) @@ -636,27 +620,7 @@ public virtual async Task> Remove } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -664,29 +628,35 @@ public virtual Response RemoveTag(string k { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerAssociationAssociationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.RemoveTag"); + using DiagnosticScope scope = _associationsInterfaceClientDiagnostics.CreateScope("TrafficControllerAssociationResource.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 = _trafficControllerAssociationAssociationsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _associationsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerAssociationData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerAssociationResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerAssociationPatch(); - foreach (var tag in current.Tags) + TrafficControllerAssociationData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerAssociationPatch patch = new TrafficControllerAssociationPatch(); + 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) diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerCollection.cs index 88e3980cdce3..b2e11ab989fe 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerCollection.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.ServiceNetworking @@ -25,51 +26,49 @@ namespace Azure.ResourceManager.ServiceNetworking /// public partial class TrafficControllerCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _trafficControllerTrafficControllerInterfaceClientDiagnostics; - private readonly TrafficControllerInterfaceRestOperations _trafficControllerTrafficControllerInterfaceRestClient; + private readonly ClientDiagnostics _trafficControllerInterfaceClientDiagnostics; + private readonly TrafficControllerInterface _trafficControllerInterfaceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerCollection for mocking. protected TrafficControllerCollection() { } - /// 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 TrafficControllerCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerTrafficControllerInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficControllerResource.ResourceType, out string trafficControllerTrafficControllerInterfaceApiVersion); - _trafficControllerTrafficControllerInterfaceRestClient = new TrafficControllerInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerTrafficControllerInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficControllerResource.ResourceType, out string trafficControllerApiVersion); + _trafficControllerInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerResource.ResourceType.Namespace, Diagnostics); + _trafficControllerInterfaceRestClient = new TrafficControllerInterface(_trafficControllerInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerApiVersion ?? "2025-03-01-preview"); + 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 a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -77,21 +76,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// traffic controller name for path. /// Resource create parameters. /// 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 trafficControllerName, TrafficControllerData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.CreateOrUpdate"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, data, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerOperationSource(Client), _trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, _trafficControllerTrafficControllerInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, TrafficControllerData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerOperationSource(Client), + _trafficControllerInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,20 +117,16 @@ public virtual async Task> CreateOrUpdat /// Create a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_CreateOrUpdate + /// Operation Id. + /// TrafficControllerInterface_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -126,21 +134,34 @@ public virtual async Task> CreateOrUpdat /// traffic controller name for path. /// Resource create parameters. /// 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 trafficControllerName, TrafficControllerData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.CreateOrUpdate"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.CreateOrUpdate"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, data, cancellationToken); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerOperationSource(Client), _trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, _trafficControllerTrafficControllerInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, TrafficControllerData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerOperationSource(Client), + _trafficControllerInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,38 +175,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Get + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Get"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Get"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync(string t /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Get"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Get"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string trafficControllerN /// List TrafficController resources by resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers. /// /// - /// Operation Id - /// TrafficController_ListByResourceGroup + /// Operation Id. + /// TrafficControllerInterface_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// 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) => _trafficControllerTrafficControllerInterfaceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerTrafficControllerInterfaceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerResource(Client, TrafficControllerData.DeserializeTrafficControllerData(e)), _trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, "TrafficControllerCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TrafficControllerInterfaceGetByResourceGroupAsyncCollectionResultOfT(_trafficControllerInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new TrafficControllerResource(Client, data)); } /// /// List TrafficController resources by resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers - /// - /// - /// Operation Id - /// TrafficController_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(Cancellation /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _trafficControllerTrafficControllerInterfaceRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerTrafficControllerInterfaceRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerResource(Client, TrafficControllerData.DeserializeTrafficControllerData(e)), _trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, "TrafficControllerCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TrafficControllerInterfaceGetByResourceGroupCollectionResultOfT(_trafficControllerInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new TrafficControllerResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Exists"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Exists"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -347,36 +386,50 @@ public virtual async Task> ExistsAsync(string trafficControllerNa /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Get + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Exists"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.Exists"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -390,38 +443,54 @@ public virtual Response Exists(string trafficControllerName, CancellationT /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.GetIfExists"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -435,38 +504,54 @@ public virtual async Task> GetIfExis /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Get + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// traffic controller name for path. /// 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 trafficControllerName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(trafficControllerName, nameof(trafficControllerName)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.GetIfExists"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerCollection.GetIfExists"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, trafficControllerName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +571,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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.Serialization.cs index cfe281dda1d3..ce6e3e542027 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.Serialization.cs @@ -10,17 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - public partial class TrafficControllerData : IUtf8JsonSerializable, IJsonModel + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. + public partial class TrafficControllerData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TrafficControllerData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -32,259 +38,144 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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(TrafficControllerData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsCollectionDefined(ConfigurationEndpoints)) - { - writer.WritePropertyName("configurationEndpoints"u8); - writer.WriteStartArray(); - foreach (var item in ConfigurationEndpoints) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Frontends)) - { - writer.WritePropertyName("frontends"u8); - writer.WriteStartArray(); - foreach (var item in Frontends) - { - ((IJsonModel)item).Write(writer, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Associations)) - { - writer.WritePropertyName("associations"u8); - writer.WriteStartArray(); - foreach (var item in Associations) - { - ((IJsonModel)item).Write(writer, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && Optional.IsCollectionDefined(SecurityPolicies)) - { - writer.WritePropertyName("securityPolicies"u8); - writer.WriteStartArray(); - foreach (var item in SecurityPolicies) - { - ((IJsonModel)item).Write(writer, options); - } - writer.WriteEndArray(); - } - if (Optional.IsDefined(SecurityPolicyConfigurations)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("securityPolicyConfigurations"u8); - writer.WriteObjectValue(SecurityPolicyConfigurations, options); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsDefined(TrafficControllerProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(TrafficControllerProvisioningState.Value.ToString()); - } - writer.WriteEndObject(); } - TrafficControllerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficControllerData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData 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(TrafficControllerData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerData(document.RootElement, options); } - internal static TrafficControllerData DeserializeTrafficControllerData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerData DeserializeTrafficControllerData(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; + ResourceType resourceType = default; SystemData systemData = default; - IReadOnlyList configurationEndpoints = default; - IReadOnlyList frontends = default; - IReadOnlyList associations = default; - IReadOnlyList securityPolicies = default; - SecurityPolicyConfigurations securityPolicyConfigurations = default; - ServiceNetworkingProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + TrafficControllerProperties 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)) { - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("configurationEndpoints"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - configurationEndpoints = array; - continue; + dictionary.Add(prop0.Name, null); } - if (property0.NameEquals("frontends"u8)) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default)); - } - frontends = array; - continue; - } - if (property0.NameEquals("associations"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default)); - } - associations = array; - continue; - } - if (property0.NameEquals("securityPolicies"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property0.Value.EnumerateArray()) - { - array.Add(ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureResourceManagerServiceNetworkingContext.Default)); - } - securityPolicies = array; - continue; - } - if (property0.NameEquals("securityPolicyConfigurations"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(property0.Value, options); - continue; - } - if (property0.NameEquals("provisioningState"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new ServiceNetworkingProvisioningState(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TrafficControllerProperties.DeserializeTrafficControllerProperties(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 TrafficControllerData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - configurationEndpoints ?? new ChangeTrackingList(), - frontends ?? new ChangeTrackingList(), - associations ?? new ChangeTrackingList(), - securityPolicies ?? new ChangeTrackingList(), - securityPolicyConfigurations, - provisioningState, - serializedAdditionalRawData); + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -294,15 +185,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - TrafficControllerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficControllerData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerData(document.RootElement, options); } default: @@ -310,6 +206,26 @@ TrafficControllerData IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerData trafficControllerData) + { + if (trafficControllerData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TrafficControllerData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficControllerData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.cs index e26b248767ec..ee20c6daac45 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerData.cs @@ -14,95 +14,112 @@ namespace Azure.ResourceManager.ServiceNetworking { - /// - /// A class representing the TrafficController data model. - /// Concrete tracked resource types can be created by aliasing this type using a specific property type. - /// + /// Concrete tracked resource types can be created by aliasing this type using a specific property type. public partial class TrafficControllerData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public TrafficControllerData(AzureLocation location) : base(location) { - ConfigurationEndpoints = new ChangeTrackingList(); - Frontends = new ChangeTrackingList(); - Associations = new ChangeTrackingList(); - SecurityPolicies = new ChangeTrackingList(); } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// Configuration Endpoints. - /// Frontends References List. - /// Associations References List. - /// Security Policies References List. - /// Security Policy Configuration. - /// The status of the last operation. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, IReadOnlyList configurationEndpoints, IReadOnlyList frontends, IReadOnlyList associations, IReadOnlyList securityPolicies, SecurityPolicyConfigurations securityPolicyConfigurations, ServiceNetworkingProvisioningState? trafficControllerProvisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal TrafficControllerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, TrafficControllerProperties properties) : base(id, name, resourceType, systemData, tags, location) { - ConfigurationEndpoints = configurationEndpoints; - Frontends = frontends; - Associations = associations; - SecurityPolicies = securityPolicies; - SecurityPolicyConfigurations = securityPolicyConfigurations; - TrafficControllerProvisioningState = trafficControllerProvisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal TrafficControllerData() + /// The resource-specific properties for this resource. + internal TrafficControllerProperties Properties { get; set; } + + /// Configuration Endpoints. + public IReadOnlyList ConfigurationEndpoints { + get + { + if (Properties is null) + { + Properties = new TrafficControllerProperties(); + } + return Properties.ConfigurationEndpoints; + } } - /// Configuration Endpoints. - public IReadOnlyList ConfigurationEndpoints { get; } /// Frontends References List. - public IReadOnlyList Frontends { get; } + public IReadOnlyList Frontends + { + get + { + if (Properties is null) + { + Properties = new TrafficControllerProperties(); + } + return Properties.Frontends; + } + } + /// Associations References List. - public IReadOnlyList Associations { get; } + public IReadOnlyList Associations + { + get + { + if (Properties is null) + { + Properties = new TrafficControllerProperties(); + } + return Properties.Associations; + } + } + /// Security Policies References List. - public IReadOnlyList SecurityPolicies { get; } + public IReadOnlyList SecurityPolicies + { + get + { + if (Properties is null) + { + Properties = new TrafficControllerProperties(); + } + return Properties.SecurityPolicies; + } + } + /// Security Policy Configuration. - public SecurityPolicyConfigurations SecurityPolicyConfigurations { get; set; } + public SecurityPolicyConfigurations SecurityPolicyConfigurations + { + get + { + return Properties is null ? default : Properties.SecurityPolicyConfigurations; + } + set + { + if (Properties is null) + { + Properties = new TrafficControllerProperties(); + } + Properties.SecurityPolicyConfigurations = value; + } + } + /// The status of the last operation. - public ServiceNetworkingProvisioningState? TrafficControllerProvisioningState { get; } + public ServiceNetworkingProvisioningState? TrafficControllerProvisioningState + { + get + { + return Properties is null ? default : Properties.TrafficControllerProvisioningState; + } + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendCollection.cs index 3d8320c75726..a77edda56272 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendCollection.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; namespace Azure.ResourceManager.ServiceNetworking { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.ServiceNetworking /// public partial class TrafficControllerFrontendCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _trafficControllerFrontendFrontendsInterfaceClientDiagnostics; - private readonly FrontendsInterfaceRestOperations _trafficControllerFrontendFrontendsInterfaceRestClient; + private readonly ClientDiagnostics _frontendsInterfaceClientDiagnostics; + private readonly FrontendsInterface _frontendsInterfaceRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerFrontendCollection for mocking. protected TrafficControllerFrontendCollection() { } - /// 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 TrafficControllerFrontendCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerFrontendFrontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerFrontendResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(TrafficControllerFrontendResource.ResourceType, out string trafficControllerFrontendFrontendsInterfaceApiVersion); - _trafficControllerFrontendFrontendsInterfaceRestClient = new FrontendsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerFrontendFrontendsInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(TrafficControllerFrontendResource.ResourceType, out string trafficControllerFrontendApiVersion); + _frontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", TrafficControllerFrontendResource.ResourceType.Namespace, Diagnostics); + _frontendsInterfaceRestClient = new FrontendsInterface(_frontendsInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerFrontendApiVersion ?? "2025-03-01-preview"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != TrafficControllerResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, TrafficControllerResource.ResourceType), id); + } } /// /// Create a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// FrontendsInterface_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -76,21 +75,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// Frontends. /// Resource create parameters. /// 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 frontendName, TrafficControllerFrontendData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.CreateOrUpdate"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerFrontendOperationSource(Client), _trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, _trafficControllerFrontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, TrafficControllerFrontendData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerFrontendOperationSource(Client), + _frontendsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,20 +116,16 @@ public virtual async Task> Creat /// Create a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_CreateOrUpdate + /// Operation Id. + /// FrontendsInterface_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -125,21 +133,34 @@ public virtual async Task> Creat /// Frontends. /// Resource create parameters. /// 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 frontendName, TrafficControllerFrontendData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.CreateOrUpdate"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.CreateOrUpdate"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data, cancellationToken); - var operation = new ServiceNetworkingArmOperation(new TrafficControllerFrontendOperationSource(Client), _trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, _trafficControllerFrontendFrontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, TrafficControllerFrontendData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation( + new TrafficControllerFrontendOperationSource(Client), + _frontendsInterfaceClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation CreateOrUpdate(Wa /// Get a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Get + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Get"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Get"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task> GetAsync( /// Get a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Get"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Get"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response Get(string frontendNa /// List Frontend resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends. /// /// - /// Operation Id - /// Frontend_ListByTrafficController + /// Operation Id. + /// FrontendsInterface_ListByTrafficController. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// 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) => _trafficControllerFrontendFrontendsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerFrontendFrontendsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerFrontendResource(Client, TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(e)), _trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, "TrafficControllerFrontendCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new FrontendsInterfaceGetByTrafficControllerAsyncCollectionResultOfT(_frontendsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new TrafficControllerFrontendResource(Client, data)); } /// /// List Frontend resources by TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends - /// - /// - /// Operation Id - /// Frontend_ListByTrafficController + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// FrontendsInterface_ListByTrafficController. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable GetAllAsync(Canc /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _trafficControllerFrontendFrontendsInterfaceRestClient.CreateListByTrafficControllerRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _trafficControllerFrontendFrontendsInterfaceRestClient.CreateListByTrafficControllerNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TrafficControllerFrontendResource(Client, TrafficControllerFrontendData.DeserializeTrafficControllerFrontendData(e)), _trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, "TrafficControllerFrontendCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new FrontendsInterfaceGetByTrafficControllerCollectionResultOfT(_frontendsInterfaceRestClient, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context), data => new TrafficControllerFrontendResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Exists"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Exists"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -346,36 +385,50 @@ public virtual async Task> ExistsAsync(string frontendName, Cance /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Get + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Exists"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.Exists"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -389,38 +442,54 @@ public virtual Response Exists(string frontendName, CancellationToken canc /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetIfExists"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetIfExists"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -434,38 +503,54 @@ public virtual async Task> G /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Get + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-03-01-preview. /// /// /// /// Frontends. /// 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 frontendName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetIfExists"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendCollection.GetIfExists"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, frontendName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((TrafficControllerFrontendData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.Serialization.cs index 09ea31d8ae87..dd8f25c40efa 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.Models; using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { - public partial class TrafficControllerFrontendData : IUtf8JsonSerializable, IJsonModel + /// Frontend Sub Resource of Traffic Controller. + public partial class TrafficControllerFrontendData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TrafficControllerFrontendData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,167 +38,144 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode /// 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(TrafficControllerFrontendData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (options.Format != "W" && Optional.IsDefined(Fqdn)) - { - writer.WritePropertyName("fqdn"u8); - writer.WriteStringValue(Fqdn); - } - if (Optional.IsDefined(SecurityPolicyConfigurations)) + if (Optional.IsDefined(Properties)) { - writer.WritePropertyName("securityPolicyConfigurations"u8); - writer.WriteObjectValue(SecurityPolicyConfigurations, options); + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) - { - writer.WritePropertyName("provisioningState"u8); - writer.WriteStringValue(ProvisioningState.Value.ToString()); - } - writer.WriteEndObject(); } - TrafficControllerFrontendData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TrafficControllerFrontendData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (TrafficControllerFrontendData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData 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(TrafficControllerFrontendData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTrafficControllerFrontendData(document.RootElement, options); } - internal static TrafficControllerFrontendData DeserializeTrafficControllerFrontendData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TrafficControllerFrontendData DeserializeTrafficControllerFrontendData(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; + ResourceType resourceType = default; SystemData systemData = default; - string fqdn = default; - SecurityPolicyConfigurations securityPolicyConfigurations = default; - ServiceNetworkingProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + FrontendProperties 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)) { - location = new AzureLocation(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("type"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerServiceNetworkingContext.Default); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { - property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) { - if (property0.NameEquals("fqdn"u8)) - { - fqdn = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("securityPolicyConfigurations"u8)) + if (prop0.Value.ValueKind == JsonValueKind.Null) { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - securityPolicyConfigurations = SecurityPolicyConfigurations.DeserializeSecurityPolicyConfigurations(property0.Value, options); - continue; + dictionary.Add(prop0.Name, null); } - if (property0.NameEquals("provisioningState"u8)) + else { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - provisioningState = new ServiceNetworkingProvisioningState(property0.Value.GetString()); - continue; + dictionary.Add(prop0.Name, prop0.Value.GetString()); } } + tags = dictionary; + continue; + } + if (prop.NameEquals("location"u8)) + { + location = new AzureLocation(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = FrontendProperties.DeserializeFrontendProperties(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 TrafficControllerFrontendData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - fqdn, - securityPolicyConfigurations, - provisioningState, - serializedAdditionalRawData); + properties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// 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": @@ -201,15 +185,20 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - TrafficControllerFrontendData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + TrafficControllerFrontendData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (TrafficControllerFrontendData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTrafficControllerFrontendData(document.RootElement, options); } default: @@ -217,6 +206,26 @@ TrafficControllerFrontendData IPersistableModel.C } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(TrafficControllerFrontendData trafficControllerFrontendData) + { + if (trafficControllerFrontendData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(trafficControllerFrontendData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static TrafficControllerFrontendData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTrafficControllerFrontendData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.cs index 4cf9ccff1b76..e0d28ed8b7ad 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendData.cs @@ -13,79 +13,69 @@ namespace Azure.ResourceManager.ServiceNetworking { - /// - /// A class representing the TrafficControllerFrontend data model. - /// Frontend Sub Resource of Traffic Controller. - /// + /// Frontend Sub Resource of Traffic Controller. public partial class TrafficControllerFrontendData : TrackedResourceData { - /// - /// 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 location. + /// The geo-location where the resource lives. public TrafficControllerFrontendData(AzureLocation location) : base(location) { } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. - /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. - /// Frontend Security Policy Configuration. - /// Provisioning State of Traffic Controller Frontend Resource. - /// Keeps track of any properties unknown to the library. - internal TrafficControllerFrontendData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string fqdn, SecurityPolicyConfigurations securityPolicyConfigurations, ServiceNetworkingProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The resource-specific properties for this resource. + internal TrafficControllerFrontendData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, FrontendProperties properties) : base(id, name, resourceType, systemData, tags, location) { - Fqdn = fqdn; - SecurityPolicyConfigurations = securityPolicyConfigurations; - ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; } - /// Initializes a new instance of for deserialization. - internal TrafficControllerFrontendData() + /// The resource-specific properties for this resource. + internal FrontendProperties Properties { get; set; } + + /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. + public string Fqdn { + get + { + return Properties is null ? default : Properties.Fqdn; + } } - /// The Fully Qualified Domain Name of the DNS record associated to a Traffic Controller frontend. - public string Fqdn { get; } /// Frontend Security Policy Configuration. - public SecurityPolicyConfigurations SecurityPolicyConfigurations { get; set; } + public SecurityPolicyConfigurations SecurityPolicyConfigurations + { + get + { + return Properties is null ? default : Properties.SecurityPolicyConfigurations; + } + set + { + if (Properties is null) + { + Properties = new FrontendProperties(); + } + Properties.SecurityPolicyConfigurations = value; + } + } + /// Provisioning State of Traffic Controller Frontend Resource. - public ServiceNetworkingProvisioningState? ProvisioningState { get; } + public ServiceNetworkingProvisioningState? ProvisioningState + { + get + { + return Properties is null ? default : Properties.ProvisioningState; + } + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.Serialization.cs index b33c786b8120..e7477204bda7 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.ServiceNetworking { + /// public partial class TrafficControllerFrontendResource : IJsonModel { - private static TrafficControllerFrontendData s_dataDeserializationInstance; - private static TrafficControllerFrontendData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficControllerFrontendData(); + + /// 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); - TrafficControllerFrontendData 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. + TrafficControllerFrontendData 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, AzureResourceManagerServiceNetworkingContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficControllerFrontendData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerServiceNetworkingContext.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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.cs index ef89d356a216..1703f2fbc738 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerFrontendResource.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.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { /// - /// A Class representing a TrafficControllerFrontend 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 GetTrafficControllerFrontendResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficControllerFrontend method. + /// A class representing a TrafficControllerFrontend 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 GetTrafficControllerFrontends method. /// public partial class TrafficControllerFrontendResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The trafficControllerName. - /// The frontendName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficControllerFrontendFrontendsInterfaceClientDiagnostics; - private readonly FrontendsInterfaceRestOperations _trafficControllerFrontendFrontendsInterfaceRestClient; + private readonly ClientDiagnostics _frontendsInterfaceClientDiagnostics; + private readonly FrontendsInterface _frontendsInterfaceRestClient; private readonly TrafficControllerFrontendData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.ServiceNetworking/trafficControllers/frontends"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerFrontendResource for mocking. protected TrafficControllerFrontendResource() { } - /// 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 TrafficControllerFrontendResource(ArmClient client, TrafficControllerFrontendData data) : this(client, data.Id) @@ -56,71 +46,93 @@ internal TrafficControllerFrontendResource(ArmClient client, TrafficControllerFr _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 TrafficControllerFrontendResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerFrontendFrontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficControllerFrontendFrontendsInterfaceApiVersion); - _trafficControllerFrontendFrontendsInterfaceRestClient = new FrontendsInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerFrontendFrontendsInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficControllerFrontendApiVersion); + _frontendsInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); + _frontendsInterfaceRestClient = new FrontendsInterface(_frontendsInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerFrontendApiVersion ?? "2025-03-01-preview"); + 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 TrafficControllerFrontendData 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 trafficControllerName. + /// The frontendName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName, string frontendName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}"; + 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); + } } /// /// Get a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Get + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Get"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Get"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +146,41 @@ public virtual async Task> GetAsync( /// Get a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Get + /// Operation Id. + /// FrontendsInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Get"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Get"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,39 +191,49 @@ public virtual Response Get(CancellationToken } /// - /// Delete a Frontend + /// Update a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Delete + /// Operation Id. + /// FrontendsInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Update"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, _trafficControllerFrontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerFrontendPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -213,39 +243,49 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a Frontend + /// Update a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Delete + /// Operation Id. + /// FrontendsInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Update(TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Update"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_trafficControllerFrontendFrontendsInterfaceClientDiagnostics, Pipeline, _trafficControllerFrontendFrontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, TrafficControllerFrontendPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -255,39 +295,46 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a Frontend + /// Delete a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Update + /// Operation Id. + /// FrontendsInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual async Task> UpdateAsync(TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Update"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Delete"); scope.Start(); try { - var response = await _trafficControllerFrontendFrontendsInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_frontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -297,39 +344,46 @@ public virtual async Task> UpdateAsy } /// - /// Update a Frontend + /// Delete a Frontend /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName}. /// /// - /// Operation Id - /// Frontend_Update + /// Operation Id. + /// FrontendsInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual Response Update(TrafficControllerFrontendPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Update"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.Delete"); scope.Start(); try { - var response = _trafficControllerFrontendFrontendsInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); - return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_frontendsInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -338,27 +392,7 @@ public virtual Response Update(TrafficControl } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -368,29 +402,35 @@ public virtual async Task> AddTagAsy Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.AddTag"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerFrontendPatch(); - foreach (var tag in current.Tags) + TrafficControllerFrontendData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); + 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) @@ -400,27 +440,7 @@ public virtual async Task> AddTagAsy } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -430,29 +450,35 @@ public virtual Response AddTag(string key, st Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.AddTag"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerFrontendPatch(); - foreach (var tag in current.Tags) + TrafficControllerFrontendData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); + 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) @@ -462,54 +488,40 @@ public virtual Response AddTag(string key, st } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.SetTags"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerFrontendPatch(); + TrafficControllerFrontendData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); 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) @@ -519,54 +531,40 @@ public virtual async Task> SetTagsAs } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.SetTags"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerFrontendPatch(); + TrafficControllerFrontendData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); 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) @@ -576,27 +574,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -604,29 +582,35 @@ public virtual async Task> RemoveTag { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.RemoveTag"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 _trafficControllerFrontendFrontendsInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerFrontendPatch(); - foreach (var tag in current.Tags) + TrafficControllerFrontendData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); + 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) @@ -636,27 +620,7 @@ public virtual async Task> RemoveTag } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -664,29 +628,35 @@ public virtual Response RemoveTag(string key, { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerFrontendFrontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.RemoveTag"); + using DiagnosticScope scope = _frontendsInterfaceClientDiagnostics.CreateScope("TrafficControllerFrontendResource.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 = _trafficControllerFrontendFrontendsInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerFrontendResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _frontendsInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerFrontendData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerFrontendResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerFrontendPatch(); - foreach (var tag in current.Tags) + TrafficControllerFrontendData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerFrontendPatch patch = new TrafficControllerFrontendPatch(); + 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) diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.Serialization.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.Serialization.cs index f33cb6c76ba4..5f11bd025f51 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.Serialization.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.Serialization.cs @@ -8,22 +8,33 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; +using Azure.ResourceManager; namespace Azure.ResourceManager.ServiceNetworking { - public partial class TrafficControllerResource : IJsonModel + /// + public partial class TrafficControllerResource : ArmResource, IJsonModel { - private static TrafficControllerData s_dataDeserializationInstance; - private static TrafficControllerData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new TrafficControllerData(); + + /// 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); - TrafficControllerData 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. + TrafficControllerData 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, AzureResourceManagerServiceNetworkingContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. TrafficControllerData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerServiceNetworkingContext.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/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.cs index ab5351efba6d..6221efe47618 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/src/Generated/TrafficControllerResource.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.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking { /// - /// A Class representing a TrafficController 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 GetTrafficControllerResource method. - /// Otherwise you can get one from its parent resource using the GetTrafficController method. + /// A class representing a TrafficController 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 GetTrafficControllers method. /// public partial class TrafficControllerResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The trafficControllerName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _trafficControllerTrafficControllerInterfaceClientDiagnostics; - private readonly TrafficControllerInterfaceRestOperations _trafficControllerTrafficControllerInterfaceRestClient; + private readonly ClientDiagnostics _trafficControllerInterfaceClientDiagnostics; + private readonly TrafficControllerInterface _trafficControllerInterfaceRestClient; private readonly TrafficControllerData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.ServiceNetworking/trafficControllers"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of TrafficControllerResource for mocking. protected TrafficControllerResource() { } - /// 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 TrafficControllerResource(ArmClient client, TrafficControllerData data) : this(client, data.Id) @@ -56,278 +46,92 @@ internal TrafficControllerResource(ArmClient client, TrafficControllerData data) _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 TrafficControllerResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _trafficControllerTrafficControllerInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string trafficControllerTrafficControllerInterfaceApiVersion); - _trafficControllerTrafficControllerInterfaceRestClient = new TrafficControllerInterfaceRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, trafficControllerTrafficControllerInterfaceApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string trafficControllerApiVersion); + _trafficControllerInterfaceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceNetworking", ResourceType.Namespace, Diagnostics); + _trafficControllerInterfaceRestClient = new TrafficControllerInterface(_trafficControllerInterfaceClientDiagnostics, Pipeline, Endpoint, trafficControllerApiVersion ?? "2025-03-01-preview"); + 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 TrafficControllerData 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 TrafficControllerAssociationResources in the TrafficController. - /// An object representing collection of TrafficControllerAssociationResources and their operations over a TrafficControllerAssociationResource. - public virtual TrafficControllerAssociationCollection GetTrafficControllerAssociations() - { - return GetCachedClient(client => new TrafficControllerAssociationCollection(client, Id)); - } - - /// - /// Get a Association - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Name of Association. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetTrafficControllerAssociationAsync(string associationName, CancellationToken cancellationToken = default) - { - return await GetTrafficControllerAssociations().GetAsync(associationName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a Association - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/associations/{associationName} - /// - /// - /// Operation Id - /// Association_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Name of Association. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetTrafficControllerAssociation(string associationName, CancellationToken cancellationToken = default) - { - return GetTrafficControllerAssociations().Get(associationName, cancellationToken); - } - - /// Gets a collection of TrafficControllerFrontendResources in the TrafficController. - /// An object representing collection of TrafficControllerFrontendResources and their operations over a TrafficControllerFrontendResource. - public virtual TrafficControllerFrontendCollection GetTrafficControllerFrontends() - { - return GetCachedClient(client => new TrafficControllerFrontendCollection(client, Id)); - } - - /// - /// Get a Frontend - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Frontends. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetTrafficControllerFrontendAsync(string frontendName, CancellationToken cancellationToken = default) - { - return await GetTrafficControllerFrontends().GetAsync(frontendName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a Frontend - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/frontends/{frontendName} - /// - /// - /// Operation Id - /// Frontend_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// Frontends. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetTrafficControllerFrontend(string frontendName, CancellationToken cancellationToken = default) - { - return GetTrafficControllerFrontends().Get(frontendName, cancellationToken); - } - - /// Gets a collection of ApplicationGatewayForContainersSecurityPolicyResources in the TrafficController. - /// An object representing collection of ApplicationGatewayForContainersSecurityPolicyResources and their operations over a ApplicationGatewayForContainersSecurityPolicyResource. - public virtual ApplicationGatewayForContainersSecurityPolicyCollection GetApplicationGatewayForContainersSecurityPolicies() - { - return GetCachedClient(client => new ApplicationGatewayForContainersSecurityPolicyCollection(client, Id)); - } - - /// - /// Get a SecurityPolicy - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// SecurityPolicy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetApplicationGatewayForContainersSecurityPolicyAsync(string securityPolicyName, CancellationToken cancellationToken = default) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The trafficControllerName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string trafficControllerName) { - return await GetApplicationGatewayForContainersSecurityPolicies().GetAsync(securityPolicyName, cancellationToken).ConfigureAwait(false); + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}"; + return new ResourceIdentifier(resourceId); } - /// - /// Get a SecurityPolicy - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}/securityPolicies/{securityPolicyName} - /// - /// - /// Operation Id - /// SecurityPolicy_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// - /// SecurityPolicy. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetApplicationGatewayForContainersSecurityPolicy(string securityPolicyName, CancellationToken cancellationToken = default) + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) { - return GetApplicationGatewayForContainersSecurityPolicies().Get(securityPolicyName, cancellationToken); + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Get + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Get"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Get"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -341,33 +145,41 @@ public virtual async Task> GetAsync(Cancella /// Get a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Get + /// Operation Id. + /// TrafficControllerInterface_Get. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Get"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Get"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -378,39 +190,49 @@ public virtual Response Get(CancellationToken cancell } /// - /// Delete a TrafficController + /// Update a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Delete + /// Operation Id. + /// TrafficControllerInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(TrafficControllerPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Update"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new ServiceNetworkingArmOperation(_trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, _trafficControllerTrafficControllerInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, TrafficControllerPatch.ToRequestContent(patch), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -420,39 +242,49 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a TrafficController + /// Update a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Delete + /// Operation Id. + /// TrafficControllerInterface_Update. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual Response Update(TrafficControllerPatch patch, CancellationToken cancellationToken = default) { - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Update"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new ServiceNetworkingArmOperation(_trafficControllerTrafficControllerInterfaceClientDiagnostics, Pipeline, _trafficControllerTrafficControllerInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); - if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); - return operation; + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, TrafficControllerPatch.ToRequestContent(patch), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) { @@ -462,39 +294,46 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a TrafficController + /// Delete a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Update + /// Operation Id. + /// TrafficControllerInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual async Task> UpdateAsync(TrafficControllerPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Update"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Delete"); scope.Start(); try { - var response = await _trafficControllerTrafficControllerInterfaceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_trafficControllerInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } + return operation; } catch (Exception e) { @@ -504,39 +343,46 @@ public virtual async Task> UpdateAsync(Traff } /// - /// Update a TrafficController + /// Delete a TrafficController /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName}. /// /// - /// Operation Id - /// TrafficController_Update + /// Operation Id. + /// TrafficControllerInterface_Delete. /// /// - /// Default Api Version - /// 2025-03-01-preview + /// Default Api Version. + /// 2025-03-01-preview. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// - /// The resource properties to be updated. + /// 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. - /// is null. - public virtual Response Update(TrafficControllerPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Update"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.Delete"); scope.Start(); try { - var response = _trafficControllerTrafficControllerInterfaceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + ServiceNetworkingArmOperation operation = new ServiceNetworkingArmOperation(_trafficControllerInterfaceClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + { + operation.WaitForCompletionResponse(cancellationToken); + } + return operation; } catch (Exception e) { @@ -545,27 +391,7 @@ public virtual Response Update(TrafficControllerPatch } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -575,29 +401,35 @@ public virtual async Task> AddTagAsync(strin Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.AddTag"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerPatch(); - foreach (var tag in current.Tags) + TrafficControllerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); + 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) @@ -607,27 +439,7 @@ public virtual async Task> AddTagAsync(strin } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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. @@ -637,29 +449,35 @@ public virtual Response AddTag(string key, string val Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.AddTag"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerPatch(); - foreach (var tag in current.Tags) + TrafficControllerData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); + 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) @@ -669,54 +487,40 @@ public virtual Response AddTag(string key, string val } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.SetTags"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerPatch(); + TrafficControllerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); 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) @@ -726,54 +530,40 @@ public virtual async Task> SetTagsAsync(IDic } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-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 = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.SetTags"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerPatch(); + TrafficControllerData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); 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) @@ -783,27 +573,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -811,29 +581,35 @@ public virtual async Task> RemoveTagAsync(st { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.RemoveTag"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 _trafficControllerTrafficControllerInterfaceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new TrafficControllerPatch(); - foreach (var tag in current.Tags) + TrafficControllerData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); + 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) @@ -843,27 +619,7 @@ public virtual async Task> RemoveTagAsync(st } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceNetworking/trafficControllers/{trafficControllerName} - /// - /// - /// Operation Id - /// TrafficController_Get - /// - /// - /// Default Api Version - /// 2025-03-01-preview - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -871,29 +627,35 @@ public virtual Response RemoveTag(string key, Cancell { Argument.AssertNotNull(key, nameof(key)); - using var scope = _trafficControllerTrafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.RemoveTag"); + using DiagnosticScope scope = _trafficControllerInterfaceClientDiagnostics.CreateScope("TrafficControllerResource.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 = _trafficControllerTrafficControllerInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new TrafficControllerResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _trafficControllerInterfaceRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(TrafficControllerData.FromResponse(result), result); + return Response.FromValue(new TrafficControllerResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new TrafficControllerPatch(); - foreach (var tag in current.Tags) + TrafficControllerData current = Get(cancellationToken: cancellationToken).Value.Data; + TrafficControllerPatch patch = new TrafficControllerPatch(); + 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) @@ -902,5 +664,104 @@ public virtual Response RemoveTag(string key, Cancell throw; } } + + /// Gets a collection of TrafficControllerAssociations in the . + /// An object representing collection of TrafficControllerAssociations and their operations over a TrafficControllerAssociationResource. + public virtual TrafficControllerAssociationCollection GetTrafficControllerAssociations() + { + return GetCachedClient(client => new TrafficControllerAssociationCollection(client, Id)); + } + + /// Get a Association. + /// Name of Association. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrafficControllerAssociationAsync(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + return await GetTrafficControllerAssociations().GetAsync(associationName, cancellationToken).ConfigureAwait(false); + } + + /// Get a Association. + /// Name of Association. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrafficControllerAssociation(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + return GetTrafficControllerAssociations().Get(associationName, cancellationToken); + } + + /// Gets a collection of TrafficControllerFrontends in the . + /// An object representing collection of TrafficControllerFrontends and their operations over a TrafficControllerFrontendResource. + public virtual TrafficControllerFrontendCollection GetTrafficControllerFrontends() + { + return GetCachedClient(client => new TrafficControllerFrontendCollection(client, Id)); + } + + /// Get a Frontend. + /// Frontends. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetTrafficControllerFrontendAsync(string frontendName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); + + return await GetTrafficControllerFrontends().GetAsync(frontendName, cancellationToken).ConfigureAwait(false); + } + + /// Get a Frontend. + /// Frontends. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetTrafficControllerFrontend(string frontendName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(frontendName, nameof(frontendName)); + + return GetTrafficControllerFrontends().Get(frontendName, cancellationToken); + } + + /// Gets a collection of ApplicationGatewayForContainersSecurityPolicies in the . + /// An object representing collection of ApplicationGatewayForContainersSecurityPolicies and their operations over a ApplicationGatewayForContainersSecurityPolicyResource. + public virtual ApplicationGatewayForContainersSecurityPolicyCollection GetApplicationGatewayForContainersSecurityPolicies() + { + return GetCachedClient(client => new ApplicationGatewayForContainersSecurityPolicyCollection(client, Id)); + } + + /// Get a SecurityPolicy. + /// SecurityPolicy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetApplicationGatewayForContainersSecurityPolicyAsync(string securityPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); + + return await GetApplicationGatewayForContainersSecurityPolicies().GetAsync(securityPolicyName, cancellationToken).ConfigureAwait(false); + } + + /// Get a SecurityPolicy. + /// SecurityPolicy. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetApplicationGatewayForContainersSecurityPolicy(string securityPolicyName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(securityPolicyName, nameof(securityPolicyName)); + + return GetApplicationGatewayForContainersSecurityPolicies().Get(securityPolicyName, cancellationToken); + } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tests/Tests/TrafficControllerTests.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tests/Tests/TrafficControllerTests.cs index 988bf052dce3..95aeb30acfa6 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tests/Tests/TrafficControllerTests.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tests/Tests/TrafficControllerTests.cs @@ -11,6 +11,7 @@ using NUnit.Framework; using Azure.ResourceManager.Network.Models; using Azure.ResourceManager.ServiceNetworking.Tests; +using Azure.ResourceManager.ServiceNetworking.Models; namespace Azure.ResourceManager.ServiceNetworking.TrafficController.Tests.Tests { @@ -48,6 +49,8 @@ private async Task> CreateTrafficControl //Obtaining the Collection object of TrafficController to perform the Create/PUT operation. TrafficControllerCollection trafficControllerCollection = GetTrafficControllers(resourceGroup); TrafficControllerData tcgw = new TrafficControllerData(location); + // Access a property to ensure Properties object is initialized for serialization + _ = tcgw.ConfigurationEndpoints; var tcTask = await trafficControllerCollection.CreateOrUpdateAsync(WaitUntil.Completed, tcName, tcgw); return tcTask; } @@ -59,7 +62,7 @@ private async Task GetTrafficControllerAsync(string r return await trafficControllerCollection.GetAsync(tcName); } - private async void DeleteTrafficControllerAsync(TrafficControllerResource tc) + private async Task DeleteTrafficControllerAsync(TrafficControllerResource tc) { await tc.DeleteAsync(WaitUntil.Started); } @@ -74,6 +77,8 @@ private async Task> CreateFronte { Location = location }; + // Access a property to ensure Properties object is initialized for serialization + _ = fnd.ProvisioningState; //Performing the Create/PUT operation and returning the result. return await frontends.CreateOrUpdateAsync(WaitUntil.Completed, frontendName, fnd); } @@ -100,7 +105,7 @@ private async Task DeleteFrontendResource(ResourceGroupResource rgResource, Traf } TrafficControllerFrontendCollection frontends = GetFrontends(tc); PublicIPAddressCollection publicIPAddresses = rgResource.GetPublicIPAddresses(); - PublicIPAddressResource pip = publicIPAddresses.GetAsync(pipName).Result; + PublicIPAddressResource pip = await publicIPAddresses.GetAsync(pipName); await pip.DeleteAsync(WaitUntil.Started); } @@ -128,7 +133,8 @@ private async Task> CreateAss AddressPrefixes = { "10.225.0.0/16" }, }; _resourceNames["tc-vnet"] = vnetName; - VirtualNetworkResource vnet = vnets.CreateOrUpdateAsync(WaitUntil.Completed, vnetName, vnetData).Result.Value; + var vnetOperation = await vnets.CreateOrUpdateAsync(WaitUntil.Completed, vnetName, vnetData); + VirtualNetworkResource vnet = vnetOperation.Value; SubnetCollection subnets = vnet.GetSubnets(); SubnetData subnetData = new SubnetData() { @@ -141,21 +147,23 @@ private async Task> CreateAss }; subnetData.Delegations.Add(trafficControllerServiceDelegation); _resourceNames["tc-subnet"] = subnetName; - subnet = subnets.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, subnetData).Result.Value; + var subnetOperation = await subnets.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, subnetData); + subnet = subnetOperation.Value; } //Association Data object that is used to create the new frontend object. TrafficControllerAssociationData associationData = new TrafficControllerAssociationData(location) { - AssociationType = null, SubnetId = subnet.Id, Location = location, }; + // Ensure Properties object is initialized with default AssociationType + associationData.AssociationType = TrafficControllerAssociationType.Subnets; //Performing the Create/PUT operation return await associations.CreateOrUpdateAsync(WaitUntil.Completed, associationName, associationData); } - private async void DeleteAssociationResourcesAsync(string associationName, TrafficControllerResource tc, string resourceGroup) + private async Task DeleteAssociationResourcesAsync(string associationName, TrafficControllerResource tc, string resourceGroup) { string vnetName; string subnetName; @@ -172,9 +180,9 @@ private async void DeleteAssociationResourcesAsync(string associationName, Traff TrafficControllerAssociationCollection associations = GetAssociations(tc); VirtualNetworkCollection vnets = GetVirtualNetworks(resourceGroup); - VirtualNetworkResource vnet = vnets.GetAsync(vnetName).Result; + VirtualNetworkResource vnet = await vnets.GetAsync(vnetName); - SubnetResource subnet = vnet.GetSubnetAsync(subnetName).Result; + SubnetResource subnet = await vnet.GetSubnetAsync(subnetName); await subnet.DeleteAsync(WaitUntil.Started); await vnet.DeleteAsync(WaitUntil.Started); } @@ -192,7 +200,7 @@ private async Task GetAssociationAsync(str return await associations.GetAsync(associationName); } - private async void DeleteResourceGroupAsync(ResourceGroupResource rgResource) + private async Task DeleteResourceGroupAsync(ResourceGroupResource rgResource) { await rgResource.DeleteAsync(WaitUntil.Started); } @@ -209,22 +217,22 @@ public async Task TrafficControllerTest() ResourceGroupResource rgResource = CreateResourceGroup(Subscription, resourceGroupName, location); resourceGroupName = rgResource.Data.Name; //Testing PUT Operation - TrafficControllerResource tcCreate = CreateTrafficControllerAsync(location, resourceGroupName, tcName).Result.Value; + TrafficControllerResource tcCreate = (await CreateTrafficControllerAsync(location, resourceGroupName, tcName)).Value; Assert.NotNull(tcCreate, "Traffic Controller is Null"); Assert.AreEqual(tcCreate.Data.Name, tcName); - Assert.AreEqual(tcCreate.Data.TrafficControllerProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(tcCreate.Data.TrafficControllerProvisioningState?.ToString(), "Succeeded"); //Testing GET Operation - TrafficControllerResource tcGet = GetTrafficControllerAsync(resourceGroupName, tcName).Result; + TrafficControllerResource tcGet = await GetTrafficControllerAsync(resourceGroupName, tcName); Assert.NotNull(tcGet, "Traffic Controller is Null"); Assert.AreEqual(tcGet.Data.Name, tcName); - Assert.AreEqual(tcGet.Data.TrafficControllerProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(tcGet.Data.TrafficControllerProvisioningState?.ToString(), "Succeeded"); //Testing DELETE Operation var tcDelete = await tcGet.DeleteAsync(WaitUntil.Completed); var deleteResponse = tcDelete.WaitForCompletionResponse(); Assert.AreEqual(deleteResponse.IsError, false); - DeleteResourceGroupAsync(rgResource); + await DeleteResourceGroupAsync(rgResource); } [Test] @@ -240,20 +248,20 @@ public async Task FrontendsTest() resourceGroupName = rgResource.Data.Name; //Creating Traffic Controller and obtaining Frontends object for performing tests of CRUD functions - TrafficControllerResource tc = CreateTrafficControllerAsync(location, resourceGroupName, tcName).Result.Value; + TrafficControllerResource tc = (await CreateTrafficControllerAsync(location, resourceGroupName, tcName)).Value; //Testing PUT Operation string frontendName = Recording.GenerateAssetName("tc-frontend"); - var frontendCreation = CreateFrontendAsync(rgResource, frontendName, tc, location).Result.Value; + var frontendCreation = (await CreateFrontendAsync(rgResource, frontendName, tc, location)).Value; Assert.IsNotNull(frontendCreation); Assert.AreEqual(frontendCreation.Data.Name, frontendName); - Assert.AreEqual(frontendCreation.Data.ProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(frontendCreation.Data.ProvisioningState?.ToString(), "Succeeded"); //Testing GET Operation - var frontendGet = GetFrontendAsync(frontendName, tc).Result; + var frontendGet = await GetFrontendAsync(frontendName, tc); Assert.IsNotNull(frontendGet); Assert.AreEqual(frontendGet.Data.Name, frontendName); - Assert.AreEqual(frontendGet.Data.ProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(frontendGet.Data.ProvisioningState?.ToString(), "Succeeded"); //Testing DELETE Operation var frontendDelete = await frontendGet.DeleteAsync(WaitUntil.Completed); @@ -261,8 +269,8 @@ public async Task FrontendsTest() Assert.AreEqual(deleteResponse.IsError, false); //Deleting Traffic Controller await DeleteFrontendResource(rgResource, tc); - DeleteTrafficControllerAsync(tc); - DeleteResourceGroupAsync(rgResource); + await DeleteTrafficControllerAsync(tc); + await DeleteResourceGroupAsync(rgResource); } [Test] @@ -278,26 +286,26 @@ public async Task AssociationTest() resourceGroupName = rgResource.Data.Name; //Creating Traffic Controller and obtaining Associations object for performing tests of CRUD functions - TrafficControllerResource tc = CreateTrafficControllerAsync(location, resourceGroupName, tcName).Result.Value; + TrafficControllerResource tc = (await CreateTrafficControllerAsync(location, resourceGroupName, tcName)).Value; string associationName = Recording.GenerateAssetName("tc-association"); - TrafficControllerAssociationResource associationCreate = CreateAssociationAsync(resourceGroupName, associationName, tc, location).Result.Value; + TrafficControllerAssociationResource associationCreate = (await CreateAssociationAsync(resourceGroupName, associationName, tc, location)).Value; Assert.IsNotNull(associationCreate); Assert.AreEqual(associationCreate.Data.Name, associationName); - Assert.AreEqual(associationCreate.Data.ProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(associationCreate.Data.ProvisioningState?.ToString(), "Succeeded"); //Testing the GET Operation - TrafficControllerAssociationResource associationGet = GetAssociationAsync(associationName, tc).Result; + TrafficControllerAssociationResource associationGet = await GetAssociationAsync(associationName, tc); Assert.IsNotNull(associationGet); Assert.AreEqual(associationGet.Data.Name, associationName); - Assert.AreEqual(associationGet.Data.ProvisioningState.ToString(), "Succeeded"); + Assert.AreEqual(associationGet.Data.ProvisioningState?.ToString(), "Succeeded"); //Testing DELETE Operation await DeleteAssociation(associationGet); //Deleting Traffic Controller - DeleteAssociationResourcesAsync(associationName, tc, resourceGroupName); - DeleteTrafficControllerAsync(tc); - DeleteResourceGroupAsync(rgResource); + await DeleteAssociationResourcesAsync(associationName, tc, resourceGroupName); + await DeleteTrafficControllerAsync(tc); + await DeleteResourceGroupAsync(rgResource); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tsp-location.yaml b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tsp-location.yaml index 00adf32e016f..f2aa56953b24 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tsp-location.yaml +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/tsp-location.yaml @@ -1,4 +1,5 @@ directory: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/ServiceNetworking -commit: 52fc376d009c4d96b89cfc410c11a38358a18f5b +commit: 217f332d35760fbe2034475504284f5d84bdd968 repo: Azure/azure-rest-api-specs -emitterPackageJsonPath: eng/legacy-emitter-package.json +# emitterPackageJsonPath: eng/legacy-emitter-package.json +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"