diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterCollection.cs new file mode 100644 index 000000000000..e8fa0b191fb8 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterCollection.cs @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NetworkSecurityPerimeterCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_PutNetworkSecurityPerimeter() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterPut.json + // this example is just showing the usage of "NetworkSecurityPerimeters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkSecurityPerimeterResource + NetworkSecurityPerimeterCollection collection = resourceGroupResource.GetNetworkSecurityPerimeters(); + + // invoke the operation + string networkSecurityPerimeterName = "nsp1"; + NetworkSecurityPerimeterData data = new NetworkSecurityPerimeterData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkSecurityPerimeterName, data); + NetworkSecurityPerimeterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NetworkSecurityPerimeterGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterGet.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkSecurityPerimeterResource + NetworkSecurityPerimeterCollection collection = resourceGroupResource.GetNetworkSecurityPerimeters(); + + // invoke the operation + string networkSecurityPerimeterName = "nsp1"; + NetworkSecurityPerimeterResource result = await collection.GetAsync(networkSecurityPerimeterName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListNetworkSecurityPerimeter() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterList.json + // this example is just showing the usage of "NetworkSecurityPerimeters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkSecurityPerimeterResource + NetworkSecurityPerimeterCollection collection = resourceGroupResource.GetNetworkSecurityPerimeters(); + + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NetworkSecurityPerimeterGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterGet.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkSecurityPerimeterResource + NetworkSecurityPerimeterCollection collection = resourceGroupResource.GetNetworkSecurityPerimeters(); + + // invoke the operation + string networkSecurityPerimeterName = "nsp1"; + bool result = await collection.ExistsAsync(networkSecurityPerimeterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NetworkSecurityPerimeterGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterGet.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkSecurityPerimeterResource + NetworkSecurityPerimeterCollection collection = resourceGroupResource.GetNetworkSecurityPerimeters(); + + // invoke the operation + string networkSecurityPerimeterName = "nsp1"; + NullableResponse response = await collection.GetIfExistsAsync(networkSecurityPerimeterName); + NetworkSecurityPerimeterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterResource.cs new file mode 100644 index 000000000000..afe19708173a --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityPerimeterResource.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NetworkSecurityPerimeterResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NetworkSecurityPerimeterGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterGet.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // invoke the operation + NetworkSecurityPerimeterResource result = await networkSecurityPerimeter.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NetworkSecurityPerimeterDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterDelete.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "testNSP1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // invoke the operation + await networkSecurityPerimeter.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_PatchNetworkSecurityPerimeter() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterPatch.json + // this example is just showing the usage of "NetworkSecurityPerimeters_Patch" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // invoke the operation + NetworkSecurityPerimeterPatch patch = new NetworkSecurityPerimeterPatch + { + Tags = +{ +["description"] = "nsp1" +}, + }; + NetworkSecurityPerimeterResource result = await networkSecurityPerimeter.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleCollection.cs new file mode 100644 index 000000000000..35e81b4eb6e4 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleCollection.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspAccessRuleCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_NspAccessRulePut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRulePut.json + // this example is just showing the usage of "NspAccessRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // get the collection of this NspAccessRuleResource + NspAccessRuleCollection collection = nspProfile.GetNspAccessRules(); + + // invoke the operation + string accessRuleName = "accessRule1"; + NspAccessRuleData data = new NspAccessRuleData(default) + { + Direction = AccessRuleDirection.Inbound, + AddressPrefixes = { "10.11.0.0/16", "10.10.1.0/24" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accessRuleName, data); + NspAccessRuleResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspAccessRuleGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleGet.json + // this example is just showing the usage of "NspAccessRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // get the collection of this NspAccessRuleResource + NspAccessRuleCollection collection = nspProfile.GetNspAccessRules(); + + // invoke the operation + string accessRuleName = "accessRule1"; + NspAccessRuleResource result = await collection.GetAsync(accessRuleName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspAccessRulesList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleList.json + // this example is just showing the usage of "NspAccessRules_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // get the collection of this NspAccessRuleResource + NspAccessRuleCollection collection = nspProfile.GetNspAccessRules(); + + // invoke the operation and iterate over the result + await foreach (NspAccessRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspAccessRuleGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleGet.json + // this example is just showing the usage of "NspAccessRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // get the collection of this NspAccessRuleResource + NspAccessRuleCollection collection = nspProfile.GetNspAccessRules(); + + // invoke the operation + string accessRuleName = "accessRule1"; + bool result = await collection.ExistsAsync(accessRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspAccessRuleGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleGet.json + // this example is just showing the usage of "NspAccessRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // get the collection of this NspAccessRuleResource + NspAccessRuleCollection collection = nspProfile.GetNspAccessRules(); + + // invoke the operation + string accessRuleName = "accessRule1"; + NullableResponse response = await collection.GetIfExistsAsync(accessRuleName); + NspAccessRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleResource.cs new file mode 100644 index 000000000000..7db0cebc83a8 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAccessRuleResource.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspAccessRuleResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspAccessRuleGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleGet.json + // this example is just showing the usage of "NspAccessRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAccessRuleResource created on azure + // for more information of creating NspAccessRuleResource, please refer to the document of NspAccessRuleResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + string accessRuleName = "accessRule1"; + ResourceIdentifier nspAccessRuleResourceId = NspAccessRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + NspAccessRuleResource nspAccessRule = client.GetNspAccessRuleResource(nspAccessRuleResourceId); + + // invoke the operation + NspAccessRuleResource result = await nspAccessRule.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspAccessRulesDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleDelete.json + // this example is just showing the usage of "NspAccessRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAccessRuleResource created on azure + // for more information of creating NspAccessRuleResource, please refer to the document of NspAccessRuleResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + string accessRuleName = "accessRule1"; + ResourceIdentifier nspAccessRuleResourceId = NspAccessRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + NspAccessRuleResource nspAccessRule = client.GetNspAccessRuleResource(nspAccessRuleResourceId); + + // invoke the operation + await nspAccessRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_NspAccessRulePut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRulePut.json + // this example is just showing the usage of "NspAccessRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAccessRuleResource created on azure + // for more information of creating NspAccessRuleResource, please refer to the document of NspAccessRuleResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + string accessRuleName = "accessRule1"; + ResourceIdentifier nspAccessRuleResourceId = NspAccessRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + NspAccessRuleResource nspAccessRule = client.GetNspAccessRuleResource(nspAccessRuleResourceId); + + // invoke the operation + NspAccessRuleData data = new NspAccessRuleData(default) + { + Direction = AccessRuleDirection.Inbound, + AddressPrefixes = { "10.11.0.0/16", "10.10.1.0/24" }, + }; + ArmOperation lro = await nspAccessRule.UpdateAsync(WaitUntil.Completed, data); + NspAccessRuleResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAccessRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task PostNspAccessRulesReconcile_NspAccessRuleReconcile() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAccessRuleReconcile.json + // this example is just showing the usage of "NspAccessRulesReconcile_Post" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAccessRuleResource created on azure + // for more information of creating NspAccessRuleResource, please refer to the document of NspAccessRuleResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + string accessRuleName = "accessRuleName1"; + ResourceIdentifier nspAccessRuleResourceId = NspAccessRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + NspAccessRuleResource nspAccessRule = client.GetNspAccessRuleResource(nspAccessRuleResourceId); + + // invoke the operation + BinaryData unknown = BinaryData.FromObjectAsJson(new + { + properties = new object(), + }); + BinaryData result = await nspAccessRule.PostNspAccessRulesReconcileAsync(unknown); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationCollection.cs new file mode 100644 index 000000000000..20fdc00c5675 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationCollection.cs @@ -0,0 +1,202 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspAssociationCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_NspAssociationPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationPut.json + // this example is just showing the usage of "NspAssociations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspAssociationResource + NspAssociationCollection collection = networkSecurityPerimeter.GetNspAssociations(); + + // invoke the operation + string associationName = "association1"; + NspAssociationData data = new NspAssociationData(default) + { + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/{paasSubscriptionId}/resourceGroups/{paasResourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}"), + ProfileId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityPerimeters/nsp1/profiles/{profileName}"), + AccessMode = AssociationAccessMode.Enforced, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associationName, data); + NspAssociationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspAssociationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationGet.json + // this example is just showing the usage of "NspAssociations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspAssociationResource + NspAssociationCollection collection = networkSecurityPerimeter.GetNspAssociations(); + + // invoke the operation + string associationName = "association1"; + NspAssociationResource result = await collection.GetAsync(associationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspAssociationList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationList.json + // this example is just showing the usage of "NspAssociations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspAssociationResource + NspAssociationCollection collection = networkSecurityPerimeter.GetNspAssociations(); + + // invoke the operation and iterate over the result + await foreach (NspAssociationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspAssociationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationGet.json + // this example is just showing the usage of "NspAssociations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspAssociationResource + NspAssociationCollection collection = networkSecurityPerimeter.GetNspAssociations(); + + // invoke the operation + string associationName = "association1"; + bool result = await collection.ExistsAsync(associationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspAssociationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationGet.json + // this example is just showing the usage of "NspAssociations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspAssociationResource + NspAssociationCollection collection = networkSecurityPerimeter.GetNspAssociations(); + + // invoke the operation + string associationName = "association1"; + NullableResponse response = await collection.GetIfExistsAsync(associationName); + NspAssociationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationResource.cs new file mode 100644 index 000000000000..9cadf373ff4f --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspAssociationResource.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspAssociationResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspAssociationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationGet.json + // this example is just showing the usage of "NspAssociations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAssociationResource created on azure + // for more information of creating NspAssociationResource, please refer to the document of NspAssociationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string associationName = "association1"; + ResourceIdentifier nspAssociationResourceId = NspAssociationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + NspAssociationResource nspAssociation = client.GetNspAssociationResource(nspAssociationResourceId); + + // invoke the operation + NspAssociationResource result = await nspAssociation.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspAssociationDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationDelete.json + // this example is just showing the usage of "NspAssociations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAssociationResource created on azure + // for more information of creating NspAssociationResource, please refer to the document of NspAssociationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string associationName = "association1"; + ResourceIdentifier nspAssociationResourceId = NspAssociationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + NspAssociationResource nspAssociation = client.GetNspAssociationResource(nspAssociationResourceId); + + // invoke the operation + await nspAssociation.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_NspAssociationPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationPut.json + // this example is just showing the usage of "NspAssociations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAssociationResource created on azure + // for more information of creating NspAssociationResource, please refer to the document of NspAssociationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string associationName = "association1"; + ResourceIdentifier nspAssociationResourceId = NspAssociationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + NspAssociationResource nspAssociation = client.GetNspAssociationResource(nspAssociationResourceId); + + // invoke the operation + NspAssociationData data = new NspAssociationData(default) + { + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/{paasSubscriptionId}/resourceGroups/{paasResourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}"), + ProfileId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityPerimeters/nsp1/profiles/{profileName}"), + AccessMode = AssociationAccessMode.Enforced, + }; + ArmOperation lro = await nspAssociation.UpdateAsync(WaitUntil.Completed, data); + NspAssociationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task PostNspAssociationReconcile_NspAssociationReconcile() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspAssociationReconcile.json + // this example is just showing the usage of "NspAssociationReconcile_Post" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspAssociationResource created on azure + // for more information of creating NspAssociationResource, please refer to the document of NspAssociationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string associationName = "association1"; + ResourceIdentifier nspAssociationResourceId = NspAssociationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + NspAssociationResource nspAssociation = client.GetNspAssociationResource(nspAssociationResourceId); + + // invoke the operation + BinaryData unknown = BinaryData.FromObjectAsJson(new + { + properties = new object(), + }); + BinaryData result = await nspAssociation.PostNspAssociationReconcileAsync(unknown); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkCollection.cs new file mode 100644 index 000000000000..c3cfe8cd5537 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkCollection.cs @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLinkCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_NspLinksPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkPut.json + // this example is just showing the usage of "NspLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkResource + NspLinkCollection collection = networkSecurityPerimeter.GetNspLinks(); + + // invoke the operation + string linkName = "link1"; + NspLinkData data = new NspLinkData + { + AutoApprovedRemotePerimeterResourceId = "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityPerimeters/nsp2", + LocalInboundProfiles = { "*" }, + RemoteInboundProfiles = { "*" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkName, data); + NspLinkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLinksGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkGet.json + // this example is just showing the usage of "NspLinks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkResource + NspLinkCollection collection = networkSecurityPerimeter.GetNspLinks(); + + // invoke the operation + string linkName = "link1"; + NspLinkResource result = await collection.GetAsync(linkName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspLinkList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkList.json + // this example is just showing the usage of "NspLinks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkResource + NspLinkCollection collection = networkSecurityPerimeter.GetNspLinks(); + + // invoke the operation and iterate over the result + await foreach (NspLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspLinksGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkGet.json + // this example is just showing the usage of "NspLinks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkResource + NspLinkCollection collection = networkSecurityPerimeter.GetNspLinks(); + + // invoke the operation + string linkName = "link1"; + bool result = await collection.ExistsAsync(linkName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspLinksGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkGet.json + // this example is just showing the usage of "NspLinks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkResource + NspLinkCollection collection = networkSecurityPerimeter.GetNspLinks(); + + // invoke the operation + string linkName = "link1"; + NullableResponse response = await collection.GetIfExistsAsync(linkName); + NspLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceCollection.cs new file mode 100644 index 000000000000..46e85c7f475e --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceCollection.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLinkReferenceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLinkReferencesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceGet.json + // this example is just showing the usage of "NspLinkReferences_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkReferenceResource + NspLinkReferenceCollection collection = networkSecurityPerimeter.GetNspLinkReferences(); + + // invoke the operation + string linkReferenceName = "link1-guid"; + NspLinkReferenceResource result = await collection.GetAsync(linkReferenceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkReferenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspLinkReferenceList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceList.json + // this example is just showing the usage of "NspLinkReferences_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkReferenceResource + NspLinkReferenceCollection collection = networkSecurityPerimeter.GetNspLinkReferences(); + + // invoke the operation and iterate over the result + await foreach (NspLinkReferenceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkReferenceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspLinkReferencesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceGet.json + // this example is just showing the usage of "NspLinkReferences_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkReferenceResource + NspLinkReferenceCollection collection = networkSecurityPerimeter.GetNspLinkReferences(); + + // invoke the operation + string linkReferenceName = "link1-guid"; + bool result = await collection.ExistsAsync(linkReferenceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspLinkReferencesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceGet.json + // this example is just showing the usage of "NspLinkReferences_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLinkReferenceResource + NspLinkReferenceCollection collection = networkSecurityPerimeter.GetNspLinkReferences(); + + // invoke the operation + string linkReferenceName = "link1-guid"; + NullableResponse response = await collection.GetIfExistsAsync(linkReferenceName); + NspLinkReferenceResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkReferenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceResource.cs new file mode 100644 index 000000000000..5b6a8e05153c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkReferenceResource.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLinkReferenceResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLinkReferencesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceGet.json + // this example is just showing the usage of "NspLinkReferences_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLinkReferenceResource created on azure + // for more information of creating NspLinkReferenceResource, please refer to the document of NspLinkReferenceResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + string linkReferenceName = "link1-guid"; + ResourceIdentifier nspLinkReferenceResourceId = NspLinkReferenceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + NspLinkReferenceResource nspLinkReference = client.GetNspLinkReferenceResource(nspLinkReferenceResourceId); + + // invoke the operation + NspLinkReferenceResource result = await nspLinkReference.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkReferenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspLinkReferenceDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkReferenceDelete.json + // this example is just showing the usage of "NspLinkReferences_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLinkReferenceResource created on azure + // for more information of creating NspLinkReferenceResource, please refer to the document of NspLinkReferenceResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp2"; + string linkReferenceName = "link1-guid"; + ResourceIdentifier nspLinkReferenceResourceId = NspLinkReferenceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + NspLinkReferenceResource nspLinkReference = client.GetNspLinkReferenceResource(nspLinkReferenceResourceId); + + // invoke the operation + await nspLinkReference.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkResource.cs new file mode 100644 index 000000000000..38c68c4b0839 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLinkResource.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLinkResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLinksGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkGet.json + // this example is just showing the usage of "NspLinks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLinkResource created on azure + // for more information of creating NspLinkResource, please refer to the document of NspLinkResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string linkName = "link1"; + ResourceIdentifier nspLinkResourceId = NspLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + NspLinkResource nspLink = client.GetNspLinkResource(nspLinkResourceId); + + // invoke the operation + NspLinkResource result = await nspLink.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspLinkDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkDelete.json + // this example is just showing the usage of "NspLinks_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLinkResource created on azure + // for more information of creating NspLinkResource, please refer to the document of NspLinkResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string linkName = "link1"; + ResourceIdentifier nspLinkResourceId = NspLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + NspLinkResource nspLink = client.GetNspLinkResource(nspLinkResourceId); + + // invoke the operation + await nspLink.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_NspLinksPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLinkPut.json + // this example is just showing the usage of "NspLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLinkResource created on azure + // for more information of creating NspLinkResource, please refer to the document of NspLinkResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string linkName = "link1"; + ResourceIdentifier nspLinkResourceId = NspLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + NspLinkResource nspLink = client.GetNspLinkResource(nspLinkResourceId); + + // invoke the operation + NspLinkData data = new NspLinkData + { + AutoApprovedRemotePerimeterResourceId = "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityPerimeters/nsp2", + LocalInboundProfiles = { "*" }, + RemoteInboundProfiles = { "*" }, + }; + ArmOperation lro = await nspLink.UpdateAsync(WaitUntil.Completed, data); + NspLinkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationCollection.cs new file mode 100644 index 000000000000..ba091336364f --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationCollection.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLoggingConfigurationCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_NspLoggingConfigurationPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationPut.json + // this example is just showing the usage of "NspLoggingConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLoggingConfigurationResource + NspLoggingConfigurationCollection collection = networkSecurityPerimeter.GetNspLoggingConfigurations(); + + // invoke the operation + string loggingConfigurationName = "instance"; + NspLoggingConfigurationData data = new NspLoggingConfigurationData + { + Properties = new NspLoggingConfigurationProperties + { + EnabledLogCategories = { "NspPublicInboundPerimeterRulesDenied", "NspPublicOutboundPerimeterRulesDenied" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loggingConfigurationName, data); + NspLoggingConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLoggingConfigurationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationGet.json + // this example is just showing the usage of "NspLoggingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLoggingConfigurationResource + NspLoggingConfigurationCollection collection = networkSecurityPerimeter.GetNspLoggingConfigurations(); + + // invoke the operation + string loggingConfigurationName = "instance"; + NspLoggingConfigurationResource result = await collection.GetAsync(loggingConfigurationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspLoggingConfigurationList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationList.json + // this example is just showing the usage of "NspLoggingConfigurations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLoggingConfigurationResource + NspLoggingConfigurationCollection collection = networkSecurityPerimeter.GetNspLoggingConfigurations(); + + // invoke the operation and iterate over the result + await foreach (NspLoggingConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspLoggingConfigurationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationGet.json + // this example is just showing the usage of "NspLoggingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLoggingConfigurationResource + NspLoggingConfigurationCollection collection = networkSecurityPerimeter.GetNspLoggingConfigurations(); + + // invoke the operation + string loggingConfigurationName = "instance"; + bool result = await collection.ExistsAsync(loggingConfigurationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspLoggingConfigurationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationGet.json + // this example is just showing the usage of "NspLoggingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspLoggingConfigurationResource + NspLoggingConfigurationCollection collection = networkSecurityPerimeter.GetNspLoggingConfigurations(); + + // invoke the operation + string loggingConfigurationName = "instance"; + NullableResponse response = await collection.GetIfExistsAsync(loggingConfigurationName); + NspLoggingConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationResource.cs new file mode 100644 index 000000000000..398905c41348 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspLoggingConfigurationResource.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Network.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspLoggingConfigurationResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspLoggingConfigurationGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationGet.json + // this example is just showing the usage of "NspLoggingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLoggingConfigurationResource created on azure + // for more information of creating NspLoggingConfigurationResource, please refer to the document of NspLoggingConfigurationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string loggingConfigurationName = "instance"; + ResourceIdentifier nspLoggingConfigurationResourceId = NspLoggingConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + NspLoggingConfigurationResource nspLoggingConfiguration = client.GetNspLoggingConfigurationResource(nspLoggingConfigurationResourceId); + + // invoke the operation + NspLoggingConfigurationResource result = await nspLoggingConfiguration.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspLoggingConfigurationDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationDelete.json + // this example is just showing the usage of "NspLoggingConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLoggingConfigurationResource created on azure + // for more information of creating NspLoggingConfigurationResource, please refer to the document of NspLoggingConfigurationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string loggingConfigurationName = "instance"; + ResourceIdentifier nspLoggingConfigurationResourceId = NspLoggingConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + NspLoggingConfigurationResource nspLoggingConfiguration = client.GetNspLoggingConfigurationResource(nspLoggingConfigurationResourceId); + + // invoke the operation + await nspLoggingConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_NspLoggingConfigurationPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspLoggingConfigurationPut.json + // this example is just showing the usage of "NspLoggingConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspLoggingConfigurationResource created on azure + // for more information of creating NspLoggingConfigurationResource, please refer to the document of NspLoggingConfigurationResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string loggingConfigurationName = "instance"; + ResourceIdentifier nspLoggingConfigurationResourceId = NspLoggingConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + NspLoggingConfigurationResource nspLoggingConfiguration = client.GetNspLoggingConfigurationResource(nspLoggingConfigurationResourceId); + + // invoke the operation + NspLoggingConfigurationData data = new NspLoggingConfigurationData + { + Properties = new NspLoggingConfigurationProperties + { + EnabledLogCategories = { "NspPublicInboundPerimeterRulesDenied", "NspPublicOutboundPerimeterRulesDenied" }, + }, + }; + ArmOperation lro = await nspLoggingConfiguration.UpdateAsync(WaitUntil.Completed, data); + NspLoggingConfigurationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspLoggingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileCollection.cs new file mode 100644 index 000000000000..65e8562704df --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileCollection.cs @@ -0,0 +1,196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspProfileCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_NspProfilesPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfilePut.json + // this example is just showing the usage of "NspProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspProfileResource + NspProfileCollection collection = networkSecurityPerimeter.GetNspProfiles(); + + // invoke the operation + string profileName = "profile1"; + NspProfileData data = new NspProfileData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + NspProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspProfilesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileGet.json + // this example is just showing the usage of "NspProfiles_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspProfileResource + NspProfileCollection collection = networkSecurityPerimeter.GetNspProfiles(); + + // invoke the operation + string profileName = "profile1"; + NspProfileResource result = await collection.GetAsync(profileName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NspProfilesList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileList.json + // this example is just showing the usage of "NspProfiles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspProfileResource + NspProfileCollection collection = networkSecurityPerimeter.GetNspProfiles(); + + // invoke the operation and iterate over the result + await foreach (NspProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspProfilesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileGet.json + // this example is just showing the usage of "NspProfiles_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspProfileResource + NspProfileCollection collection = networkSecurityPerimeter.GetNspProfiles(); + + // invoke the operation + string profileName = "profile1"; + bool result = await collection.ExistsAsync(profileName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspProfilesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileGet.json + // this example is just showing the usage of "NspProfiles_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkSecurityPerimeterResource created on azure + // for more information of creating NetworkSecurityPerimeterResource, please refer to the document of NetworkSecurityPerimeterResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + ResourceIdentifier networkSecurityPerimeterResourceId = NetworkSecurityPerimeterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + NetworkSecurityPerimeterResource networkSecurityPerimeter = client.GetNetworkSecurityPerimeterResource(networkSecurityPerimeterResourceId); + + // get the collection of this NspProfileResource + NspProfileCollection collection = networkSecurityPerimeter.GetNspProfiles(); + + // invoke the operation + string profileName = "profile1"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + NspProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileResource.cs new file mode 100644 index 000000000000..09e92838711d --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NspProfileResource.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_NspProfileResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspProfilesGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileGet.json + // this example is just showing the usage of "NspProfiles_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // invoke the operation + NspProfileResource result = await nspProfile.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NspProfilesDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfileDelete.json + // this example is just showing the usage of "NspProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // invoke the operation + await nspProfile.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_NspProfilesPut() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspProfilePut.json + // this example is just showing the usage of "NspProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NspProfileResource created on azure + // for more information of creating NspProfileResource, please refer to the document of NspProfileResource + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; + string networkSecurityPerimeterName = "nsp1"; + string profileName = "profile1"; + ResourceIdentifier nspProfileResourceId = NspProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + NspProfileResource nspProfile = client.GetNspProfileResource(nspProfileResourceId); + + // invoke the operation + NspProfileData data = new NspProfileData(default); + ArmOperation lro = await nspProfile.UpdateAsync(WaitUntil.Completed, data); + NspProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NspProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultCollection.cs new file mode 100644 index 000000000000..f84ac3ffc5bb --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultCollection.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_OperationStatusResultCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspOperationStatusGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspOperationStatusGet.json + // this example is just showing the usage of "NspOperationStatus_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this OperationStatusResultResource + OperationStatusResultCollection collection = subscriptionResource.GetOperationStatusResults(); + + // invoke the operation + AzureLocation location = new AzureLocation("location1"); + string operationId = "operationId1"; + OperationStatusResultResource result = await collection.GetAsync(location, operationId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationStatusResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_NspOperationStatusGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspOperationStatusGet.json + // this example is just showing the usage of "NspOperationStatus_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this OperationStatusResultResource + OperationStatusResultCollection collection = subscriptionResource.GetOperationStatusResults(); + + // invoke the operation + AzureLocation location = new AzureLocation("location1"); + string operationId = "operationId1"; + bool result = await collection.ExistsAsync(location, operationId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_NspOperationStatusGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspOperationStatusGet.json + // this example is just showing the usage of "NspOperationStatus_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this OperationStatusResultResource + OperationStatusResultCollection collection = subscriptionResource.GetOperationStatusResults(); + + // invoke the operation + AzureLocation location = new AzureLocation("location1"); + string operationId = "operationId1"; + NullableResponse response = await collection.GetIfExistsAsync(location, operationId); + OperationStatusResultResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationStatusResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultResource.cs new file mode 100644 index 000000000000..d001b0940eb8 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OperationStatusResultResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Network.Samples +{ + public partial class Sample_OperationStatusResultResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NspOperationStatusGet() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NspOperationStatusGet.json + // this example is just showing the usage of "NspOperationStatus_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OperationStatusResultResource created on azure + // for more information of creating OperationStatusResultResource, please refer to the document of OperationStatusResultResource + string subscriptionId = "subId"; + AzureLocation location = new AzureLocation("location1"); + string operationId = "operationId1"; + ResourceIdentifier operationStatusResultResourceId = OperationStatusResultResource.CreateResourceIdentifier(subscriptionId, location, operationId); + OperationStatusResultResource operationStatusResult = client.GetOperationStatusResultResource(operationStatusResultResourceId); + + // invoke the operation + OperationStatusResultResource result = await operationStatusResult.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationStatusResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 36d7cc8c9a3b..7c09006434f8 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,65 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkSecurityPerimeters_NetworkSecurityPerimetersList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/NetworkSecurityPerimeterListAll.json + // this example is just showing the usage of "NetworkSecurityPerimeters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterResource item in subscriptionResource.GetNetworkSecurityPerimetersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPerimeterAssociableResourceTypes_CheckDnsNameAvailability() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-07-01/examples/PerimeterAssociableResourcesList.json + // this example is just showing the usage of "PerimeterAssociableResourceTypes_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westus"); + await foreach (PerimeterAssociableResource item in subscriptionResource.GetPerimeterAssociableResourceTypesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetApplicationGateways_ListsAllApplicationGatewaysInASubscription() diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/ArmNetworkModelFactory.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/ArmNetworkModelFactory.cs index 191b27658c9d..9c0bd9f1940a 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/ArmNetworkModelFactory.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/ArmNetworkModelFactory.cs @@ -19,6 +19,339 @@ namespace Azure.ResourceManager.Network.Models /// Model factory for models. public static partial class ArmNetworkModelFactory { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the scope assignment resource. + /// perimeter guid of the network security perimeter. + /// A new instance for mocking. + public static NetworkSecurityPerimeterData NetworkSecurityPerimeterData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, NspProvisioningState? provisioningState = null, Guid? perimeterGuid = null) + { + tags ??= new Dictionary(); + + return new NetworkSecurityPerimeterData( + id, + name, + resourceType, + systemData, + tags, + location, + provisioningState, + perimeterGuid, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource ID. + /// Resource name. + /// Resource type. + /// Resource location. + /// Resource tags. + /// A new instance for mocking. + public static NetworkTrackedResourceData NetworkTrackedResourceData(ResourceIdentifier id = null, string name = null, ResourceType? resourceType = null, AzureLocation? location = null, IDictionary tags = null) + { + tags ??= new Dictionary(); + + return new NetworkTrackedResourceData( + id, + name, + resourceType, + location, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Network security perimeter identifier. + /// List of tags for Network Security Perimeter. + /// A new instance for mocking. + public static NetworkSecurityPerimeterPatch NetworkSecurityPerimeterPatch(string id = null, IDictionary tags = null) + { + tags ??= new Dictionary(); + + return new NetworkSecurityPerimeterPatch(id, tags, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Version number that increases with every update to access rules within the profile. + /// Version number that increases with every update to diagnostic settings within the profile. + /// A new instance for mocking. + public static NspProfileData NspProfileData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string accessRulesVersion = null, string diagnosticSettingsVersion = null) + { + tags ??= new Dictionary(); + + return new NspProfileData( + id, + name, + resourceType, + systemData, + tags, + location, + accessRulesVersion, + diagnosticSettingsVersion, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the scope assignment resource. + /// Direction that specifies whether the access rules is inbound/outbound. + /// Inbound address prefixes (IPv4/IPv6). + /// Outbound rules fully qualified domain name format. + /// List of subscription ids. + /// Rule specified by the perimeter id. + /// Outbound rules email address format. + /// Outbound rules phone number format. + /// Inbound rules service tag names. + /// A new instance for mocking. + public static NspAccessRuleData NspAccessRuleData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, NspProvisioningState? provisioningState = null, AccessRuleDirection? direction = null, IEnumerable addressPrefixes = null, IEnumerable fullyQualifiedDomainNames = null, IEnumerable subscriptions = null, IEnumerable networkSecurityPerimeters = null, IEnumerable emailAddresses = null, IEnumerable phoneNumbers = null, IEnumerable serviceTags = null) + { + tags ??= new Dictionary(); + addressPrefixes ??= new List(); + fullyQualifiedDomainNames ??= new List(); + subscriptions ??= new List(); + networkSecurityPerimeters ??= new List(); + emailAddresses ??= new List(); + phoneNumbers ??= new List(); + serviceTags ??= new List(); + + return new NspAccessRuleData( + id, + name, + resourceType, + systemData, + tags, + location, + provisioningState, + direction, + addressPrefixes?.ToList(), + fullyQualifiedDomainNames?.ToList(), + subscriptions?.ToList(), + networkSecurityPerimeters?.ToList(), + emailAddresses?.ToList(), + phoneNumbers?.ToList(), + serviceTags?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// NSP id in the ARM id format. + /// Resource guid of the NSP supplied. + /// Location of the NSP supplied. + /// A new instance for mocking. + public static PerimeterBasedAccessRule PerimeterBasedAccessRule(string id = null, Guid? perimeterGuid = null, AzureLocation? location = null) + { + return new PerimeterBasedAccessRule(id, perimeterGuid, location, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the resource association resource. + /// The PaaS resource to be associated. + /// Profile id to which the PaaS resource is associated. + /// Access mode on the association. + /// Specifies if there are provisioning issues. + /// A new instance for mocking. + public static NspAssociationData NspAssociationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, NspProvisioningState? provisioningState = null, ResourceIdentifier privateLinkResourceId = null, ResourceIdentifier profileId = null, AssociationAccessMode? accessMode = null, string hasProvisioningIssues = null) + { + tags ??= new Dictionary(); + + return new NspAssociationData( + id, + name, + resourceType, + systemData, + tags, + location, + provisioningState, + privateLinkResourceId != null ? ResourceManagerModelFactory.WritableSubResource(privateLinkResourceId) : null, + profileId != null ? ResourceManagerModelFactory.WritableSubResource(profileId) : null, + accessMode, + hasProvisioningIssues, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// A friendly name for the properties of perimeter associable resources. + /// Public DNS zone names of the resources. + /// A new instance for mocking. + public static PerimeterAssociableResource PerimeterAssociableResource(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string displayName = null, IEnumerable publicDnsZones = null) + { + tags ??= new Dictionary(); + publicDnsZones ??= new List(); + + return new PerimeterAssociableResource( + id, + name, + resourceType, + systemData, + tags, + location, + displayName, + publicDnsZones?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The provisioning state of the NSP Link resource. + /// Perimeter ARM Id for the remote NSP with which the link gets created in Auto-approval mode. It should be used when the NSP admin have Microsoft.Network/networkSecurityPerimeters/linkPerimeter/action permission on the remote NSP resource. + /// Remote NSP Guid with which the link gets created. + /// Remote NSP location with which the link gets created. + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// Remote Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. This property can only be updated in auto-approval mode. + /// Remote Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// A message passed to the owner of the remote NSP link resource with this connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. Restricted to 140 chars. + /// The NSP link state. + /// A unique read-only string that changes whenever the resource is updated. + /// A new instance for mocking. + public static NspLinkData NspLinkData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, NspLinkProvisioningState? provisioningState = null, string autoApprovedRemotePerimeterResourceId = null, Guid? remotePerimeterGuid = null, string remotePerimeterLocation = null, IEnumerable localInboundProfiles = null, IEnumerable localOutboundProfiles = null, IEnumerable remoteInboundProfiles = null, IEnumerable remoteOutboundProfiles = null, string description = null, NspLinkStatus? status = null, ETag? etag = null) + { + localInboundProfiles ??= new List(); + localOutboundProfiles ??= new List(); + remoteInboundProfiles ??= new List(); + remoteOutboundProfiles ??= new List(); + + return new NspLinkData( + id, + name, + resourceType, + systemData, + provisioningState, + autoApprovedRemotePerimeterResourceId, + remotePerimeterGuid, + remotePerimeterLocation, + localInboundProfiles?.ToList(), + localOutboundProfiles?.ToList(), + remoteInboundProfiles?.ToList(), + remoteOutboundProfiles?.ToList(), + description, + status, + etag, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The provisioning state of the NSP LinkReference resource. + /// Perimeter ARM Id for the remote NSP with which the link is created. + /// Remote NSP Guid with which the link is created. + /// Remote NSP location with which the link gets created. + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// Remote Inbound profile names to which Inbound is allowed. ['*'] value implies inbound is allowed to all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + /// Remote Outbound profile names from which Outbound is allowed. ['*'] value implies outbound is allowed from all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + /// A message sent by the remote NSP link admin for connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. + /// The NSP linkReference state. It cannot be changed if link is created in auto-approval mode. + /// A unique read-only string that changes whenever the resource is updated. + /// A new instance for mocking. + public static NspLinkReferenceData NspLinkReferenceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, NspLinkProvisioningState? provisioningState = null, string remotePerimeterResourceId = null, Guid? remotePerimeterGuid = null, string remotePerimeterLocation = null, IEnumerable localInboundProfiles = null, IEnumerable localOutboundProfiles = null, IEnumerable remoteInboundProfiles = null, IEnumerable remoteOutboundProfiles = null, string description = null, NspLinkStatus? status = null, ETag? etag = null) + { + localInboundProfiles ??= new List(); + localOutboundProfiles ??= new List(); + remoteInboundProfiles ??= new List(); + remoteOutboundProfiles ??= new List(); + + return new NspLinkReferenceData( + id, + name, + resourceType, + systemData, + provisioningState, + remotePerimeterResourceId, + remotePerimeterGuid, + remotePerimeterLocation, + localInboundProfiles?.ToList(), + localOutboundProfiles?.ToList(), + remoteInboundProfiles?.ToList(), + remoteOutboundProfiles?.ToList(), + description, + status, + etag, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Properties of the NSP logging configuration. + /// A unique read-only string that changes whenever the resource is updated. + /// A new instance for mocking. + public static NspLoggingConfigurationData NspLoggingConfigurationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, NspLoggingConfigurationProperties properties = null, ETag? etag = null) + { + return new NspLoggingConfigurationData( + id, + name, + resourceType, + systemData, + properties, + etag, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Fully qualified ID for the async operation. + /// Fully qualified ID of the resource against which the original async operation was started. + /// Name of the async operation. + /// Operation status. + /// Percent of the operation that is complete. + /// The start time of the operation. + /// The end time of the operation. + /// The operations list. + /// If present, details of the operation error. + /// A new instance for mocking. + public static OperationStatusResultData OperationStatusResultData(ResourceIdentifier id = null, ResourceIdentifier resourceId = null, string name = null, string status = null, float? percentComplete = null, DateTimeOffset? startOn = null, DateTimeOffset? endOn = null, IEnumerable operations = null, ResponseError error = null) + { + operations ??= new List(); + + return new OperationStatusResultData( + id, + resourceId, + name, + status, + percentComplete, + startOn, + endOn, + operations?.ToList(), + error, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// Resource ID. /// Resource name. @@ -700,26 +1033,6 @@ public static ApplicationSecurityGroupData ApplicationSecurityGroupData(Resource provisioningState); } - /// Initializes a new instance of . - /// Resource ID. - /// Resource name. - /// Resource type. - /// Resource location. - /// Resource tags. - /// A new instance for mocking. - public static NetworkTrackedResourceData NetworkTrackedResourceData(ResourceIdentifier id = null, string name = null, ResourceType? resourceType = null, AzureLocation? location = null, IDictionary tags = null) - { - tags ??= new Dictionary(); - - return new NetworkTrackedResourceData( - id, - name, - resourceType, - location, - tags, - serializedAdditionalRawData: null); - } - /// Initializes a new instance of . /// Resource ID. /// Resource name. diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkArmClient.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkArmClient.cs index 0b7c2de7ca6c..b86ebbab233d 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkArmClient.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkArmClient.cs @@ -34,6 +34,102 @@ private string GetApiVersionOrNull(ResourceType resourceType) 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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NetworkSecurityPerimeterResource GetNetworkSecurityPerimeterResource(ResourceIdentifier id) + { + NetworkSecurityPerimeterResource.ValidateResourceId(id); + return new NetworkSecurityPerimeterResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspProfileResource GetNspProfileResource(ResourceIdentifier id) + { + NspProfileResource.ValidateResourceId(id); + return new NspProfileResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspAccessRuleResource GetNspAccessRuleResource(ResourceIdentifier id) + { + NspAccessRuleResource.ValidateResourceId(id); + return new NspAccessRuleResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspAssociationResource GetNspAssociationResource(ResourceIdentifier id) + { + NspAssociationResource.ValidateResourceId(id); + return new NspAssociationResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspLinkResource GetNspLinkResource(ResourceIdentifier id) + { + NspLinkResource.ValidateResourceId(id); + return new NspLinkResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspLinkReferenceResource GetNspLinkReferenceResource(ResourceIdentifier id) + { + NspLinkReferenceResource.ValidateResourceId(id); + return new NspLinkReferenceResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NspLoggingConfigurationResource GetNspLoggingConfigurationResource(ResourceIdentifier id) + { + NspLoggingConfigurationResource.ValidateResourceId(id); + return new NspLoggingConfigurationResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual OperationStatusResultResource GetOperationStatusResultResource(ResourceIdentifier id) + { + OperationStatusResultResource.ValidateResourceId(id); + return new OperationStatusResultResource(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. diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkResourceGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkResourceGroupResource.cs index 07374533a9bc..5585226c70fc 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkResourceGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkResourceGroupResource.cs @@ -54,6 +54,75 @@ private string GetApiVersionOrNull(ResourceType resourceType) return apiVersion; } + /// Gets a collection of NetworkSecurityPerimeterResources in the ResourceGroupResource. + /// An object representing collection of NetworkSecurityPerimeterResources and their operations over a NetworkSecurityPerimeterResource. + public virtual NetworkSecurityPerimeterCollection GetNetworkSecurityPerimeters() + { + return GetCachedClient(client => new NetworkSecurityPerimeterCollection(client, Id)); + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNetworkSecurityPerimeterAsync(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + return await GetNetworkSecurityPerimeters().GetAsync(networkSecurityPerimeterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNetworkSecurityPerimeter(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + return GetNetworkSecurityPerimeters().Get(networkSecurityPerimeterName, cancellationToken); + } + /// Gets a collection of ApplicationGatewayResources in the ResourceGroupResource. /// An object representing collection of ApplicationGatewayResources and their operations over a ApplicationGatewayResource. public virtual ApplicationGatewayCollection GetApplicationGateways() diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkSubscriptionResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkSubscriptionResource.cs index 93e571a9400c..d2966a34cb53 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkSubscriptionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/MockableNetworkSubscriptionResource.cs @@ -18,6 +18,10 @@ namespace Azure.ResourceManager.Network.Mocking /// A class to add extension methods to SubscriptionResource. public partial class MockableNetworkSubscriptionResource : ArmResource { + private ClientDiagnostics _networkSecurityPerimeterClientDiagnostics; + private NetworkSecurityPerimetersRestOperations _networkSecurityPerimeterRestClient; + private ClientDiagnostics _perimeterAssociableResourceTypesClientDiagnostics; + private PerimeterAssociableResourceTypesRestOperations _perimeterAssociableResourceTypesRestClient; private ClientDiagnostics _applicationGatewayClientDiagnostics; private ApplicationGatewaysRestOperations _applicationGatewayRestClient; private ClientDiagnostics _applicationSecurityGroupClientDiagnostics; @@ -135,6 +139,10 @@ internal MockableNetworkSubscriptionResource(ArmClient client, ResourceIdentifie { } + private ClientDiagnostics NetworkSecurityPerimeterClientDiagnostics => _networkSecurityPerimeterClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Network", NetworkSecurityPerimeterResource.ResourceType.Namespace, Diagnostics); + private NetworkSecurityPerimetersRestOperations NetworkSecurityPerimeterRestClient => _networkSecurityPerimeterRestClient ??= new NetworkSecurityPerimetersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(NetworkSecurityPerimeterResource.ResourceType)); + private ClientDiagnostics PerimeterAssociableResourceTypesClientDiagnostics => _perimeterAssociableResourceTypesClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Network", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private PerimeterAssociableResourceTypesRestOperations PerimeterAssociableResourceTypesRestClient => _perimeterAssociableResourceTypesRestClient ??= new PerimeterAssociableResourceTypesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); private ClientDiagnostics ApplicationGatewayClientDiagnostics => _applicationGatewayClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Network", ApplicationGatewayResource.ResourceType.Namespace, Diagnostics); private ApplicationGatewaysRestOperations ApplicationGatewayRestClient => _applicationGatewayRestClient ??= new ApplicationGatewaysRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(ApplicationGatewayResource.ResourceType)); private ClientDiagnostics ApplicationSecurityGroupClientDiagnostics => _applicationSecurityGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Network", ApplicationSecurityGroupResource.ResourceType.Namespace, Diagnostics); @@ -246,6 +254,77 @@ private string GetApiVersionOrNull(ResourceType resourceType) return apiVersion; } + /// Gets a collection of OperationStatusResultResources in the SubscriptionResource. + /// An object representing collection of OperationStatusResultResources and their operations over a OperationStatusResultResource. + public virtual OperationStatusResultCollection GetOperationStatusResults() + { + return GetCachedClient(client => new OperationStatusResultCollection(client, Id)); + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetOperationStatusResultAsync(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + return await GetOperationStatusResults().GetAsync(location, operationId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetOperationStatusResult(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + return GetOperationStatusResults().Get(location, operationId, cancellationToken); + } + /// Gets a collection of ApplicationGatewayWafDynamicManifestResources in the SubscriptionResource. /// The region where the nrp are located at. /// An object representing collection of ApplicationGatewayWafDynamicManifestResources and their operations over a ApplicationGatewayWafDynamicManifestResource. @@ -659,6 +738,124 @@ public virtual Response GetNetworkVirtualApp return GetNetworkVirtualApplianceSkus().Get(skuName, cancellationToken); } + /// + /// List all network security perimeters in a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetNetworkSecurityPerimetersAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => NetworkSecurityPerimeterRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => NetworkSecurityPerimeterRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterResource(Client, NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(e)), NetworkSecurityPerimeterClientDiagnostics, Pipeline, "MockableNetworkSubscriptionResource.GetNetworkSecurityPerimeters", "value", "nextLink", cancellationToken); + } + + /// + /// List all network security perimeters in a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetNetworkSecurityPerimeters(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => NetworkSecurityPerimeterRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => NetworkSecurityPerimeterRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterResource(Client, NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(e)), NetworkSecurityPerimeterClientDiagnostics, Pipeline, "MockableNetworkSubscriptionResource.GetNetworkSecurityPerimeters", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/perimeterAssociableResourceTypes + /// + /// + /// Operation Id + /// PerimeterAssociableResourceTypes_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// The location of network security perimeter. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetPerimeterAssociableResourceTypesAsync(AzureLocation location, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => PerimeterAssociableResourceTypesRestClient.CreateListRequest(Id.SubscriptionId, location); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => PerimeterAssociableResourceTypesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => PerimeterAssociableResource.DeserializePerimeterAssociableResource(e), PerimeterAssociableResourceTypesClientDiagnostics, Pipeline, "MockableNetworkSubscriptionResource.GetPerimeterAssociableResourceTypes", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/perimeterAssociableResourceTypes + /// + /// + /// Operation Id + /// PerimeterAssociableResourceTypes_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// The location of network security perimeter. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetPerimeterAssociableResourceTypes(AzureLocation location, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => PerimeterAssociableResourceTypesRestClient.CreateListRequest(Id.SubscriptionId, location); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => PerimeterAssociableResourceTypesRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, location); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => PerimeterAssociableResource.DeserializePerimeterAssociableResource(e), PerimeterAssociableResourceTypesClientDiagnostics, Pipeline, "MockableNetworkSubscriptionResource.GetPerimeterAssociableResourceTypes", "value", "nextLink", cancellationToken); + } + /// /// Gets all the application gateways in a subscription. /// diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/NetworkExtensions.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/NetworkExtensions.cs index db16625c0cd2..a91c30783b87 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/NetworkExtensions.cs +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Extensions/NetworkExtensions.cs @@ -39,6 +39,158 @@ private static MockableNetworkSubscriptionResource GetMockableNetworkSubscriptio return resource.GetCachedClient(client => new MockableNetworkSubscriptionResource(client, resource.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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NetworkSecurityPerimeterResource GetNetworkSecurityPerimeterResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNetworkSecurityPerimeterResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspProfileResource GetNspProfileResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspProfileResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspAccessRuleResource GetNspAccessRuleResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspAccessRuleResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspAssociationResource GetNspAssociationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspAssociationResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspLinkResource GetNspLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspLinkResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspLinkReferenceResource GetNspLinkReferenceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspLinkReferenceResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NspLoggingConfigurationResource GetNspLoggingConfigurationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetNspLoggingConfigurationResource(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. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static OperationStatusResultResource GetOperationStatusResultResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNetworkArmClient(client).GetOperationStatusResultResource(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. @@ -2469,6 +2621,99 @@ public static Response GetManag return GetMockableNetworkManagementGroupResource(managementGroupResource).GetManagementGroupNetworkManagerConnection(networkManagerConnectionName, cancellationToken); } + /// + /// Gets a collection of NetworkSecurityPerimeterResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of NetworkSecurityPerimeterResources and their operations over a NetworkSecurityPerimeterResource. + public static NetworkSecurityPerimeterCollection GetNetworkSecurityPerimeters(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableNetworkResourceGroupResource(resourceGroupResource).GetNetworkSecurityPerimeters(); + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetNetworkSecurityPerimeterAsync(this ResourceGroupResource resourceGroupResource, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableNetworkResourceGroupResource(resourceGroupResource).GetNetworkSecurityPerimeterAsync(networkSecurityPerimeterName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetNetworkSecurityPerimeter(this ResourceGroupResource resourceGroupResource, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableNetworkResourceGroupResource(resourceGroupResource).GetNetworkSecurityPerimeter(networkSecurityPerimeterName, cancellationToken); + } + /// /// Gets a collection of ApplicationGatewayResources in the ResourceGroupResource. /// @@ -7026,6 +7271,101 @@ public static Pageable GetAutoApprovedPrivateLin return GetMockableNetworkResourceGroupResource(resourceGroupResource).GetAutoApprovedPrivateLinkServicesByResourceGroupPrivateLinkServices(location, cancellationToken); } + /// + /// Gets a collection of OperationStatusResultResources in the SubscriptionResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of OperationStatusResultResources and their operations over a OperationStatusResultResource. + public static OperationStatusResultCollection GetOperationStatusResults(this SubscriptionResource subscriptionResource) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetOperationStatusResults(); + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetOperationStatusResultAsync(this SubscriptionResource subscriptionResource, AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableNetworkSubscriptionResource(subscriptionResource).GetOperationStatusResultAsync(location, operationId, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetOperationStatusResult(this SubscriptionResource subscriptionResource, AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetOperationStatusResult(location, operationId, cancellationToken); + } + /// /// Gets a collection of ApplicationGatewayWafDynamicManifestResources in the SubscriptionResource. /// @@ -7585,6 +7925,148 @@ public static Response GetNetworkVirtualAppl return GetMockableNetworkSubscriptionResource(subscriptionResource).GetNetworkVirtualApplianceSku(skuName, cancellationToken); } + /// + /// List all network security perimeters in a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetNetworkSecurityPerimetersAsync(this SubscriptionResource subscriptionResource, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetNetworkSecurityPerimetersAsync(top, skipToken, cancellationToken); + } + + /// + /// List all network security perimeters in a subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetNetworkSecurityPerimeters(this SubscriptionResource subscriptionResource, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetNetworkSecurityPerimeters(top, skipToken, cancellationToken); + } + + /// + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/perimeterAssociableResourceTypes + /// + /// + /// Operation Id + /// PerimeterAssociableResourceTypes_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location of network security perimeter. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetPerimeterAssociableResourceTypesAsync(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetPerimeterAssociableResourceTypesAsync(location, cancellationToken); + } + + /// + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/perimeterAssociableResourceTypes + /// + /// + /// Operation Id + /// PerimeterAssociableResourceTypes_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location of network security perimeter. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetPerimeterAssociableResourceTypes(this SubscriptionResource subscriptionResource, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNetworkSubscriptionResource(subscriptionResource).GetPerimeterAssociableResourceTypes(location, cancellationToken); + } + /// /// Gets all the application gateways in a subscription. /// diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/LongRunningOperation/NspAssociationOperationSource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/LongRunningOperation/NspAssociationOperationSource.cs new file mode 100644 index 000000000000..991132957a0a --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/LongRunningOperation/NspAssociationOperationSource.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Network +{ + internal class NspAssociationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal NspAssociationOperationSource(ArmClient client) + { + _client = client; + } + + NspAssociationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = NspAssociationData.DeserializeNspAssociationData(document.RootElement); + return new NspAssociationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = NspAssociationData.DeserializeNspAssociationData(document.RootElement); + return new NspAssociationResource(_client, data); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/AccessRuleDirection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/AccessRuleDirection.cs new file mode 100644 index 000000000000..7c96b19c686c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/AccessRuleDirection.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + /// Direction that specifies whether the access rules is inbound/outbound. + public readonly partial struct AccessRuleDirection : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AccessRuleDirection(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InboundValue = "Inbound"; + private const string OutboundValue = "Outbound"; + + /// Inbound. + public static AccessRuleDirection Inbound { get; } = new AccessRuleDirection(InboundValue); + /// Outbound. + public static AccessRuleDirection Outbound { get; } = new AccessRuleDirection(OutboundValue); + /// Determines if two values are the same. + public static bool operator ==(AccessRuleDirection left, AccessRuleDirection right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AccessRuleDirection left, AccessRuleDirection right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AccessRuleDirection(string value) => new AccessRuleDirection(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AccessRuleDirection other && Equals(other); + /// + public bool Equals(AccessRuleDirection 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/network/Azure.ResourceManager.Network/src/Generated/Models/AssociationAccessMode.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/AssociationAccessMode.cs new file mode 100644 index 000000000000..3b277e86b899 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/AssociationAccessMode.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + /// Access mode on the association. + public readonly partial struct AssociationAccessMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssociationAccessMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LearningValue = "Learning"; + private const string EnforcedValue = "Enforced"; + private const string AuditValue = "Audit"; + + /// Learning. + public static AssociationAccessMode Learning { get; } = new AssociationAccessMode(LearningValue); + /// Enforced. + public static AssociationAccessMode Enforced { get; } = new AssociationAccessMode(EnforcedValue); + /// Audit. + public static AssociationAccessMode Audit { get; } = new AssociationAccessMode(AuditValue); + /// Determines if two values are the same. + public static bool operator ==(AssociationAccessMode left, AssociationAccessMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssociationAccessMode left, AssociationAccessMode right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssociationAccessMode(string value) => new AssociationAccessMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssociationAccessMode other && Equals(other); + /// + public bool Equals(AssociationAccessMode 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/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.Serialization.cs new file mode 100644 index 000000000000..446a93b4ec61 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NetworkSecurityPerimeterListResult : 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(NetworkSecurityPerimeterListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NetworkSecurityPerimeterListResult 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(NetworkSecurityPerimeterListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterListResult(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterListResult DeserializeNetworkSecurityPerimeterListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterListResult)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterListResult 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); + return DeserializeNetworkSecurityPerimeterListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.cs new file mode 100644 index 000000000000..264e4f11fb1e --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NetworkSecurityPerimeter. It contains a list of network security perimeters and a URL link to get the next set of results. + internal partial class NetworkSecurityPerimeterListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NetworkSecurityPerimeterListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NetworkSecurityPerimeter. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NetworkSecurityPerimeter. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.Serialization.cs new file mode 100644 index 000000000000..55d85606a6ac --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.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.Core; + +namespace Azure.ResourceManager.Network.Models +{ + public partial class NetworkSecurityPerimeterPatch : 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(NetworkSecurityPerimeterPatch)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NetworkSecurityPerimeterPatch 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(NetworkSecurityPerimeterPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterPatch(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterPatch DeserializeNetworkSecurityPerimeterPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterPatch(id, tags ?? new ChangeTrackingDictionary(), 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); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterPatch)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterPatch 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); + return DeserializeNetworkSecurityPerimeterPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.cs new file mode 100644 index 000000000000..9ef504338c4e --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NetworkSecurityPerimeterPatch.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Update tags request. + public partial class NetworkSecurityPerimeterPatch + { + /// + /// 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 NetworkSecurityPerimeterPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Network security perimeter identifier. + /// List of tags for Network Security Perimeter. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterPatch(string id, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Id = id; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Network security perimeter identifier. + public string Id { get; } + /// List of tags for Network Security Perimeter. + public IDictionary Tags { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.Serialization.cs new file mode 100644 index 000000000000..1277e688c872 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspAccessRuleListResult : 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(NspAccessRuleListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspAccessRuleListResult 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(NspAccessRuleListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspAccessRuleListResult(document.RootElement, options); + } + + internal static NspAccessRuleListResult DeserializeNspAccessRuleListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspAccessRuleData.DeserializeNspAccessRuleData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspAccessRuleListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspAccessRuleListResult)} does not support writing '{options.Format}' format."); + } + } + + NspAccessRuleListResult 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); + return DeserializeNspAccessRuleListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspAccessRuleListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.cs new file mode 100644 index 000000000000..c6bc6fb796f4 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAccessRuleListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP access rules. Contains a list of NSP access rules and a URL link to get the next set of results. + internal partial class NspAccessRuleListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspAccessRuleListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP access rule. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspAccessRuleListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP access rule. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.Serialization.cs new file mode 100644 index 000000000000..0a769603e42c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspAssociationsListResult : 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(NspAssociationsListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspAssociationsListResult 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(NspAssociationsListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspAssociationsListResult(document.RootElement, options); + } + + internal static NspAssociationsListResult DeserializeNspAssociationsListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspAssociationData.DeserializeNspAssociationData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspAssociationsListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspAssociationsListResult)} does not support writing '{options.Format}' format."); + } + } + + NspAssociationsListResult 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); + return DeserializeNspAssociationsListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspAssociationsListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.cs new file mode 100644 index 000000000000..e1d86f9412cf --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspAssociationsListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP resource associations. Contains a list of NSP resource associations and a URL link to get the next set of results. + internal partial class NspAssociationsListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspAssociationsListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP resource associations. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspAssociationsListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP resource associations. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.Serialization.cs new file mode 100644 index 000000000000..fa03d94e78a8 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspLinkListResult : 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(NspLinkListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspLinkListResult 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(NspLinkListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLinkListResult(document.RootElement, options); + } + + internal static NspLinkListResult DeserializeNspLinkListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspLinkData.DeserializeNspLinkData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLinkListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspLinkListResult)} does not support writing '{options.Format}' format."); + } + } + + NspLinkListResult 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); + return DeserializeNspLinkListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLinkListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.cs new file mode 100644 index 000000000000..24ec1f42ee2b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP link resources. Contains a list of NSP link resources and a URL link to get the next set of results. + internal partial class NspLinkListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspLinkListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP Link resources. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspLinkListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP Link resources. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkProvisioningState.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkProvisioningState.cs new file mode 100644 index 000000000000..0fd355ea2244 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkProvisioningState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + /// The current provisioning state of NSP Link/LinkReference. + public readonly partial struct NspLinkProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NspLinkProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string CreatingValue = "Creating"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + private const string FailedValue = "Failed"; + private const string WaitForRemoteCompletionValue = "WaitForRemoteCompletion"; + + /// Succeeded. + public static NspLinkProvisioningState Succeeded { get; } = new NspLinkProvisioningState(SucceededValue); + /// Creating. + public static NspLinkProvisioningState Creating { get; } = new NspLinkProvisioningState(CreatingValue); + /// Updating. + public static NspLinkProvisioningState Updating { get; } = new NspLinkProvisioningState(UpdatingValue); + /// Deleting. + public static NspLinkProvisioningState Deleting { get; } = new NspLinkProvisioningState(DeletingValue); + /// Accepted. + public static NspLinkProvisioningState Accepted { get; } = new NspLinkProvisioningState(AcceptedValue); + /// Failed. + public static NspLinkProvisioningState Failed { get; } = new NspLinkProvisioningState(FailedValue); + /// WaitForRemoteCompletion. + public static NspLinkProvisioningState WaitForRemoteCompletion { get; } = new NspLinkProvisioningState(WaitForRemoteCompletionValue); + /// Determines if two values are the same. + public static bool operator ==(NspLinkProvisioningState left, NspLinkProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NspLinkProvisioningState left, NspLinkProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NspLinkProvisioningState(string value) => new NspLinkProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NspLinkProvisioningState other && Equals(other); + /// + public bool Equals(NspLinkProvisioningState 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/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.Serialization.cs new file mode 100644 index 000000000000..48036d15375d --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspLinkReferenceListResult : 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(NspLinkReferenceListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspLinkReferenceListResult 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(NspLinkReferenceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLinkReferenceListResult(document.RootElement, options); + } + + internal static NspLinkReferenceListResult DeserializeNspLinkReferenceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspLinkReferenceData.DeserializeNspLinkReferenceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLinkReferenceListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspLinkReferenceListResult)} does not support writing '{options.Format}' format."); + } + } + + NspLinkReferenceListResult 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); + return DeserializeNspLinkReferenceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLinkReferenceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.cs new file mode 100644 index 000000000000..0755a5a474f9 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkReferenceListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP linkReference resources. Contains a list of NSP linkReference resources and a URL link to get the next set of results. + internal partial class NspLinkReferenceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspLinkReferenceListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP LinkReference resources. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspLinkReferenceListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP LinkReference resources. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkStatus.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkStatus.cs new file mode 100644 index 000000000000..a618360042fb --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLinkStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + /// The NSP link state. + public readonly partial struct NspLinkStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NspLinkStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string PendingValue = "Pending"; + private const string RejectedValue = "Rejected"; + private const string DisconnectedValue = "Disconnected"; + + /// Approved. + public static NspLinkStatus Approved { get; } = new NspLinkStatus(ApprovedValue); + /// Pending. + public static NspLinkStatus Pending { get; } = new NspLinkStatus(PendingValue); + /// Rejected. + public static NspLinkStatus Rejected { get; } = new NspLinkStatus(RejectedValue); + /// Disconnected. + public static NspLinkStatus Disconnected { get; } = new NspLinkStatus(DisconnectedValue); + /// Determines if two values are the same. + public static bool operator ==(NspLinkStatus left, NspLinkStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NspLinkStatus left, NspLinkStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NspLinkStatus(string value) => new NspLinkStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NspLinkStatus other && Equals(other); + /// + public bool Equals(NspLinkStatus 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/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.Serialization.cs new file mode 100644 index 000000000000..13f5f37a2f72 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspLoggingConfigurationListResult : 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(NspLoggingConfigurationListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspLoggingConfigurationListResult 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(NspLoggingConfigurationListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLoggingConfigurationListResult(document.RootElement, options); + } + + internal static NspLoggingConfigurationListResult DeserializeNspLoggingConfigurationListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLoggingConfigurationListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationListResult)} does not support writing '{options.Format}' format."); + } + } + + NspLoggingConfigurationListResult 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); + return DeserializeNspLoggingConfigurationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.cs new file mode 100644 index 000000000000..65ab8525ad4d --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP logging configuration. Contains a list of NSP logging configurations and a URL link to get the next set of results. + internal partial class NspLoggingConfigurationListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspLoggingConfigurationListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP logging configuration. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspLoggingConfigurationListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP logging configuration. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.Serialization.cs new file mode 100644 index 000000000000..0f9ff021be34 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + public partial class NspLoggingConfigurationProperties : 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(NspLoggingConfigurationProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(EnabledLogCategories)) + { + writer.WritePropertyName("enabledLogCategories"u8); + writer.WriteStartArray(); + foreach (var item in EnabledLogCategories) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspLoggingConfigurationProperties 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(NspLoggingConfigurationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLoggingConfigurationProperties(document.RootElement, options); + } + + internal static NspLoggingConfigurationProperties DeserializeNspLoggingConfigurationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList enabledLogCategories = default; + string version = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabledLogCategories"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + enabledLogCategories = array; + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLoggingConfigurationProperties(enabledLogCategories ?? new ChangeTrackingList(), version, 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); + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationProperties)} does not support writing '{options.Format}' format."); + } + } + + NspLoggingConfigurationProperties 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); + return DeserializeNspLoggingConfigurationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.cs new file mode 100644 index 000000000000..634066676e0b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspLoggingConfigurationProperties.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// The NSP logging configuration properties. + public partial class NspLoggingConfigurationProperties + { + /// + /// 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 NspLoggingConfigurationProperties() + { + EnabledLogCategories = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The log categories to enable in the NSP logging configuration. + /// The version of the NSP logging configuration. + /// Keeps track of any properties unknown to the library. + internal NspLoggingConfigurationProperties(IList enabledLogCategories, string version, IDictionary serializedAdditionalRawData) + { + EnabledLogCategories = enabledLogCategories; + Version = version; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The log categories to enable in the NSP logging configuration. + public IList EnabledLogCategories { get; } + /// The version of the NSP logging configuration. + public string Version { get; set; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.Serialization.cs new file mode 100644 index 000000000000..3e913f63781b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class NspProfileListResult : 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(NspProfileListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NspProfileListResult 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(NspProfileListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspProfileListResult(document.RootElement, options); + } + + internal static NspProfileListResult DeserializeNspProfileListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NspProfileData.DeserializeNspProfileData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspProfileListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(NspProfileListResult)} does not support writing '{options.Format}' format."); + } + } + + NspProfileListResult 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); + return DeserializeNspProfileListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspProfileListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.cs new file mode 100644 index 000000000000..3ccdb48db27b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProfileListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Result of the request to list NSP profiles. Contains a list of NSP profiles and a URL link to get the next set of results. + internal partial class NspProfileListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NspProfileListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets a page of NSP profile. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal NspProfileListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets a page of NSP profile. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProvisioningState.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProvisioningState.cs new file mode 100644 index 000000000000..d2469a977bb7 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/NspProvisioningState.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Network.Models +{ + /// The current provisioning state. + public readonly partial struct NspProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NspProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string CreatingValue = "Creating"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + private const string FailedValue = "Failed"; + + /// Succeeded. + public static NspProvisioningState Succeeded { get; } = new NspProvisioningState(SucceededValue); + /// Creating. + public static NspProvisioningState Creating { get; } = new NspProvisioningState(CreatingValue); + /// Updating. + public static NspProvisioningState Updating { get; } = new NspProvisioningState(UpdatingValue); + /// Deleting. + public static NspProvisioningState Deleting { get; } = new NspProvisioningState(DeletingValue); + /// Accepted. + public static NspProvisioningState Accepted { get; } = new NspProvisioningState(AcceptedValue); + /// Failed. + public static NspProvisioningState Failed { get; } = new NspProvisioningState(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(NspProvisioningState left, NspProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NspProvisioningState left, NspProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NspProvisioningState(string value) => new NspProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NspProvisioningState other && Equals(other); + /// + public bool Equals(NspProvisioningState 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/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.Serialization.cs new file mode 100644 index 000000000000..b2dad3e36417 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.Serialization.cs @@ -0,0 +1,214 @@ +// 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.Models; + +namespace Azure.ResourceManager.Network.Models +{ + public partial class PerimeterAssociableResource : 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 override 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(PerimeterAssociableResource)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PublicDnsZones)) + { + writer.WritePropertyName("publicDnsZones"u8); + writer.WriteStartArray(); + foreach (var item in PublicDnsZones) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + PerimeterAssociableResource 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(PerimeterAssociableResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePerimeterAssociableResource(document.RootElement, options); + } + + internal static PerimeterAssociableResource DeserializePerimeterAssociableResource(JsonElement element, ModelReaderWriterOptions options = null) + { + 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; + SystemData systemData = default; + string displayName = default; + IReadOnlyList publicDnsZones = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("displayName"u8)) + { + displayName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("publicDnsZones"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + publicDnsZones = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PerimeterAssociableResource( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + displayName, + publicDnsZones ?? 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); + default: + throw new FormatException($"The model {nameof(PerimeterAssociableResource)} does not support writing '{options.Format}' format."); + } + } + + PerimeterAssociableResource 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); + return DeserializePerimeterAssociableResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PerimeterAssociableResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.cs new file mode 100644 index 000000000000..a0c72c4d4a9e --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResource.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 Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Network.Models +{ + /// Resource that is onboarded to use network security perimeter. Also referred as perimeter associable resource. + public partial class PerimeterAssociableResource : 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; + + /// Initializes a new instance of . + /// The location. + public PerimeterAssociableResource(AzureLocation location) : base(location) + { + PublicDnsZones = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// A friendly name for the properties of perimeter associable resources. + /// Public DNS zone names of the resources. + /// Keeps track of any properties unknown to the library. + internal PerimeterAssociableResource(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string displayName, IReadOnlyList publicDnsZones, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + DisplayName = displayName; + PublicDnsZones = publicDnsZones; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PerimeterAssociableResource() + { + } + + /// A friendly name for the properties of perimeter associable resources. + public string DisplayName { get; } + /// Public DNS zone names of the resources. + public IReadOnlyList PublicDnsZones { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.Serialization.cs new file mode 100644 index 000000000000..972633808e24 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.Serialization.cs @@ -0,0 +1,154 @@ +// 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.Network.Models +{ + internal partial class PerimeterAssociableResourcesListResult : 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(PerimeterAssociableResourcesListResult)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PerimeterAssociableResourcesListResult 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(PerimeterAssociableResourcesListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePerimeterAssociableResourcesListResult(document.RootElement, options); + } + + internal static PerimeterAssociableResourcesListResult DeserializePerimeterAssociableResourcesListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PerimeterAssociableResource.DeserializePerimeterAssociableResource(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PerimeterAssociableResourcesListResult(value ?? new ChangeTrackingList(), nextLink, 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); + default: + throw new FormatException($"The model {nameof(PerimeterAssociableResourcesListResult)} does not support writing '{options.Format}' format."); + } + } + + PerimeterAssociableResourcesListResult 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); + return DeserializePerimeterAssociableResourcesListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PerimeterAssociableResourcesListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.cs new file mode 100644 index 000000000000..b132b03dd33b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterAssociableResourcesListResult.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Network.Models +{ + /// Paged list of perimeter associable resources. + internal partial class PerimeterAssociableResourcesListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal PerimeterAssociableResourcesListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets paged list of perimeter associable resources. + /// Gets the URL to get the next page of results. + /// Keeps track of any properties unknown to the library. + internal PerimeterAssociableResourcesListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets paged list of perimeter associable resources. + public IReadOnlyList Value { get; } + /// Gets the URL to get the next page of results. + public string NextLink { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.Serialization.cs new file mode 100644 index 000000000000..a6741f3c4891 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.Serialization.cs @@ -0,0 +1,159 @@ +// 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.Network.Models +{ + public partial class PerimeterBasedAccessRule : 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(PerimeterBasedAccessRule)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(PerimeterGuid)) + { + writer.WritePropertyName("perimeterGuid"u8); + writer.WriteStringValue(PerimeterGuid.Value); + } + if (options.Format != "W" && Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location.Value); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PerimeterBasedAccessRule 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(PerimeterBasedAccessRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePerimeterBasedAccessRule(document.RootElement, options); + } + + internal static PerimeterBasedAccessRule DeserializePerimeterBasedAccessRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + Guid? perimeterGuid = default; + AzureLocation? location = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("perimeterGuid"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + perimeterGuid = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PerimeterBasedAccessRule(id, perimeterGuid, location, 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); + default: + throw new FormatException($"The model {nameof(PerimeterBasedAccessRule)} does not support writing '{options.Format}' format."); + } + } + + PerimeterBasedAccessRule 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); + return DeserializePerimeterBasedAccessRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PerimeterBasedAccessRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.cs new file mode 100644 index 000000000000..eca7247ce0ed --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/Models/PerimeterBasedAccessRule.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Network.Models +{ + /// The PerimeterBasedAccessRule. + public partial class PerimeterBasedAccessRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal PerimeterBasedAccessRule() + { + } + + /// Initializes a new instance of . + /// NSP id in the ARM id format. + /// Resource guid of the NSP supplied. + /// Location of the NSP supplied. + /// Keeps track of any properties unknown to the library. + internal PerimeterBasedAccessRule(string id, Guid? perimeterGuid, AzureLocation? location, IDictionary serializedAdditionalRawData) + { + Id = id; + PerimeterGuid = perimeterGuid; + Location = location; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// NSP id in the ARM id format. + public string Id { get; } + /// Resource guid of the NSP supplied. + public Guid? PerimeterGuid { get; } + /// Location of the NSP supplied. + public AzureLocation? Location { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterCollection.cs new file mode 100644 index 000000000000..48cb45198f3c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterCollection.cs @@ -0,0 +1,502 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNetworkSecurityPerimeters method from an instance of . + /// + public partial class NetworkSecurityPerimeterCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _networkSecurityPerimeterClientDiagnostics; + private readonly NetworkSecurityPerimetersRestOperations _networkSecurityPerimeterRestClient; + + /// Initializes a new instance of the class for mocking. + protected NetworkSecurityPerimeterCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NetworkSecurityPerimeterCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _networkSecurityPerimeterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NetworkSecurityPerimeterResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NetworkSecurityPerimeterResource.ResourceType, out string networkSecurityPerimeterApiVersion); + _networkSecurityPerimeterRestClient = new NetworkSecurityPerimetersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, networkSecurityPerimeterApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + 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)); + } + + /// + /// Creates or updates a Network Security Perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the network security perimeter. + /// Parameter supplied to create or update the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string networkSecurityPerimeterName, NetworkSecurityPerimeterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, data, cancellationToken).ConfigureAwait(false); + var uri = _networkSecurityPerimeterRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NetworkSecurityPerimeterResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a Network Security Perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the network security perimeter. + /// Parameter supplied to create or update the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string networkSecurityPerimeterName, NetworkSecurityPerimeterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, data, cancellationToken); + var uri = _networkSecurityPerimeterRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NetworkSecurityPerimeterResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.Get"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.Get"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List network security perimeters in a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _networkSecurityPerimeterRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _networkSecurityPerimeterRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterResource(Client, NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(e)), _networkSecurityPerimeterClientDiagnostics, Pipeline, "NetworkSecurityPerimeterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List network security perimeters in a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _networkSecurityPerimeterRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _networkSecurityPerimeterRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NetworkSecurityPerimeterResource(Client, NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(e)), _networkSecurityPerimeterClientDiagnostics, Pipeline, "NetworkSecurityPerimeterCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.Exists"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.Exists"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the network security perimeter. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterCollection.GetIfExists"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, networkSecurityPerimeterName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.Serialization.cs new file mode 100644 index 000000000000..4cc97e9b7fc6 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.Serialization.cs @@ -0,0 +1,209 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NetworkSecurityPerimeterData : 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 override 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(NetworkSecurityPerimeterData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(PerimeterGuid)) + { + writer.WritePropertyName("perimeterGuid"u8); + writer.WriteStringValue(PerimeterGuid.Value); + } + writer.WriteEndObject(); + } + + NetworkSecurityPerimeterData 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(NetworkSecurityPerimeterData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkSecurityPerimeterData(document.RootElement, options); + } + + internal static NetworkSecurityPerimeterData DeserializeNetworkSecurityPerimeterData(JsonElement element, ModelReaderWriterOptions options = null) + { + 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; + SystemData systemData = default; + NspProvisioningState? provisioningState = default; + Guid? perimeterGuid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NspProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("perimeterGuid"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + perimeterGuid = property0.Value.GetGuid(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkSecurityPerimeterData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + provisioningState, + perimeterGuid, + 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); + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterData)} does not support writing '{options.Format}' format."); + } + } + + NetworkSecurityPerimeterData 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); + return DeserializeNetworkSecurityPerimeterData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkSecurityPerimeterData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.cs new file mode 100644 index 000000000000..21ed3d3f908b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterData.cs @@ -0,0 +1,87 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NetworkSecurityPerimeter data model. + /// The Network Security Perimeter resource + /// + public partial class NetworkSecurityPerimeterData : 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; + + /// Initializes a new instance of . + /// The location. + public NetworkSecurityPerimeterData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the scope assignment resource. + /// perimeter guid of the network security perimeter. + /// Keeps track of any properties unknown to the library. + internal NetworkSecurityPerimeterData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, NspProvisioningState? provisioningState, Guid? perimeterGuid, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + PerimeterGuid = perimeterGuid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NetworkSecurityPerimeterData() + { + } + + /// The provisioning state of the scope assignment resource. + public NspProvisioningState? ProvisioningState { get; } + /// perimeter guid of the network security perimeter. + public Guid? PerimeterGuid { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.Serialization.cs new file mode 100644 index 000000000000..850ca72093f5 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NetworkSecurityPerimeterResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NetworkSecurityPerimeterData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NetworkSecurityPerimeterData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.cs new file mode 100644 index 000000000000..edb2399925cb --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NetworkSecurityPerimeterResource.cs @@ -0,0 +1,1044 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NetworkSecurityPerimeter 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 GetNetworkSecurityPerimeterResource method. + /// Otherwise you can get one from its parent resource using the GetNetworkSecurityPerimeter method. + /// + public partial class NetworkSecurityPerimeterResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _networkSecurityPerimeterClientDiagnostics; + private readonly NetworkSecurityPerimetersRestOperations _networkSecurityPerimeterRestClient; + private readonly NetworkSecurityPerimeterData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters"; + + /// Initializes a new instance of the class for mocking. + protected NetworkSecurityPerimeterResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NetworkSecurityPerimeterResource(ArmClient client, NetworkSecurityPerimeterData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NetworkSecurityPerimeterResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _networkSecurityPerimeterClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string networkSecurityPerimeterApiVersion); + _networkSecurityPerimeterRestClient = new NetworkSecurityPerimetersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, networkSecurityPerimeterApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NetworkSecurityPerimeterData 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 NspProfileResources in the NetworkSecurityPerimeter. + /// An object representing collection of NspProfileResources and their operations over a NspProfileResource. + public virtual NspProfileCollection GetNspProfiles() + { + return GetCachedClient(client => new NspProfileCollection(client, Id)); + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspProfileAsync(string profileName, CancellationToken cancellationToken = default) + { + return await GetNspProfiles().GetAsync(profileName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspProfile(string profileName, CancellationToken cancellationToken = default) + { + return GetNspProfiles().Get(profileName, cancellationToken); + } + + /// Gets a collection of NspAssociationResources in the NetworkSecurityPerimeter. + /// An object representing collection of NspAssociationResources and their operations over a NspAssociationResource. + public virtual NspAssociationCollection GetNspAssociations() + { + return GetCachedClient(client => new NspAssociationCollection(client, Id)); + } + + /// + /// Gets the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspAssociationAsync(string associationName, CancellationToken cancellationToken = default) + { + return await GetNspAssociations().GetAsync(associationName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspAssociation(string associationName, CancellationToken cancellationToken = default) + { + return GetNspAssociations().Get(associationName, cancellationToken); + } + + /// Gets a collection of NspLinkResources in the NetworkSecurityPerimeter. + /// An object representing collection of NspLinkResources and their operations over a NspLinkResource. + public virtual NspLinkCollection GetNspLinks() + { + return GetCachedClient(client => new NspLinkCollection(client, Id)); + } + + /// + /// Gets the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspLinkAsync(string linkName, CancellationToken cancellationToken = default) + { + return await GetNspLinks().GetAsync(linkName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspLink(string linkName, CancellationToken cancellationToken = default) + { + return GetNspLinks().Get(linkName, cancellationToken); + } + + /// Gets a collection of NspLinkReferenceResources in the NetworkSecurityPerimeter. + /// An object representing collection of NspLinkReferenceResources and their operations over a NspLinkReferenceResource. + public virtual NspLinkReferenceCollection GetNspLinkReferences() + { + return GetCachedClient(client => new NspLinkReferenceCollection(client, Id)); + } + + /// + /// Gets the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspLinkReferenceAsync(string linkReferenceName, CancellationToken cancellationToken = default) + { + return await GetNspLinkReferences().GetAsync(linkReferenceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspLinkReference(string linkReferenceName, CancellationToken cancellationToken = default) + { + return GetNspLinkReferences().Get(linkReferenceName, cancellationToken); + } + + /// Gets a collection of NspLoggingConfigurationResources in the NetworkSecurityPerimeter. + /// An object representing collection of NspLoggingConfigurationResources and their operations over a NspLoggingConfigurationResource. + public virtual NspLoggingConfigurationCollection GetNspLoggingConfigurations() + { + return GetCachedClient(client => new NspLoggingConfigurationCollection(client, Id)); + } + + /// + /// Gets the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspLoggingConfigurationAsync(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + return await GetNspLoggingConfigurations().GetAsync(loggingConfigurationName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspLoggingConfiguration(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + return GetNspLoggingConfigurations().Get(loggingConfigurationName, cancellationToken); + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Get"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified network security perimeter by the name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Get"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Delete"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(_networkSecurityPerimeterClientDiagnostics, Pipeline, _networkSecurityPerimeterRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Delete"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new NetworkArmOperation(_networkSecurityPerimeterClientDiagnostics, Pipeline, _networkSecurityPerimeterRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch Tags for a Network Security Perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Patch + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameter supplied to the network security perimeter. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(NetworkSecurityPerimeterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Update"); + scope.Start(); + try + { + var response = await _networkSecurityPerimeterRestClient.PatchAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch Tags for a Network Security Perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Patch + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// Parameter supplied to the network security perimeter. + /// The cancellation token to use. + /// is null. + public virtual Response Update(NetworkSecurityPerimeterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.Update"); + scope.Start(); + try + { + var response = _networkSecurityPerimeterRestClient.Patch(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// 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 = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _networkSecurityPerimeterRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName} + /// + /// + /// Operation Id + /// NetworkSecurityPerimeters_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _networkSecurityPerimeterClientDiagnostics.CreateScope("NetworkSecurityPerimeterResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _networkSecurityPerimeterRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NetworkSecurityPerimeterResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NetworkSecurityPerimeterPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleCollection.cs new file mode 100644 index 000000000000..ee0564af47a9 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleCollection.cs @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspAccessRules method from an instance of . + /// + public partial class NspAccessRuleCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspAccessRuleClientDiagnostics; + private readonly NspAccessRulesRestOperations _nspAccessRuleRestClient; + + /// Initializes a new instance of the class for mocking. + protected NspAccessRuleCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspAccessRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspAccessRuleClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspAccessRuleResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspAccessRuleResource.ResourceType, out string nspAccessRuleApiVersion); + _nspAccessRuleRestClient = new NspAccessRulesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspAccessRuleApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NspProfileResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NspProfileResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates a network access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP access rule. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string accessRuleName, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, data, cancellationToken).ConfigureAwait(false); + var uri = _nspAccessRuleRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspAccessRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP access rule. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string accessRuleName, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, data, cancellationToken); + var uri = _nspAccessRuleRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspAccessRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.Get"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.Get"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP access rules in the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules + /// + /// + /// Operation Id + /// NspAccessRules_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspAccessRuleRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspAccessRuleRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspAccessRuleResource(Client, NspAccessRuleData.DeserializeNspAccessRuleData(e)), _nspAccessRuleClientDiagnostics, Pipeline, "NspAccessRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP access rules in the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules + /// + /// + /// Operation Id + /// NspAccessRules_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspAccessRuleRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspAccessRuleRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspAccessRuleResource(Client, NspAccessRuleData.DeserializeNspAccessRuleData(e)), _nspAccessRuleClientDiagnostics, Pipeline, "NspAccessRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.Exists"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.Exists"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, accessRuleName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.Serialization.cs new file mode 100644 index 000000000000..591ba3775437 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.Serialization.cs @@ -0,0 +1,392 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspAccessRuleData : 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 override 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(NspAccessRuleData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Direction)) + { + writer.WritePropertyName("direction"u8); + writer.WriteStringValue(Direction.Value.ToString()); + } + if (Optional.IsCollectionDefined(AddressPrefixes)) + { + writer.WritePropertyName("addressPrefixes"u8); + writer.WriteStartArray(); + foreach (var item in AddressPrefixes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FullyQualifiedDomainNames)) + { + writer.WritePropertyName("fullyQualifiedDomainNames"u8); + writer.WriteStartArray(); + foreach (var item in FullyQualifiedDomainNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Subscriptions)) + { + writer.WritePropertyName("subscriptions"u8); + writer.WriteStartArray(); + foreach (var item in Subscriptions) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(NetworkSecurityPerimeters)) + { + writer.WritePropertyName("networkSecurityPerimeters"u8); + writer.WriteStartArray(); + foreach (var item in NetworkSecurityPerimeters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(EmailAddresses)) + { + writer.WritePropertyName("emailAddresses"u8); + writer.WriteStartArray(); + foreach (var item in EmailAddresses) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(PhoneNumbers)) + { + writer.WritePropertyName("phoneNumbers"u8); + writer.WriteStartArray(); + foreach (var item in PhoneNumbers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ServiceTags)) + { + writer.WritePropertyName("serviceTags"u8); + writer.WriteStartArray(); + foreach (var item in ServiceTags) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + NspAccessRuleData 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(NspAccessRuleData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspAccessRuleData(document.RootElement, options); + } + + internal static NspAccessRuleData DeserializeNspAccessRuleData(JsonElement element, ModelReaderWriterOptions options = null) + { + 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; + SystemData systemData = default; + NspProvisioningState? provisioningState = default; + AccessRuleDirection? direction = default; + IList addressPrefixes = default; + IList fullyQualifiedDomainNames = default; + IList subscriptions = default; + IReadOnlyList networkSecurityPerimeters = default; + IList emailAddresses = default; + IList phoneNumbers = default; + IList serviceTags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NspProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("direction"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + direction = new AccessRuleDirection(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("addressPrefixes"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + addressPrefixes = array; + continue; + } + if (property0.NameEquals("fullyQualifiedDomainNames"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fullyQualifiedDomainNames = array; + continue; + } + if (property0.NameEquals("subscriptions"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + subscriptions = array; + continue; + } + if (property0.NameEquals("networkSecurityPerimeters"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(PerimeterBasedAccessRule.DeserializePerimeterBasedAccessRule(item, options)); + } + networkSecurityPerimeters = array; + continue; + } + if (property0.NameEquals("emailAddresses"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + emailAddresses = array; + continue; + } + if (property0.NameEquals("phoneNumbers"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + phoneNumbers = array; + continue; + } + if (property0.NameEquals("serviceTags"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + serviceTags = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspAccessRuleData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + provisioningState, + direction, + addressPrefixes ?? new ChangeTrackingList(), + fullyQualifiedDomainNames ?? new ChangeTrackingList(), + subscriptions ?? new ChangeTrackingList(), + networkSecurityPerimeters ?? new ChangeTrackingList(), + emailAddresses ?? new ChangeTrackingList(), + phoneNumbers ?? new ChangeTrackingList(), + serviceTags ?? 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); + default: + throw new FormatException($"The model {nameof(NspAccessRuleData)} does not support writing '{options.Format}' format."); + } + } + + NspAccessRuleData 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); + return DeserializeNspAccessRuleData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspAccessRuleData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.cs new file mode 100644 index 000000000000..7c8bf27b3e78 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleData.cs @@ -0,0 +1,123 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspAccessRule data model. + /// The NSP access rule resource + /// + public partial class NspAccessRuleData : 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; + + /// Initializes a new instance of . + /// The location. + public NspAccessRuleData(AzureLocation location) : base(location) + { + AddressPrefixes = new ChangeTrackingList(); + FullyQualifiedDomainNames = new ChangeTrackingList(); + Subscriptions = new ChangeTrackingList(); + NetworkSecurityPerimeters = new ChangeTrackingList(); + EmailAddresses = new ChangeTrackingList(); + PhoneNumbers = new ChangeTrackingList(); + ServiceTags = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the scope assignment resource. + /// Direction that specifies whether the access rules is inbound/outbound. + /// Inbound address prefixes (IPv4/IPv6). + /// Outbound rules fully qualified domain name format. + /// List of subscription ids. + /// Rule specified by the perimeter id. + /// Outbound rules email address format. + /// Outbound rules phone number format. + /// Inbound rules service tag names. + /// Keeps track of any properties unknown to the library. + internal NspAccessRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, NspProvisioningState? provisioningState, AccessRuleDirection? direction, IList addressPrefixes, IList fullyQualifiedDomainNames, IList subscriptions, IReadOnlyList networkSecurityPerimeters, IList emailAddresses, IList phoneNumbers, IList serviceTags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + Direction = direction; + AddressPrefixes = addressPrefixes; + FullyQualifiedDomainNames = fullyQualifiedDomainNames; + Subscriptions = subscriptions; + NetworkSecurityPerimeters = networkSecurityPerimeters; + EmailAddresses = emailAddresses; + PhoneNumbers = phoneNumbers; + ServiceTags = serviceTags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NspAccessRuleData() + { + } + + /// The provisioning state of the scope assignment resource. + public NspProvisioningState? ProvisioningState { get; } + /// Direction that specifies whether the access rules is inbound/outbound. + public AccessRuleDirection? Direction { get; set; } + /// Inbound address prefixes (IPv4/IPv6). + public IList AddressPrefixes { get; } + /// Outbound rules fully qualified domain name format. + public IList FullyQualifiedDomainNames { get; } + /// List of subscription ids. + public IList Subscriptions { get; } + /// Rule specified by the perimeter id. + public IReadOnlyList NetworkSecurityPerimeters { get; } + /// Outbound rules email address format. + public IList EmailAddresses { get; } + /// Outbound rules phone number format. + public IList PhoneNumbers { get; } + /// Inbound rules service tag names. + public IList ServiceTags { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.Serialization.cs new file mode 100644 index 000000000000..bd9169416640 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspAccessRuleResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspAccessRuleData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspAccessRuleData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.cs new file mode 100644 index 000000000000..92677aed1650 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAccessRuleResource.cs @@ -0,0 +1,773 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspAccessRule 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 GetNspAccessRuleResource method. + /// Otherwise you can get one from its parent resource using the GetNspAccessRule method. + /// + public partial class NspAccessRuleResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The profileName. + /// The accessRuleName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspAccessRuleClientDiagnostics; + private readonly NspAccessRulesRestOperations _nspAccessRuleRestClient; + private readonly ClientDiagnostics _nspAccessRulesReconcileClientDiagnostics; + private readonly NspAccessRulesReconcileRestOperations _nspAccessRulesReconcileRestClient; + private readonly NspAccessRuleData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/profiles/accessRules"; + + /// Initializes a new instance of the class for mocking. + protected NspAccessRuleResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspAccessRuleResource(ArmClient client, NspAccessRuleData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspAccessRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspAccessRuleClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspAccessRuleApiVersion); + _nspAccessRuleRestClient = new NspAccessRulesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspAccessRuleApiVersion); + _nspAccessRulesReconcileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _nspAccessRulesReconcileRestClient = new NspAccessRulesReconcileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspAccessRuleData 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 the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Get"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Get"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAccessRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Delete"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _nspAccessRuleRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Delete"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _nspAccessRuleRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Update"); + scope.Start(); + try + { + var response = await _nspAccessRuleRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _nspAccessRuleRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspAccessRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network access rule. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.Update"); + scope.Start(); + try + { + var response = _nspAccessRuleRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _nspAccessRuleRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspAccessRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile NSP access rules + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}/reconcile + /// + /// + /// Operation Id + /// NspAccessRulesReconcile_Post + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Parameters for NSP access rule reconcile. + /// The cancellation token to use. + /// is null. + public virtual async Task> PostNspAccessRulesReconcileAsync(BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var scope = _nspAccessRulesReconcileClientDiagnostics.CreateScope("NspAccessRuleResource.PostNspAccessRulesReconcile"); + scope.Start(); + try + { + var response = await _nspAccessRulesReconcileRestClient.PostAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, unknown, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile NSP access rules + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName}/reconcile + /// + /// + /// Operation Id + /// NspAccessRulesReconcile_Post + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Parameters for NSP access rule reconcile. + /// The cancellation token to use. + /// is null. + public virtual Response PostNspAccessRulesReconcile(BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var scope = _nspAccessRulesReconcileClientDiagnostics.CreateScope("NspAccessRuleResource.PostNspAccessRulesReconcile"); + scope.Start(); + try + { + var response = _nspAccessRulesReconcileRestClient.Post(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, unknown, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// 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 = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspAccessRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspAccessRuleClientDiagnostics.CreateScope("NspAccessRuleResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAccessRuleRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAccessRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationCollection.cs new file mode 100644 index 000000000000..40528f956c89 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationCollection.cs @@ -0,0 +1,497 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspAssociations method from an instance of . + /// + public partial class NspAssociationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspAssociationClientDiagnostics; + private readonly NspAssociationsRestOperations _nspAssociationRestClient; + + /// Initializes a new instance of the class for mocking. + protected NspAssociationCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspAssociationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspAssociationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspAssociationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspAssociationResource.ResourceType, out string nspAssociationApiVersion); + _nspAssociationRestClient = new NspAssociationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspAssociationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NetworkSecurityPerimeterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NetworkSecurityPerimeterResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates a NSP resource association. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP association. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string associationName, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(new NspAssociationOperationSource(Client), _nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a NSP resource association. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP association. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string associationName, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data, cancellationToken); + var operation = new NetworkArmOperation(new NspAssociationOperationSource(Client), _nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.Get"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.Get"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP resource associations. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations + /// + /// + /// Operation Id + /// NspAssociations_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspAssociationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspAssociationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspAssociationResource(Client, NspAssociationData.DeserializeNspAssociationData(e)), _nspAssociationClientDiagnostics, Pipeline, "NspAssociationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP resource associations. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations + /// + /// + /// Operation Id + /// NspAssociations_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspAssociationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspAssociationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspAssociationResource(Client, NspAssociationData.DeserializeNspAssociationData(e)), _nspAssociationClientDiagnostics, Pipeline, "NspAssociationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.Exists"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.Exists"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP association. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, associationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.Serialization.cs new file mode 100644 index 000000000000..f75f517c6153 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.Serialization.cs @@ -0,0 +1,254 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspAssociationData : 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 override 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(NspAssociationData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(PrivateLinkResource)) + { + writer.WritePropertyName("privateLinkResource"u8); + JsonSerializer.Serialize(writer, PrivateLinkResource); + } + if (Optional.IsDefined(Profile)) + { + writer.WritePropertyName("profile"u8); + JsonSerializer.Serialize(writer, Profile); + } + if (Optional.IsDefined(AccessMode)) + { + writer.WritePropertyName("accessMode"u8); + writer.WriteStringValue(AccessMode.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(HasProvisioningIssues)) + { + writer.WritePropertyName("hasProvisioningIssues"u8); + writer.WriteStringValue(HasProvisioningIssues); + } + writer.WriteEndObject(); + } + + NspAssociationData 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(NspAssociationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspAssociationData(document.RootElement, options); + } + + internal static NspAssociationData DeserializeNspAssociationData(JsonElement element, ModelReaderWriterOptions options = null) + { + 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; + SystemData systemData = default; + NspProvisioningState? provisioningState = default; + WritableSubResource privateLinkResource = default; + WritableSubResource profile = default; + AssociationAccessMode? accessMode = default; + string hasProvisioningIssues = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NspProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("privateLinkResource"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateLinkResource = JsonSerializer.Deserialize(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("profile"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + profile = JsonSerializer.Deserialize(property0.Value.GetRawText()); + continue; + } + if (property0.NameEquals("accessMode"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + accessMode = new AssociationAccessMode(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("hasProvisioningIssues"u8)) + { + hasProvisioningIssues = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspAssociationData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + provisioningState, + privateLinkResource, + profile, + accessMode, + hasProvisioningIssues, + 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); + default: + throw new FormatException($"The model {nameof(NspAssociationData)} does not support writing '{options.Format}' format."); + } + } + + NspAssociationData 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); + return DeserializeNspAssociationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspAssociationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.cs new file mode 100644 index 000000000000..c1c96bf65e85 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationData.cs @@ -0,0 +1,124 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspAssociation data model. + /// The NSP resource association resource + /// + public partial class NspAssociationData : 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; + + /// Initializes a new instance of . + /// The location. + public NspAssociationData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The provisioning state of the resource association resource. + /// The PaaS resource to be associated. + /// Profile id to which the PaaS resource is associated. + /// Access mode on the association. + /// Specifies if there are provisioning issues. + /// Keeps track of any properties unknown to the library. + internal NspAssociationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, NspProvisioningState? provisioningState, WritableSubResource privateLinkResource, WritableSubResource profile, AssociationAccessMode? accessMode, string hasProvisioningIssues, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + PrivateLinkResource = privateLinkResource; + Profile = profile; + AccessMode = accessMode; + HasProvisioningIssues = hasProvisioningIssues; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NspAssociationData() + { + } + + /// The provisioning state of the resource association resource. + public NspProvisioningState? ProvisioningState { get; } + /// The PaaS resource to be associated. + internal WritableSubResource PrivateLinkResource { get; set; } + /// Gets or sets Id. + public ResourceIdentifier PrivateLinkResourceId + { + get => PrivateLinkResource is null ? default : PrivateLinkResource.Id; + set + { + if (PrivateLinkResource is null) + PrivateLinkResource = new WritableSubResource(); + PrivateLinkResource.Id = value; + } + } + + /// Profile id to which the PaaS resource is associated. + internal WritableSubResource Profile { get; set; } + /// Gets or sets Id. + public ResourceIdentifier ProfileId + { + get => Profile is null ? default : Profile.Id; + set + { + if (Profile is null) + Profile = new WritableSubResource(); + Profile.Id = value; + } + } + + /// Access mode on the association. + public AssociationAccessMode? AccessMode { get; set; } + /// Specifies if there are provisioning issues. + public string HasProvisioningIssues { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.Serialization.cs new file mode 100644 index 000000000000..1c997c33d767 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspAssociationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspAssociationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspAssociationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.cs new file mode 100644 index 000000000000..d595e6ad01bd --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspAssociationResource.cs @@ -0,0 +1,764 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspAssociation 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 GetNspAssociationResource method. + /// Otherwise you can get one from its parent resource using the GetNspAssociation method. + /// + public partial class NspAssociationResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The associationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspAssociationClientDiagnostics; + private readonly NspAssociationsRestOperations _nspAssociationRestClient; + private readonly ClientDiagnostics _nspAssociationReconcileClientDiagnostics; + private readonly NspAssociationReconcileRestOperations _nspAssociationReconcileRestClient; + private readonly NspAssociationData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/resourceAssociations"; + + /// Initializes a new instance of the class for mocking. + protected NspAssociationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspAssociationResource(ArmClient client, NspAssociationData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspAssociationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspAssociationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspAssociationApiVersion); + _nspAssociationRestClient = new NspAssociationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspAssociationApiVersion); + _nspAssociationReconcileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _nspAssociationReconcileRestClient = new NspAssociationReconcileRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspAssociationData 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 the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Get"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP association by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Get"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspAssociationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP association resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Delete"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(_nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.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; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP association resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Delete"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new NetworkArmOperation(_nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a NSP resource association. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Update"); + scope.Start(); + try + { + var response = await _nspAssociationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(new NspAssociationOperationSource(Client), _nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a NSP resource association. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.Update"); + scope.Start(); + try + { + var response = _nspAssociationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new NetworkArmOperation(new NspAssociationOperationSource(Client), _nspAssociationClientDiagnostics, Pipeline, _nspAssociationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile NSP association + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}/reconcile + /// + /// + /// Operation Id + /// NspAssociationReconcile_Post + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Parameters for NSP association reconcile. + /// The cancellation token to use. + /// is null. + public virtual async Task> PostNspAssociationReconcileAsync(BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var scope = _nspAssociationReconcileClientDiagnostics.CreateScope("NspAssociationResource.PostNspAssociationReconcile"); + scope.Start(); + try + { + var response = await _nspAssociationReconcileRestClient.PostAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, unknown, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Reconcile NSP association + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName}/reconcile + /// + /// + /// Operation Id + /// NspAssociationReconcile_Post + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// + /// Parameters for NSP association reconcile. + /// The cancellation token to use. + /// is null. + public virtual Response PostNspAssociationReconcile(BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var scope = _nspAssociationReconcileClientDiagnostics.CreateScope("NspAssociationResource.PostNspAssociationReconcile"); + scope.Start(); + try + { + var response = _nspAssociationReconcileRestClient.Post(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, unknown, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// 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 = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspAssociationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/resourceAssociations/{associationName} + /// + /// + /// Operation Id + /// NspAssociations_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspAssociationClientDiagnostics.CreateScope("NspAssociationResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspAssociationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspAssociationResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkCollection.cs new file mode 100644 index 000000000000..eb9969b701e6 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkCollection.cs @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspLinks method from an instance of . + /// + public partial class NspLinkCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspLinkClientDiagnostics; + private readonly NspLinksRestOperations _nspLinkRestClient; + + /// Initializes a new instance of the class for mocking. + protected NspLinkCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspLinkCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLinkClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspLinkResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspLinkResource.ResourceType, out string nspLinkApiVersion); + _nspLinkRestClient = new NspLinksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLinkApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NetworkSecurityPerimeterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NetworkSecurityPerimeterResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP link. + /// Parameters that hold the NspLink resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string linkName, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, data, cancellationToken).ConfigureAwait(false); + var uri = _nspLinkRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLinkResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP link. + /// Parameters that hold the NspLink resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string linkName, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _nspLinkRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, data, cancellationToken); + var uri = _nspLinkRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLinkResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.Get"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.Get"); + scope.Start(); + try + { + var response = _nspLinkRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP Link resources in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links + /// + /// + /// Operation Id + /// NspLinks_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLinkRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLinkRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspLinkResource(Client, NspLinkData.DeserializeNspLinkData(e)), _nspLinkClientDiagnostics, Pipeline, "NspLinkCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP Link resources in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links + /// + /// + /// Operation Id + /// NspLinks_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLinkRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLinkRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspLinkResource(Client, NspLinkData.DeserializeNspLinkData(e)), _nspLinkClientDiagnostics, Pipeline, "NspLinkCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.Exists"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.Exists"); + scope.Start(); + try + { + var response = _nspLinkRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP link. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspLinkRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.Serialization.cs new file mode 100644 index 000000000000..265c7976e7ac --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.Serialization.cs @@ -0,0 +1,358 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLinkData : 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 override 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(NspLinkData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(AutoApprovedRemotePerimeterResourceId)) + { + writer.WritePropertyName("autoApprovedRemotePerimeterResourceId"u8); + writer.WriteStringValue(AutoApprovedRemotePerimeterResourceId); + } + if (options.Format != "W" && Optional.IsDefined(RemotePerimeterGuid)) + { + writer.WritePropertyName("remotePerimeterGuid"u8); + writer.WriteStringValue(RemotePerimeterGuid.Value); + } + if (options.Format != "W" && Optional.IsDefined(RemotePerimeterLocation)) + { + writer.WritePropertyName("remotePerimeterLocation"u8); + writer.WriteStringValue(RemotePerimeterLocation); + } + if (Optional.IsCollectionDefined(LocalInboundProfiles)) + { + writer.WritePropertyName("localInboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in LocalInboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(LocalOutboundProfiles)) + { + writer.WritePropertyName("localOutboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in LocalOutboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(RemoteInboundProfiles)) + { + writer.WritePropertyName("remoteInboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in RemoteInboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RemoteOutboundProfiles)) + { + writer.WritePropertyName("remoteOutboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in RemoteOutboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WriteEndObject(); + } + + NspLinkData 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(NspLinkData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLinkData(document.RootElement, options); + } + + internal static NspLinkData DeserializeNspLinkData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + NspLinkProvisioningState? provisioningState = default; + string autoApprovedRemotePerimeterResourceId = default; + Guid? remotePerimeterGuid = default; + string remotePerimeterLocation = default; + IList localInboundProfiles = default; + IReadOnlyList localOutboundProfiles = default; + IList remoteInboundProfiles = default; + IReadOnlyList remoteOutboundProfiles = default; + string description = default; + NspLinkStatus? status = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NspLinkProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("autoApprovedRemotePerimeterResourceId"u8)) + { + autoApprovedRemotePerimeterResourceId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("remotePerimeterGuid"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + remotePerimeterGuid = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("remotePerimeterLocation"u8)) + { + remotePerimeterLocation = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("localInboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + localInboundProfiles = array; + continue; + } + if (property0.NameEquals("localOutboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + localOutboundProfiles = array; + continue; + } + if (property0.NameEquals("remoteInboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + remoteInboundProfiles = array; + continue; + } + if (property0.NameEquals("remoteOutboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + remoteOutboundProfiles = array; + continue; + } + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new NspLinkStatus(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLinkData( + id, + name, + type, + systemData, + provisioningState, + autoApprovedRemotePerimeterResourceId, + remotePerimeterGuid, + remotePerimeterLocation, + localInboundProfiles ?? new ChangeTrackingList(), + localOutboundProfiles ?? new ChangeTrackingList(), + remoteInboundProfiles ?? new ChangeTrackingList(), + remoteOutboundProfiles ?? new ChangeTrackingList(), + description, + status, + etag, + 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); + default: + throw new FormatException($"The model {nameof(NspLinkData)} does not support writing '{options.Format}' format."); + } + } + + NspLinkData 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); + return DeserializeNspLinkData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLinkData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.cs new file mode 100644 index 000000000000..e2b794688409 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkData.cs @@ -0,0 +1,119 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspLink data model. + /// The network security perimeter link resource + /// + public partial class NspLinkData : ResourceData + { + /// + /// 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 NspLinkData() + { + LocalInboundProfiles = new ChangeTrackingList(); + LocalOutboundProfiles = new ChangeTrackingList(); + RemoteInboundProfiles = new ChangeTrackingList(); + RemoteOutboundProfiles = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The provisioning state of the NSP Link resource. + /// Perimeter ARM Id for the remote NSP with which the link gets created in Auto-approval mode. It should be used when the NSP admin have Microsoft.Network/networkSecurityPerimeters/linkPerimeter/action permission on the remote NSP resource. + /// Remote NSP Guid with which the link gets created. + /// Remote NSP location with which the link gets created. + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// Remote Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. This property can only be updated in auto-approval mode. + /// Remote Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// A message passed to the owner of the remote NSP link resource with this connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. Restricted to 140 chars. + /// The NSP link state. + /// A unique read-only string that changes whenever the resource is updated. + /// Keeps track of any properties unknown to the library. + internal NspLinkData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, NspLinkProvisioningState? provisioningState, string autoApprovedRemotePerimeterResourceId, Guid? remotePerimeterGuid, string remotePerimeterLocation, IList localInboundProfiles, IReadOnlyList localOutboundProfiles, IList remoteInboundProfiles, IReadOnlyList remoteOutboundProfiles, string description, NspLinkStatus? status, ETag? etag, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ProvisioningState = provisioningState; + AutoApprovedRemotePerimeterResourceId = autoApprovedRemotePerimeterResourceId; + RemotePerimeterGuid = remotePerimeterGuid; + RemotePerimeterLocation = remotePerimeterLocation; + LocalInboundProfiles = localInboundProfiles; + LocalOutboundProfiles = localOutboundProfiles; + RemoteInboundProfiles = remoteInboundProfiles; + RemoteOutboundProfiles = remoteOutboundProfiles; + Description = description; + Status = status; + ETag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The provisioning state of the NSP Link resource. + public NspLinkProvisioningState? ProvisioningState { get; } + /// Perimeter ARM Id for the remote NSP with which the link gets created in Auto-approval mode. It should be used when the NSP admin have Microsoft.Network/networkSecurityPerimeters/linkPerimeter/action permission on the remote NSP resource. + public string AutoApprovedRemotePerimeterResourceId { get; set; } + /// Remote NSP Guid with which the link gets created. + public Guid? RemotePerimeterGuid { get; } + /// Remote NSP location with which the link gets created. + public string RemotePerimeterLocation { get; } + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + public IList LocalInboundProfiles { get; } + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + public IReadOnlyList LocalOutboundProfiles { get; } + /// Remote Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. This property can only be updated in auto-approval mode. + public IList RemoteInboundProfiles { get; } + /// Remote Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + public IReadOnlyList RemoteOutboundProfiles { get; } + /// A message passed to the owner of the remote NSP link resource with this connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. Restricted to 140 chars. + public string Description { get; set; } + /// The NSP link state. + public NspLinkStatus? Status { get; } + /// A unique read-only string that changes whenever the resource is updated. + public ETag? ETag { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceCollection.cs new file mode 100644 index 000000000000..29bbf7c5e95c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceCollection.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspLinkReferences method from an instance of . + /// + public partial class NspLinkReferenceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspLinkReferenceClientDiagnostics; + private readonly NspLinkReferencesRestOperations _nspLinkReferenceRestClient; + + /// Initializes a new instance of the class for mocking. + protected NspLinkReferenceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspLinkReferenceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLinkReferenceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspLinkReferenceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspLinkReferenceResource.ResourceType, out string nspLinkReferenceApiVersion); + _nspLinkReferenceRestClient = new NspLinkReferencesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLinkReferenceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NetworkSecurityPerimeterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NetworkSecurityPerimeterResource.ResourceType), nameof(id)); + } + + /// + /// Gets the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.Get"); + scope.Start(); + try + { + var response = await _nspLinkReferenceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.Get"); + scope.Start(); + try + { + var response = _nspLinkReferenceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences + /// + /// + /// Operation Id + /// NspLinkReferences_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLinkReferenceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLinkReferenceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspLinkReferenceResource(Client, NspLinkReferenceData.DeserializeNspLinkReferenceData(e)), _nspLinkReferenceClientDiagnostics, Pipeline, "NspLinkReferenceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences + /// + /// + /// Operation Id + /// NspLinkReferences_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLinkReferenceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLinkReferenceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspLinkReferenceResource(Client, NspLinkReferenceData.DeserializeNspLinkReferenceData(e)), _nspLinkReferenceClientDiagnostics, Pipeline, "NspLinkReferenceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.Exists"); + scope.Start(); + try + { + var response = await _nspLinkReferenceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.Exists"); + scope.Start(); + try + { + var response = _nspLinkReferenceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspLinkReferenceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP linkReference. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspLinkReferenceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, linkReferenceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.Serialization.cs new file mode 100644 index 000000000000..2cce45776c6c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.Serialization.cs @@ -0,0 +1,358 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLinkReferenceData : 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 override 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(NspLinkReferenceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(RemotePerimeterResourceId)) + { + writer.WritePropertyName("remotePerimeterResourceId"u8); + writer.WriteStringValue(RemotePerimeterResourceId); + } + if (options.Format != "W" && Optional.IsDefined(RemotePerimeterGuid)) + { + writer.WritePropertyName("remotePerimeterGuid"u8); + writer.WriteStringValue(RemotePerimeterGuid.Value); + } + if (options.Format != "W" && Optional.IsDefined(RemotePerimeterLocation)) + { + writer.WritePropertyName("remotePerimeterLocation"u8); + writer.WriteStringValue(RemotePerimeterLocation); + } + if (Optional.IsCollectionDefined(LocalInboundProfiles)) + { + writer.WritePropertyName("localInboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in LocalInboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(LocalOutboundProfiles)) + { + writer.WritePropertyName("localOutboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in LocalOutboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RemoteInboundProfiles)) + { + writer.WritePropertyName("remoteInboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in RemoteInboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RemoteOutboundProfiles)) + { + writer.WritePropertyName("remoteOutboundProfiles"u8); + writer.WriteStartArray(); + foreach (var item in RemoteOutboundProfiles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WriteEndObject(); + } + + NspLinkReferenceData 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(NspLinkReferenceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLinkReferenceData(document.RootElement, options); + } + + internal static NspLinkReferenceData DeserializeNspLinkReferenceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ETag? etag = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + NspLinkProvisioningState? provisioningState = default; + string remotePerimeterResourceId = default; + Guid? remotePerimeterGuid = default; + string remotePerimeterLocation = default; + IList localInboundProfiles = default; + IReadOnlyList localOutboundProfiles = default; + IReadOnlyList remoteInboundProfiles = default; + IReadOnlyList remoteOutboundProfiles = default; + string description = default; + NspLinkStatus? status = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NspLinkProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("remotePerimeterResourceId"u8)) + { + remotePerimeterResourceId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("remotePerimeterGuid"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + remotePerimeterGuid = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("remotePerimeterLocation"u8)) + { + remotePerimeterLocation = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("localInboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + localInboundProfiles = array; + continue; + } + if (property0.NameEquals("localOutboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + localOutboundProfiles = array; + continue; + } + if (property0.NameEquals("remoteInboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + remoteInboundProfiles = array; + continue; + } + if (property0.NameEquals("remoteOutboundProfiles"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + remoteOutboundProfiles = array; + continue; + } + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new NspLinkStatus(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLinkReferenceData( + id, + name, + type, + systemData, + provisioningState, + remotePerimeterResourceId, + remotePerimeterGuid, + remotePerimeterLocation, + localInboundProfiles ?? new ChangeTrackingList(), + localOutboundProfiles ?? new ChangeTrackingList(), + remoteInboundProfiles ?? new ChangeTrackingList(), + remoteOutboundProfiles ?? new ChangeTrackingList(), + description, + status, + etag, + 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); + default: + throw new FormatException($"The model {nameof(NspLinkReferenceData)} does not support writing '{options.Format}' format."); + } + } + + NspLinkReferenceData 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); + return DeserializeNspLinkReferenceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLinkReferenceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.cs new file mode 100644 index 000000000000..b8aafc7d9467 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceData.cs @@ -0,0 +1,119 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspLinkReference data model. + /// The network security perimeter linkReference resource + /// + public partial class NspLinkReferenceData : ResourceData + { + /// + /// 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 NspLinkReferenceData() + { + LocalInboundProfiles = new ChangeTrackingList(); + LocalOutboundProfiles = new ChangeTrackingList(); + RemoteInboundProfiles = new ChangeTrackingList(); + RemoteOutboundProfiles = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The provisioning state of the NSP LinkReference resource. + /// Perimeter ARM Id for the remote NSP with which the link is created. + /// Remote NSP Guid with which the link is created. + /// Remote NSP location with which the link gets created. + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + /// Remote Inbound profile names to which Inbound is allowed. ['*'] value implies inbound is allowed to all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + /// Remote Outbound profile names from which Outbound is allowed. ['*'] value implies outbound is allowed from all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + /// A message sent by the remote NSP link admin for connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. + /// The NSP linkReference state. It cannot be changed if link is created in auto-approval mode. + /// A unique read-only string that changes whenever the resource is updated. + /// Keeps track of any properties unknown to the library. + internal NspLinkReferenceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, NspLinkProvisioningState? provisioningState, string remotePerimeterResourceId, Guid? remotePerimeterGuid, string remotePerimeterLocation, IList localInboundProfiles, IReadOnlyList localOutboundProfiles, IReadOnlyList remoteInboundProfiles, IReadOnlyList remoteOutboundProfiles, string description, NspLinkStatus? status, ETag? etag, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + ProvisioningState = provisioningState; + RemotePerimeterResourceId = remotePerimeterResourceId; + RemotePerimeterGuid = remotePerimeterGuid; + RemotePerimeterLocation = remotePerimeterLocation; + LocalInboundProfiles = localInboundProfiles; + LocalOutboundProfiles = localOutboundProfiles; + RemoteInboundProfiles = remoteInboundProfiles; + RemoteOutboundProfiles = remoteOutboundProfiles; + Description = description; + Status = status; + ETag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The provisioning state of the NSP LinkReference resource. + public NspLinkProvisioningState? ProvisioningState { get; } + /// Perimeter ARM Id for the remote NSP with which the link is created. + public string RemotePerimeterResourceId { get; } + /// Remote NSP Guid with which the link is created. + public Guid? RemotePerimeterGuid { get; } + /// Remote NSP location with which the link gets created. + public string RemotePerimeterLocation { get; } + /// Local Inbound profile names to which Inbound is allowed. Use ['*'] to allow inbound to all profiles. + public IList LocalInboundProfiles { get; } + /// Local Outbound profile names from which Outbound is allowed. In current version, it is readonly property and it's value is set to ['*'] to allow outbound from all profiles. In later version, user will be able to modify it. + public IReadOnlyList LocalOutboundProfiles { get; } + /// Remote Inbound profile names to which Inbound is allowed. ['*'] value implies inbound is allowed to all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + public IReadOnlyList RemoteInboundProfiles { get; } + /// Remote Outbound profile names from which Outbound is allowed. ['*'] value implies outbound is allowed from all profiles at remote perimeter. This property can only be updated from corresponding link resource present in remote perimeter. + public IReadOnlyList RemoteOutboundProfiles { get; } + /// A message sent by the remote NSP link admin for connection request. In case of Auto-approved flow, it is default to 'Auto Approved'. + public string Description { get; } + /// The NSP linkReference state. It cannot be changed if link is created in auto-approval mode. + public NspLinkStatus? Status { get; set; } + /// A unique read-only string that changes whenever the resource is updated. + public ETag? ETag { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.Serialization.cs new file mode 100644 index 000000000000..3124e666bfe1 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLinkReferenceResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspLinkReferenceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspLinkReferenceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.cs new file mode 100644 index 000000000000..174c864d1e35 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkReferenceResource.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspLinkReference 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 GetNspLinkReferenceResource method. + /// Otherwise you can get one from its parent resource using the GetNspLinkReference method. + /// + public partial class NspLinkReferenceResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The linkReferenceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkReferenceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspLinkReferenceClientDiagnostics; + private readonly NspLinkReferencesRestOperations _nspLinkReferenceRestClient; + private readonly NspLinkReferenceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/linkReferences"; + + /// Initializes a new instance of the class for mocking. + protected NspLinkReferenceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspLinkReferenceResource(ArmClient client, NspLinkReferenceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspLinkReferenceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLinkReferenceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspLinkReferenceApiVersion); + _nspLinkReferenceRestClient = new NspLinkReferencesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLinkReferenceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspLinkReferenceData 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 the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceResource.Get"); + scope.Start(); + try + { + var response = await _nspLinkReferenceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP linkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceResource.Get"); + scope.Start(); + try + { + var response = _nspLinkReferenceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkReferenceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP LinkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceResource.Delete"); + scope.Start(); + try + { + var response = await _nspLinkReferenceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(_nspLinkReferenceClientDiagnostics, Pipeline, _nspLinkReferenceRestClient.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; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP LinkReference resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/linkReferences/{linkReferenceName} + /// + /// + /// Operation Id + /// NspLinkReferences_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLinkReferenceClientDiagnostics.CreateScope("NspLinkReferenceResource.Delete"); + scope.Start(); + try + { + var response = _nspLinkReferenceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new NetworkArmOperation(_nspLinkReferenceClientDiagnostics, Pipeline, _nspLinkReferenceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.Serialization.cs new file mode 100644 index 000000000000..c6d96d7050c1 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLinkResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspLinkData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspLinkData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.cs new file mode 100644 index 000000000000..9237dad83d06 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLinkResource.cs @@ -0,0 +1,351 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspLink 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 GetNspLinkResource method. + /// Otherwise you can get one from its parent resource using the GetNspLink method. + /// + public partial class NspLinkResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The linkName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspLinkClientDiagnostics; + private readonly NspLinksRestOperations _nspLinkRestClient; + private readonly NspLinkData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/links"; + + /// Initializes a new instance of the class for mocking. + protected NspLinkResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspLinkResource(ArmClient client, NspLinkData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLinkClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspLinkApiVersion); + _nspLinkRestClient = new NspLinksRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLinkApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspLinkData 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 the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Get"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Get"); + scope.Start(); + try + { + var response = _nspLinkRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP Link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Delete"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new NetworkArmOperation(_nspLinkClientDiagnostics, Pipeline, _nspLinkRestClient.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; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP Link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Delete"); + scope.Start(); + try + { + var response = _nspLinkRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new NetworkArmOperation(_nspLinkClientDiagnostics, Pipeline, _nspLinkRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspLink resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Update"); + scope.Start(); + try + { + var response = await _nspLinkRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _nspLinkRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLinkResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP link resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/links/{linkName} + /// + /// + /// Operation Id + /// NspLinks_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspLink resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLinkClientDiagnostics.CreateScope("NspLinkResource.Update"); + scope.Start(); + try + { + var response = _nspLinkRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _nspLinkRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLinkResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationCollection.cs new file mode 100644 index 000000000000..5d8bb3bd7112 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationCollection.cs @@ -0,0 +1,502 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspLoggingConfigurations method from an instance of . + /// + public partial class NspLoggingConfigurationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspLoggingConfigurationClientDiagnostics; + private readonly NspLoggingConfigurationRestOperations _nspLoggingConfigurationRestClient; + private readonly ClientDiagnostics _nspLoggingConfigurationClientDiagnostics0; + private readonly NspLoggingConfigurationsRestOperations _nspLoggingConfigurationRestClient0; + + /// Initializes a new instance of the class for mocking. + protected NspLoggingConfigurationCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspLoggingConfigurationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLoggingConfigurationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspLoggingConfigurationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspLoggingConfigurationResource.ResourceType, out string nspLoggingConfigurationApiVersion); + _nspLoggingConfigurationRestClient = new NspLoggingConfigurationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLoggingConfigurationApiVersion); + _nspLoggingConfigurationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspLoggingConfigurationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspLoggingConfigurationResource.ResourceType, out string nspLoggingConfigurationApiVersion); + _nspLoggingConfigurationRestClient = new NspLoggingConfigurationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLoggingConfigurationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NetworkSecurityPerimeterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NetworkSecurityPerimeterResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP logging configuration. Accepts 'instance' as name. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string loggingConfigurationName, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, data, cancellationToken).ConfigureAwait(false); + var uri = _nspLoggingConfigurationRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLoggingConfigurationResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP logging configuration. Accepts 'instance' as name. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string loggingConfigurationName, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, data, cancellationToken); + var uri = _nspLoggingConfigurationRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLoggingConfigurationResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.Get"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.Get"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations + /// + /// + /// Operation Id + /// NspLoggingConfigurations_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLoggingConfigurationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLoggingConfigurationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspLoggingConfigurationResource(Client, NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(e)), _nspLoggingConfigurationClientDiagnostics, Pipeline, "NspLoggingConfigurationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations + /// + /// + /// Operation Id + /// NspLoggingConfigurations_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspLoggingConfigurationRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspLoggingConfigurationRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspLoggingConfigurationResource(Client, NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(e)), _nspLoggingConfigurationClientDiagnostics, Pipeline, "NspLoggingConfigurationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.Exists"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.Exists"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, loggingConfigurationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.Serialization.cs new file mode 100644 index 000000000000..5f6edbb0bdc9 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.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.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLoggingConfigurationData : 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 override 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(NspLoggingConfigurationData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("etag"u8); + writer.WriteStringValue(ETag.Value.ToString()); + } + } + + NspLoggingConfigurationData 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(NspLoggingConfigurationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspLoggingConfigurationData(document.RootElement, options); + } + + internal static NspLoggingConfigurationData DeserializeNspLoggingConfigurationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NspLoggingConfigurationProperties properties = default; + ETag? etag = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NspLoggingConfigurationProperties.DeserializeNspLoggingConfigurationProperties(property.Value, options); + continue; + } + if (property.NameEquals("etag"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + etag = new ETag(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspLoggingConfigurationData( + id, + name, + type, + systemData, + properties, + etag, + 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); + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationData)} does not support writing '{options.Format}' format."); + } + } + + NspLoggingConfigurationData 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); + return DeserializeNspLoggingConfigurationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspLoggingConfigurationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.cs new file mode 100644 index 000000000000..287e17f443d5 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationData.cs @@ -0,0 +1,79 @@ +// 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.Models; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspLoggingConfiguration data model. + /// The NSP logging configuration + /// + public partial class NspLoggingConfigurationData : ResourceData + { + /// + /// 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 NspLoggingConfigurationData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Properties of the NSP logging configuration. + /// A unique read-only string that changes whenever the resource is updated. + /// Keeps track of any properties unknown to the library. + internal NspLoggingConfigurationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, NspLoggingConfigurationProperties properties, ETag? etag, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + ETag = etag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Properties of the NSP logging configuration. + public NspLoggingConfigurationProperties Properties { get; set; } + /// A unique read-only string that changes whenever the resource is updated. + public ETag? ETag { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.Serialization.cs new file mode 100644 index 000000000000..c21b222d61fe --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspLoggingConfigurationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspLoggingConfigurationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspLoggingConfigurationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.cs new file mode 100644 index 000000000000..438c462f4869 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspLoggingConfigurationResource.cs @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspLoggingConfiguration 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 GetNspLoggingConfigurationResource method. + /// Otherwise you can get one from its parent resource using the GetNspLoggingConfiguration method. + /// + public partial class NspLoggingConfigurationResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The loggingConfigurationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspLoggingConfigurationClientDiagnostics; + private readonly NspLoggingConfigurationRestOperations _nspLoggingConfigurationRestClient; + private readonly NspLoggingConfigurationData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/loggingConfigurations"; + + /// Initializes a new instance of the class for mocking. + protected NspLoggingConfigurationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspLoggingConfigurationResource(ArmClient client, NspLoggingConfigurationData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspLoggingConfigurationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspLoggingConfigurationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspLoggingConfigurationApiVersion); + _nspLoggingConfigurationRestClient = new NspLoggingConfigurationRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspLoggingConfigurationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspLoggingConfigurationData 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 the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Get"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Get"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspLoggingConfigurationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP Logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Delete"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _nspLoggingConfigurationRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP Logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Delete"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _nspLoggingConfigurationRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Update"); + scope.Start(); + try + { + var response = await _nspLoggingConfigurationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _nspLoggingConfigurationRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLoggingConfigurationResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates NSP logging configuration. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/loggingConfigurations/{loggingConfigurationName} + /// + /// + /// Operation Id + /// NspLoggingConfiguration_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspLoggingConfigurationClientDiagnostics.CreateScope("NspLoggingConfigurationResource.Update"); + scope.Start(); + try + { + var response = _nspLoggingConfigurationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _nspLoggingConfigurationRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspLoggingConfigurationResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileCollection.cs new file mode 100644 index 000000000000..dae5e62f443a --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileCollection.cs @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetNspProfiles method from an instance of . + /// + public partial class NspProfileCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _nspProfileClientDiagnostics; + private readonly NspProfilesRestOperations _nspProfileRestClient; + + /// Initializes a new instance of the class for mocking. + protected NspProfileCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal NspProfileCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", NspProfileResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NspProfileResource.ResourceType, out string nspProfileApiVersion); + _nspProfileRestClient = new NspProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspProfileApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NetworkSecurityPerimeterResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NetworkSecurityPerimeterResource.ResourceType), nameof(id)); + } + + /// + /// Creates or updates a network profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP profile. + /// Parameters that hold the NspProfile resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string profileName, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data, cancellationToken).ConfigureAwait(false); + var uri = _nspProfileRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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 name of the NSP profile. + /// Parameters that hold the NspProfile resource to be created/updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string profileName, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _nspProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data, cancellationToken); + var uri = _nspProfileRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.Get"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.Get"); + scope.Start(); + try + { + var response = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the NSP profiles in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles + /// + /// + /// Operation Id + /// NspProfiles_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspProfileRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspProfileRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NspProfileResource(Client, NspProfileData.DeserializeNspProfileData(e)), _nspProfileClientDiagnostics, Pipeline, "NspProfileCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the NSP profiles in the specified network security perimeter. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles + /// + /// + /// Operation Id + /// NspProfiles_List + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _nspProfileRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _nspProfileRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, top, skipToken); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NspProfileResource(Client, NspProfileData.DeserializeNspProfileData(e)), _nspProfileClientDiagnostics, Pipeline, "NspProfileCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.Exists"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.Exists"); + scope.Start(); + try + { + var response = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP profile. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileCollection.GetIfExists"); + scope.Start(); + try + { + var response = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, profileName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.Serialization.cs new file mode 100644 index 000000000000..e08b03a04070 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.Serialization.cs @@ -0,0 +1,200 @@ +// 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.Models; + +namespace Azure.ResourceManager.Network +{ + public partial class NspProfileData : 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 override 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(NspProfileData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(AccessRulesVersion)) + { + writer.WritePropertyName("accessRulesVersion"u8); + writer.WriteStringValue(AccessRulesVersion); + } + if (options.Format != "W" && Optional.IsDefined(DiagnosticSettingsVersion)) + { + writer.WritePropertyName("diagnosticSettingsVersion"u8); + writer.WriteStringValue(DiagnosticSettingsVersion); + } + writer.WriteEndObject(); + } + + NspProfileData 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(NspProfileData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNspProfileData(document.RootElement, options); + } + + internal static NspProfileData DeserializeNspProfileData(JsonElement element, ModelReaderWriterOptions options = null) + { + 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; + SystemData systemData = default; + string accessRulesVersion = default; + string diagnosticSettingsVersion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.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; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"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()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("accessRulesVersion"u8)) + { + accessRulesVersion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("diagnosticSettingsVersion"u8)) + { + diagnosticSettingsVersion = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NspProfileData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + accessRulesVersion, + diagnosticSettingsVersion, + 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); + default: + throw new FormatException($"The model {nameof(NspProfileData)} does not support writing '{options.Format}' format."); + } + } + + NspProfileData 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); + return DeserializeNspProfileData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NspProfileData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.cs new file mode 100644 index 000000000000..ea1810461b33 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileData.cs @@ -0,0 +1,86 @@ +// 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.Models; + +namespace Azure.ResourceManager.Network +{ + /// + /// A class representing the NspProfile data model. + /// The network security perimeter profile resource + /// + public partial class NspProfileData : 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; + + /// Initializes a new instance of . + /// The location. + public NspProfileData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Version number that increases with every update to access rules within the profile. + /// Version number that increases with every update to diagnostic settings within the profile. + /// Keeps track of any properties unknown to the library. + internal NspProfileData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string accessRulesVersion, string diagnosticSettingsVersion, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + AccessRulesVersion = accessRulesVersion; + DiagnosticSettingsVersion = diagnosticSettingsVersion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NspProfileData() + { + } + + /// Version number that increases with every update to access rules within the profile. + public string AccessRulesVersion { get; } + /// Version number that increases with every update to diagnostic settings within the profile. + public string DiagnosticSettingsVersion { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.Serialization.cs new file mode 100644 index 000000000000..0747b73e5bed --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class NspProfileResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NspProfileData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + NspProfileData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.cs new file mode 100644 index 000000000000..1a166eb3cf62 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/NspProfileResource.cs @@ -0,0 +1,761 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing a NspProfile 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 GetNspProfileResource method. + /// Otherwise you can get one from its parent resource using the GetNspProfile method. + /// + public partial class NspProfileResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The networkSecurityPerimeterName. + /// The profileName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _nspProfileClientDiagnostics; + private readonly NspProfilesRestOperations _nspProfileRestClient; + private readonly NspProfileData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/networkSecurityPerimeters/profiles"; + + /// Initializes a new instance of the class for mocking. + protected NspProfileResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NspProfileResource(ArmClient client, NspProfileData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal NspProfileResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _nspProfileClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string nspProfileApiVersion); + _nspProfileRestClient = new NspProfilesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, nspProfileApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 NspProfileData 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 NspAccessRuleResources in the NspProfile. + /// An object representing collection of NspAccessRuleResources and their operations over a NspAccessRuleResource. + public virtual NspAccessRuleCollection GetNspAccessRules() + { + return GetCachedClient(client => new NspAccessRuleCollection(client, Id)); + } + + /// + /// Gets the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNspAccessRuleAsync(string accessRuleName, CancellationToken cancellationToken = default) + { + return await GetNspAccessRules().GetAsync(accessRuleName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the specified NSP access rule by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName}/accessRules/{accessRuleName} + /// + /// + /// Operation Id + /// NspAccessRules_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the NSP access rule. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNspAccessRule(string accessRuleName, CancellationToken cancellationToken = default) + { + return GetNspAccessRules().Get(accessRuleName, cancellationToken); + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Get"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the specified NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Get"); + scope.Start(); + try + { + var response = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NspProfileResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Delete"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _nspProfileRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an NSP profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Delete + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Delete"); + scope.Start(); + try + { + var response = _nspProfileRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _nspProfileRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspProfile resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Update"); + scope.Start(); + try + { + var response = await _nspProfileRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _nspProfileRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates or updates a network profile. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// 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. + /// Parameters that hold the NspProfile resource to be created/updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.Update"); + scope.Start(); + try + { + var response = _nspProfileRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _nspProfileRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NetworkArmOperation(Response.FromValue(new NspProfileResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// 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 = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + 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 _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + 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 _nspProfileRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityPerimeters/{networkSecurityPerimeterName}/profiles/{profileName} + /// + /// + /// Operation Id + /// NspProfiles_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _nspProfileClientDiagnostics.CreateScope("NspProfileResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _nspProfileRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NspProfileResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultCollection.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultCollection.cs new file mode 100644 index 000000000000..cf89096284a5 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultCollection.cs @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Network +{ + /// + /// 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 GetOperationStatusResults method from an instance of . + /// + public partial class OperationStatusResultCollection : ArmCollection + { + private readonly ClientDiagnostics _operationStatusResultNspOperationStatusClientDiagnostics; + private readonly NspOperationStatusRestOperations _operationStatusResultNspOperationStatusRestClient; + + /// Initializes a new instance of the class for mocking. + protected OperationStatusResultCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal OperationStatusResultCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _operationStatusResultNspOperationStatusClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", OperationStatusResultResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(OperationStatusResultResource.ResourceType, out string operationStatusResultNspOperationStatusApiVersion); + _operationStatusResultNspOperationStatusRestClient = new NspOperationStatusRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, operationStatusResultNspOperationStatusApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != SubscriptionResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, SubscriptionResource.ResourceType), nameof(id)); + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.Get"); + scope.Start(); + try + { + var response = await _operationStatusResultNspOperationStatusRestClient.GetAsync(Id.SubscriptionId, location, operationId, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.Get"); + scope.Start(); + try + { + var response = _operationStatusResultNspOperationStatusRestClient.Get(Id.SubscriptionId, location, operationId, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.Exists"); + scope.Start(); + try + { + var response = await _operationStatusResultNspOperationStatusRestClient.GetAsync(Id.SubscriptionId, location, operationId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.Exists"); + scope.Start(); + try + { + var response = _operationStatusResultNspOperationStatusRestClient.Get(Id.SubscriptionId, location, operationId, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _operationStatusResultNspOperationStatusRestClient.GetAsync(Id.SubscriptionId, location, operationId, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The location of network security perimeter. + /// The operation id of the async operation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultCollection.GetIfExists"); + scope.Start(); + try + { + var response = _operationStatusResultNspOperationStatusRestClient.Get(Id.SubscriptionId, location, operationId, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.Serialization.cs new file mode 100644 index 000000000000..31b574889e69 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.Serialization.cs @@ -0,0 +1,262 @@ +// 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.Network +{ + public partial class OperationStatusResultData : 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(OperationStatusResultData)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + if (Optional.IsDefined(PercentComplete)) + { + writer.WritePropertyName("percentComplete"u8); + writer.WriteNumberValue(PercentComplete.Value); + } + if (Optional.IsDefined(StartOn)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn.Value, "O"); + } + if (Optional.IsDefined(EndOn)) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndOn.Value, "O"); + } + if (Optional.IsCollectionDefined(Operations)) + { + writer.WritePropertyName("operations"u8); + writer.WriteStartArray(); + foreach (var item in Operations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + JsonSerializer.Serialize(writer, Error); + } + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OperationStatusResultData 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(OperationStatusResultData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationStatusResultData(document.RootElement, options); + } + + internal static OperationStatusResultData DeserializeOperationStatusResultData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + ResourceIdentifier resourceId = default; + string name = default; + string status = default; + float? percentComplete = default; + DateTimeOffset? startTime = default; + DateTimeOffset? endTime = default; + IReadOnlyList operations = default; + ResponseError error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("percentComplete"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + percentComplete = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("startTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("operations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeserializeOperationStatusResultData(item, options)); + } + operations = array; + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationStatusResultData( + id, + resourceId, + name, + status, + percentComplete, + startTime, + endTime, + operations ?? new ChangeTrackingList(), + error, + 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); + default: + throw new FormatException($"The model {nameof(OperationStatusResultData)} does not support writing '{options.Format}' format."); + } + } + + OperationStatusResultData 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); + return DeserializeOperationStatusResultData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationStatusResultData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.cs new file mode 100644 index 000000000000..bf890ded158c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultData.cs @@ -0,0 +1,112 @@ +// 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.Network +{ + /// + /// A class representing the OperationStatusResult data model. + /// The current status of an async operation. + /// + public partial class OperationStatusResultData + { + /// + /// 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 . + /// Operation status. + /// is null. + internal OperationStatusResultData(string status) + { + Argument.AssertNotNull(status, nameof(status)); + + Status = status; + Operations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Fully qualified ID for the async operation. + /// Fully qualified ID of the resource against which the original async operation was started. + /// Name of the async operation. + /// Operation status. + /// Percent of the operation that is complete. + /// The start time of the operation. + /// The end time of the operation. + /// The operations list. + /// If present, details of the operation error. + /// Keeps track of any properties unknown to the library. + internal OperationStatusResultData(ResourceIdentifier id, ResourceIdentifier resourceId, string name, string status, float? percentComplete, DateTimeOffset? startOn, DateTimeOffset? endOn, IReadOnlyList operations, ResponseError error, IDictionary serializedAdditionalRawData) + { + Id = id; + ResourceId = resourceId; + Name = name; + Status = status; + PercentComplete = percentComplete; + StartOn = startOn; + EndOn = endOn; + Operations = operations; + Error = error; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationStatusResultData() + { + } + + /// Fully qualified ID for the async operation. + public ResourceIdentifier Id { get; } + /// Fully qualified ID of the resource against which the original async operation was started. + public ResourceIdentifier ResourceId { get; } + /// Name of the async operation. + public string Name { get; } + /// Operation status. + public string Status { get; } + /// Percent of the operation that is complete. + public float? PercentComplete { get; } + /// The start time of the operation. + public DateTimeOffset? StartOn { get; } + /// The end time of the operation. + public DateTimeOffset? EndOn { get; } + /// The operations list. + public IReadOnlyList Operations { get; } + /// If present, details of the operation error. + public ResponseError Error { get; } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.Serialization.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.Serialization.cs new file mode 100644 index 000000000000..dab4020d248a --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Network +{ + public partial class OperationStatusResultResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + OperationStatusResultData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + OperationStatusResultData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.cs new file mode 100644 index 000000000000..6e4ef15373c9 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/OperationStatusResultResource.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Network +{ + /// + /// A Class representing an OperationStatusResult 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 GetOperationStatusResultResource method. + /// Otherwise you can get one from its parent resource using the GetOperationStatusResult method. + /// + public partial class OperationStatusResultResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The location. + /// The operationId. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, AzureLocation location, string operationId) + { + var resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _operationStatusResultNspOperationStatusClientDiagnostics; + private readonly NspOperationStatusRestOperations _operationStatusResultNspOperationStatusRestClient; + private readonly OperationStatusResultData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Network/locations/networkSecurityPerimeterOperationStatuses"; + + /// Initializes a new instance of the class for mocking. + protected OperationStatusResultResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal OperationStatusResultResource(ArmClient client, OperationStatusResultData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal OperationStatusResultResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _operationStatusResultNspOperationStatusClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Network", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string operationStatusResultNspOperationStatusApiVersion); + _operationStatusResultNspOperationStatusRestClient = new NspOperationStatusRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, operationStatusResultNspOperationStatusApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 OperationStatusResultData 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 the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultResource.Get"); + scope.Start(); + try + { + var response = await _operationStatusResultNspOperationStatusRestClient.GetAsync(Id.SubscriptionId, new AzureLocation(Id.Parent.Name), Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the operation status for the given operation id. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/networkSecurityPerimeterOperationStatuses/{operationId} + /// + /// + /// Operation Id + /// NspOperationStatus_Get + /// + /// + /// Default Api Version + /// 2024-07-01 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _operationStatusResultNspOperationStatusClientDiagnostics.CreateScope("OperationStatusResultResource.Get"); + scope.Start(); + try + { + var response = _operationStatusResultNspOperationStatusRestClient.Get(Id.SubscriptionId, new AzureLocation(Id.Parent.Name), Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new OperationStatusResultResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NetworkSecurityPerimetersRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NetworkSecurityPerimetersRestOperations.cs new file mode 100644 index 000000000000..396e68812792 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NetworkSecurityPerimetersRestOperations.cs @@ -0,0 +1,791 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NetworkSecurityPerimetersRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NetworkSecurityPerimetersRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NetworkSecurityPerimetersRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified network security perimeter by the name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// 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 networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NetworkSecurityPerimeterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified network security perimeter by the name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// 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 networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NetworkSecurityPerimeterData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates a Network Security Perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// Parameter supplied to create or update the network security perimeter. + /// 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 networkSecurityPerimeterName, NetworkSecurityPerimeterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NetworkSecurityPerimeterData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates a Network Security Perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// Parameter supplied to create or update the network security perimeter. + /// 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 networkSecurityPerimeterName, NetworkSecurityPerimeterData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NetworkSecurityPerimeterData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes a network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// 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 networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes a network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// 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 networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreatePatchRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreatePatchRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Patch Tags for a Network Security Perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// Parameter supplied to the network security perimeter. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> PatchAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreatePatchRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Patch Tags for a Network Security Perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// Parameter supplied to the network security perimeter. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Patch(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, NetworkSecurityPerimeterPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreatePatchRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterData.DeserializeNetworkSecurityPerimeterData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List all network security perimeters in a subscription. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List all network security perimeters in a subscription. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List network security perimeters in a resource group. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List network security perimeters in a resource group. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId, int? top, string skipToken) + { + 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); + return message; + } + + /// List all network security perimeters in a subscription. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// 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, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List all network security perimeters in a subscription. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// 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, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, int? top, string skipToken) + { + 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); + return message; + } + + /// List network security perimeters in a resource group. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List network security perimeters in a resource group. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NetworkSecurityPerimeterListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NetworkSecurityPerimeterListResult.DeserializeNetworkSecurityPerimeterListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesReconcileRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesReconcileRestOperations.cs new file mode 100644 index 000000000000..1bfe0691aa84 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesReconcileRestOperations.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspAccessRulesReconcileRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspAccessRulesReconcileRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspAccessRulesReconcileRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreatePostRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, BinaryData unknown) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreatePostRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, BinaryData unknown) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(unknown); +#else + using (JsonDocument document = JsonDocument.Parse(unknown)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Reconcile NSP access rules. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// Parameters for NSP access rule reconcile. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> PostAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var message = CreatePostRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName, unknown); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BinaryData value = default; + value = await BinaryData.FromStreamAsync(message.Response.ContentStream).ConfigureAwait(false); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Reconcile NSP access rules. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// Parameters for NSP access rule reconcile. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Post(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var message = CreatePostRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName, unknown); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BinaryData value = default; + value = BinaryData.FromStream(message.Response.ContentStream); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesRestOperations.cs new file mode 100644 index 000000000000..8833f3e0f417 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAccessRulesRestOperations.cs @@ -0,0 +1,583 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspAccessRulesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspAccessRulesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspAccessRulesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified NSP access rule by name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAccessRuleData.DeserializeNspAccessRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspAccessRuleData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP access rule by name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAccessRuleData.DeserializeNspAccessRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspAccessRuleData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, NspAccessRuleData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName, NspAccessRuleData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates a network access rule. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspAccessRuleData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAccessRuleData.DeserializeNspAccessRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates a network access rule. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// Parameters that hold the NspAccessRule resource to be created/updated. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, NspAccessRuleData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspAccessRuleData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAccessRuleData.DeserializeNspAccessRuleData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, string accessRuleName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules/", false); + uri.AppendPath(accessRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an NSP access rule. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP access rule. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The name of the NSP access rule. + /// 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 networkSecurityPerimeterName, string profileName, string accessRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNullOrEmpty(accessRuleName, nameof(accessRuleName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, accessRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendPath("/accessRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP access rules in the specified NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAccessRuleListResult.DeserializeNspAccessRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP access rules in the specified NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAccessRuleListResult.DeserializeNspAccessRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top, string skipToken) + { + 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); + return message; + } + + /// Lists the NSP access rules in the specified NSP profile. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAccessRuleListResult.DeserializeNspAccessRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP access rules in the specified NSP profile. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAccessRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAccessRuleListResult.DeserializeNspAccessRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationReconcileRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationReconcileRestOperations.cs new file mode 100644 index 000000000000..c7f1618aa06e --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationReconcileRestOperations.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspAssociationReconcileRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspAssociationReconcileRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspAssociationReconcileRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreatePostRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, BinaryData unknown) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreatePostRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, BinaryData unknown) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendPath("/reconcile", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(unknown); +#else + using (JsonDocument document = JsonDocument.Parse(unknown)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Reconcile NSP association. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP association. + /// Parameters for NSP association reconcile. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> PostAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var message = CreatePostRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName, unknown); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + BinaryData value = default; + value = await BinaryData.FromStreamAsync(message.Response.ContentStream).ConfigureAwait(false); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Reconcile NSP association. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP association. + /// Parameters for NSP association reconcile. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Post(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, BinaryData unknown, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(unknown, nameof(unknown)); + + using var message = CreatePostRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName, unknown); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + BinaryData value = default; + value = BinaryData.FromStream(message.Response.ContentStream); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationsRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationsRestOperations.cs new file mode 100644 index 000000000000..89369927555b --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspAssociationsRestOperations.cs @@ -0,0 +1,541 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspAssociationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspAssociationsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspAssociationsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, 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.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", 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; + } + + /// Gets the specified NSP association by name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP 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 networkSecurityPerimeterName, string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAssociationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAssociationData.DeserializeNspAssociationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspAssociationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP association by name. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP 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 networkSecurityPerimeterName, string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAssociationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAssociationData.DeserializeNspAssociationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspAssociationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, NspAssociationData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName, NspAssociationData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates a NSP resource association. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP association. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// 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 networkSecurityPerimeterName, string associationName, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates a NSP resource association. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP association. + /// Parameters that hold the NspAssociation resource to be created/updated. + /// 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 networkSecurityPerimeterName, string associationName, NspAssociationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", false); + uri.AppendPath(associationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string associationName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations/", 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; + } + + /// Deletes an NSP association resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP 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 networkSecurityPerimeterName, string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP association resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP 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 networkSecurityPerimeterName, string associationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(associationName, nameof(associationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, associationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/resourceAssociations", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP resource associations. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAssociationsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAssociationsListResult.DeserializeNspAssociationsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP resource associations. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAssociationsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAssociationsListResult.DeserializeNspAssociationsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + 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); + return message; + } + + /// Lists the NSP resource associations. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspAssociationsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspAssociationsListResult.DeserializeNspAssociationsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP resource associations. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspAssociationsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspAssociationsListResult.DeserializeNspAssociationsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinkReferencesRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinkReferencesRestOperations.cs new file mode 100644 index 000000000000..49f3cb274a15 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinkReferencesRestOperations.cs @@ -0,0 +1,439 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspLinkReferencesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspLinkReferencesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspLinkReferencesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkReferenceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences/", false); + uri.AppendPath(linkReferenceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkReferenceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences/", false); + uri.AppendPath(linkReferenceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified NSP linkReference resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP linkReference. + /// 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 networkSecurityPerimeterName, string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkReferenceData.DeserializeNspLinkReferenceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLinkReferenceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP linkReference resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP linkReference. + /// 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 networkSecurityPerimeterName, string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkReferenceData.DeserializeNspLinkReferenceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLinkReferenceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkReferenceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences/", false); + uri.AppendPath(linkReferenceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkReferenceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences/", false); + uri.AppendPath(linkReferenceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an NSP LinkReference resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP linkReference. + /// 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 networkSecurityPerimeterName, string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP LinkReference resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP linkReference. + /// 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 networkSecurityPerimeterName, string linkReferenceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkReferenceName, nameof(linkReferenceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkReferenceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/linkReferences", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkReferenceListResult.DeserializeNspLinkReferenceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkReferenceListResult.DeserializeNspLinkReferenceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + 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); + return message; + } + + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkReferenceListResult.DeserializeNspLinkReferenceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP LinkReference resources in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkReferenceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkReferenceListResult.DeserializeNspLinkReferenceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinksRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinksRestOperations.cs new file mode 100644 index 000000000000..ca19d5ee935c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLinksRestOperations.cs @@ -0,0 +1,549 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspLinksRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspLinksRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspLinksRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified NSP link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// 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 networkSecurityPerimeterName, string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkData.DeserializeNspLinkData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLinkData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// 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 networkSecurityPerimeterName, string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkData.DeserializeNspLinkData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLinkData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName, NspLinkData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName, NspLinkData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates NSP link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// Parameters that hold the NspLink resource to be created/updated. + /// 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 networkSecurityPerimeterName, string linkName, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspLinkData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkData.DeserializeNspLinkData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates NSP link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// Parameters that hold the NspLink resource to be created/updated. + /// 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 networkSecurityPerimeterName, string linkName, NspLinkData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspLinkData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkData.DeserializeNspLinkData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string linkName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links/", false); + uri.AppendPath(linkName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an NSP Link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// 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 networkSecurityPerimeterName, string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP Link resource. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP link. + /// 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 networkSecurityPerimeterName, string linkName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(linkName, nameof(linkName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, linkName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/links", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP Link resources in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkListResult.DeserializeNspLinkListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP Link resources in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkListResult.DeserializeNspLinkListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + 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); + return message; + } + + /// Lists the NSP Link resources in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLinkListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLinkListResult.DeserializeNspLinkListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP Link resources in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLinkListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLinkListResult.DeserializeNspLinkListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationRestOperations.cs new file mode 100644 index 000000000000..295d69505b6d --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationRestOperations.cs @@ -0,0 +1,344 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspLoggingConfigurationRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspLoggingConfigurationRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspLoggingConfigurationRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLoggingConfigurationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspLoggingConfigurationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName, NspLoggingConfigurationData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName, NspLoggingConfigurationData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspLoggingConfigurationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// Parameters that hold the NspLoggingConfiguration to be created/updated. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, NspLoggingConfigurationData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspLoggingConfigurationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLoggingConfigurationData.DeserializeNspLoggingConfigurationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string loggingConfigurationName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations/", false); + uri.AppendPath(loggingConfigurationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an NSP Logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP Logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP logging configuration. Accepts 'instance' as name. + /// 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 networkSecurityPerimeterName, string loggingConfigurationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(loggingConfigurationName, nameof(loggingConfigurationName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, loggingConfigurationName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationsRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationsRestOperations.cs new file mode 100644 index 000000000000..53d348cfec16 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspLoggingConfigurationsRestOperations.cs @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspLoggingConfigurationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspLoggingConfigurationsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspLoggingConfigurationsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/loggingConfigurations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLoggingConfigurationListResult.DeserializeNspLoggingConfigurationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP logging configuration. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLoggingConfigurationListResult.DeserializeNspLoggingConfigurationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName) + { + 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); + return message; + } + + /// Lists the NSP logging configuration. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspLoggingConfigurationListResult.DeserializeNspLoggingConfigurationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP logging configuration. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspLoggingConfigurationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspLoggingConfigurationListResult.DeserializeNspLoggingConfigurationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspOperationStatusRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspOperationStatusRestOperations.cs new file mode 100644 index 000000000000..2a50a9a6287c --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspOperationStatusRestOperations.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspOperationStatusRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspOperationStatusRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspOperationStatusRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, AzureLocation location, string operationId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/networkSecurityPerimeterOperationStatuses/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, AzureLocation location, string operationId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/networkSecurityPerimeterOperationStatuses/", false); + uri.AppendPath(operationId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the operation status for the given operation id. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The operation id of the async operation. + /// 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, AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var message = CreateGetRequest(subscriptionId, location, operationId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationStatusResultData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationStatusResultData.DeserializeOperationStatusResultData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((OperationStatusResultData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the operation status for the given operation id. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The operation id of the async operation. + /// 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, AzureLocation location, string operationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(operationId, nameof(operationId)); + + using var message = CreateGetRequest(subscriptionId, location, operationId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationStatusResultData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationStatusResultData.DeserializeOperationStatusResultData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((OperationStatusResultData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspProfilesRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspProfilesRestOperations.cs new file mode 100644 index 000000000000..22462f89f9be --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/NspProfilesRestOperations.cs @@ -0,0 +1,547 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class NspProfilesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NspProfilesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public NspProfilesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the specified NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspProfileData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspProfileData.DeserializeNspProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspProfileData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the specified NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspProfileData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspProfileData.DeserializeNspProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NspProfileData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, NspProfileData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName, NspProfileData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates or updates a network profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// Parameters that hold the NspProfile resource to be created/updated. + /// 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 networkSecurityPerimeterName, string profileName, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspProfileData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspProfileData.DeserializeNspProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates or updates a network profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// Parameters that hold the NspProfile resource to be created/updated. + /// 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 networkSecurityPerimeterName, string profileName, NspProfileData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NspProfileData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspProfileData.DeserializeNspProfileData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, string profileName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles/", false); + uri.AppendPath(profileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// 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 networkSecurityPerimeterName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an NSP profile. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// The name of the NSP profile. + /// 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 networkSecurityPerimeterName, string profileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, profileName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Network/networkSecurityPerimeters/", false); + uri.AppendPath(networkSecurityPerimeterName, true); + uri.AppendPath("/profiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the NSP profiles in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspProfileListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspProfileListResult.DeserializeNspProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP profiles in the specified network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspProfileListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspProfileListResult.DeserializeNspProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top, string skipToken) + { + 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); + return message; + } + + /// Lists the NSP profiles in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NspProfileListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = NspProfileListResult.DeserializeNspProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the NSP profiles in the specified network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the network security perimeter. + /// An optional query parameter which specifies the maximum number of records to be returned by the server. + /// SkipToken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skipToken parameter that specifies a starting point to use for subsequent calls. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string networkSecurityPerimeterName, int? top = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(networkSecurityPerimeterName, nameof(networkSecurityPerimeterName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, networkSecurityPerimeterName, top, skipToken); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NspProfileListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = NspProfileListResult.DeserializeNspProfileListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/PerimeterAssociableResourceTypesRestOperations.cs b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/PerimeterAssociableResourceTypesRestOperations.cs new file mode 100644 index 000000000000..21309945fa20 --- /dev/null +++ b/sdk/network/Azure.ResourceManager.Network/src/Generated/RestOperations/PerimeterAssociableResourceTypesRestOperations.cs @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Network.Models; + +namespace Azure.ResourceManager.Network +{ + internal partial class PerimeterAssociableResourceTypesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of PerimeterAssociableResourceTypesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public PerimeterAssociableResourceTypesRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-07-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, AzureLocation location) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/perimeterAssociableResourceTypes", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, AzureLocation location) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Network/locations/", false); + uri.AppendPath(location, true); + uri.AppendPath("/perimeterAssociableResourceTypes", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId, location); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PerimeterAssociableResourcesListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PerimeterAssociableResourcesListResult.DeserializePerimeterAssociableResourcesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId, location); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PerimeterAssociableResourcesListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PerimeterAssociableResourcesListResult.DeserializePerimeterAssociableResourcesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, AzureLocation location) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, AzureLocation location) + { + 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); + return message; + } + + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PerimeterAssociableResourcesListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PerimeterAssociableResourcesListResult.DeserializePerimeterAssociableResourcesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the list of resources that are onboarded with NSP. These resources can be associated with a network security perimeter. + /// The URL to the next page of results. + /// The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The location of network security perimeter. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, AzureLocation location, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, location); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PerimeterAssociableResourcesListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PerimeterAssociableResourcesListResult.DeserializePerimeterAssociableResourcesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/network/Azure.ResourceManager.Network/src/autorest.md b/sdk/network/Azure.ResourceManager.Network/src/autorest.md index 4f7433c20830..5e3d66eb7003 100644 --- a/sdk/network/Azure.ResourceManager.Network/src/autorest.md +++ b/sdk/network/Azure.ResourceManager.Network/src/autorest.md @@ -7,7 +7,7 @@ Run `dotnet build /t:GenerateCode` to generate code. azure-arm: true library-name: Network namespace: Azure.ResourceManager.Network -require: https://github.com/Azure/azure-rest-api-specs/blob/5dc3201e0fd56e77cd54d8f79867af4d3f57a51b/specification/network/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/network/resource-manager/readme.md # tag: package-2024-05 output-folder: $(this-folder)/Generated clear-output-folder: true diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index d8bf790b5988..f28c28a5d39c 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -79,7 +79,6 @@ trigger: - sdk/dnsresolver/Azure.ResourceManager.DnsResolver - sdk/dynatrace/Azure.ResourceManager.Dynatrace - sdk/edgeorder/Azure.ResourceManager.EdgeOrder - - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/edgezones/Azure.ResourceManager.EdgeZones - sdk/elastic/Azure.ResourceManager.Elastic - sdk/elasticsan/Azure.ResourceManager.ElasticSan @@ -108,6 +107,7 @@ trigger: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto @@ -285,7 +285,6 @@ pr: - sdk/dnsresolver/Azure.ResourceManager.DnsResolver - sdk/dynatrace/Azure.ResourceManager.Dynatrace - sdk/edgeorder/Azure.ResourceManager.EdgeOrder - - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/edgezones/Azure.ResourceManager.EdgeZones - sdk/elastic/Azure.ResourceManager.Elastic - sdk/elasticsan/Azure.ResourceManager.ElasticSan @@ -314,6 +313,7 @@ pr: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto