From 73eadf4e51ec61229e95a4ceaca6065d61f6ac51 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 25 Feb 2025 09:54:12 +0000 Subject: [PATCH] CodeGen from PR 32809 in Azure/azure-rest-api-specs Merge 0d5a2a350336235ffe81df5eb1573303602c7545 into 745faf8a3f271f7bdf7aa3982433ba6e67f51f7c --- sdk/resourcemanager/ci.mgmt.yml | 6 +- .../Azure.ResourceManager.SiteManager.sln | 54 ++ .../CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../README.md | 80 +++ ...zure.ResourceManager.SiteManager.net8.0.cs | 185 ++++++ ...ourceManager.SiteManager.netstandard2.0.cs | 185 ++++++ .../assets.json | 7 + ...ResourceManager.SiteManager.Samples.csproj | 13 + .../Azure.ResourceManager.SiteManager.csproj | 8 + .../Generated/ArmSiteManagerModelFactory.cs | 48 ++ .../MockableSiteManagerArmClient.cs | 61 ++ ...ockableSiteManagerResourceGroupResource.cs | 105 ++++ ...MockableSiteManagerSubscriptionResource.cs | 105 ++++ .../Extensions/SiteManagerExtensions.cs | 259 ++++++++ .../src/Generated/Internal/Argument.cs | 129 ++++ .../Internal/ChangeTrackingDictionary.cs | 167 +++++ .../Generated/Internal/ChangeTrackingList.cs | 153 +++++ .../Internal/ModelSerializationExtensions.cs | 398 ++++++++++++ .../src/Generated/Internal/Optional.cs | 51 ++ .../Internal/Utf8JsonRequestContent.cs | 55 ++ .../ResourceGroupSiteOperationSource.cs | 38 ++ .../SiteManagerArmOperation.cs | 94 +++ .../SiteManagerArmOperationOfT.cs | 100 +++ .../SubscriptionSiteOperationSource.cs | 38 ++ .../Models/ResourceProvisioningState.cs | 54 ++ .../Models/SiteListResult.Serialization.cs | 151 +++++ .../src/Generated/Models/SiteListResult.cs | 80 +++ .../Models/SiteProperties.Serialization.cs | 170 ++++++ .../src/Generated/Models/SiteProperties.cs | 78 +++ .../Models/SiteUpdate.Serialization.cs | 133 ++++ .../src/Generated/Models/SiteUpdate.cs | 65 ++ .../SiteUpdateProperties.Serialization.cs | 155 +++++ .../Generated/Models/SiteUpdateProperties.cs | 74 +++ .../src/Generated/ProviderConstants.cs | 16 + .../Generated/ResourceGroupSiteCollection.cs | 494 +++++++++++++++ ...ResourceGroupSiteResource.Serialization.cs | 26 + .../Generated/ResourceGroupSiteResource.cs | 344 +++++++++++ .../SitesBySubscriptionRestOperations.cs | 533 ++++++++++++++++ .../RestOperations/SitesRestOperations.cs | 577 ++++++++++++++++++ .../src/Generated/SiteData.Serialization.cs | 155 +++++ .../src/Generated/SiteData.cs | 75 +++ .../Generated/SubscriptionSiteCollection.cs | 494 +++++++++++++++ .../SubscriptionSiteResource.Serialization.cs | 26 + .../src/Generated/SubscriptionSiteResource.cs | 343 +++++++++++ .../src/Properties/AssemblyInfo.cs | 11 + .../tsp-location.yaml | 4 + sdk/sitemanager/ci.mgmt.yml | 26 + 48 files changed, 6438 insertions(+), 2 deletions(-) create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/Azure.ResourceManager.SiteManager.sln create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/CHANGELOG.md create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/Directory.Build.props create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/README.md create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.net8.0.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.netstandard2.0.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/assets.json create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Azure.ResourceManager.SiteManager.Samples.csproj create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Azure.ResourceManager.SiteManager.csproj create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupSiteOperationSource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionSiteOperationSource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/ResourceProvisioningState.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteCollection.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteCollection.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.Serialization.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Properties/AssemblyInfo.cs create mode 100644 sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml create mode 100644 sdk/sitemanager/ci.mgmt.yml diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index d8bf790b5988..315551cd133c 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 @@ -181,6 +181,7 @@ trigger: - sdk/servicelinker/Azure.ResourceManager.ServiceLinker - sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking - sdk/signalr/Azure.ResourceManager.SignalR + - sdk/sitemanager/Azure.ResourceManager.SiteManager - sdk/sphere/Azure.ResourceManager.Sphere - sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery - sdk/sqlmanagement/Azure.ResourceManager.Sql @@ -285,7 +286,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 +314,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 @@ -387,6 +388,7 @@ pr: - sdk/servicelinker/Azure.ResourceManager.ServiceLinker - sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking - sdk/signalr/Azure.ResourceManager.SignalR + - sdk/sitemanager/Azure.ResourceManager.SiteManager - sdk/sphere/Azure.ResourceManager.Sphere - sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery - sdk/sqlmanagement/Azure.ResourceManager.Sql diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/Azure.ResourceManager.SiteManager.sln b/sdk/sitemanager/Azure.ResourceManager.SiteManager/Azure.ResourceManager.SiteManager.sln new file mode 100644 index 000000000000..3e41f05eca9c --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/Azure.ResourceManager.SiteManager.sln @@ -0,0 +1,54 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.SiteManager.Samples", "samples\Azure.ResourceManager.SiteManager.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.SiteManager", "src\Azure.ResourceManager.SiteManager.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/CHANGELOG.md b/sdk/sitemanager/Azure.ResourceManager.SiteManager/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/Directory.Build.props b/sdk/sitemanager/Azure.ResourceManager.SiteManager/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/README.md b/sdk/sitemanager/Azure.ResourceManager.SiteManager/README.md new file mode 100644 index 000000000000..c2f1cb55a1f5 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure SiteManager management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure SiteManager management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.SiteManager --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.net8.0.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.net8.0.cs new file mode 100644 index 000000000000..d391e0ac9db6 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.net8.0.cs @@ -0,0 +1,185 @@ +namespace Azure.ResourceManager.SiteManager +{ + public partial class ResourceGroupSiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ResourceGroupSiteCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ResourceGroupSiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ResourceGroupSiteResource() { } + public virtual Azure.ResourceManager.SiteManager.SiteData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string siteName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.Response Update(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SiteData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteData() { } + public Azure.ResourceManager.SiteManager.Models.SiteProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class SiteManagerExtensions + { + public static Azure.Response GetResourceGroupSite(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetResourceGroupSiteAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.ResourceGroupSiteResource GetResourceGroupSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.ResourceGroupSiteCollection GetResourceGroupSites(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Response GetSubscriptionSite(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSubscriptionSiteAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.SubscriptionSiteResource GetSubscriptionSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.SubscriptionSiteCollection GetSubscriptionSites(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } + } + public partial class SubscriptionSiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SubscriptionSiteCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class SubscriptionSiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SubscriptionSiteResource() { } + public virtual Azure.ResourceManager.SiteManager.SiteData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string siteName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.Response Update(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.SiteManager.Mocking +{ + public partial class MockableSiteManagerArmClient : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerArmClient() { } + public virtual Azure.ResourceManager.SiteManager.ResourceGroupSiteResource GetResourceGroupSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SubscriptionSiteResource GetSubscriptionSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableSiteManagerResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerResourceGroupResource() { } + public virtual Azure.Response GetResourceGroupSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetResourceGroupSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.ResourceGroupSiteCollection GetResourceGroupSites() { throw null; } + } + public partial class MockableSiteManagerSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerSubscriptionResource() { } + public virtual Azure.Response GetSubscriptionSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSubscriptionSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SubscriptionSiteCollection GetSubscriptionSites() { throw null; } + } +} +namespace Azure.ResourceManager.SiteManager.Models +{ + public static partial class ArmSiteManagerModelFactory + { + public static Azure.ResourceManager.SiteManager.SiteData SiteData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.SiteManager.Models.SiteProperties properties = null) { throw null; } + public static Azure.ResourceManager.SiteManager.Models.SiteProperties SiteProperties(string displayName = null, string description = null, Azure.Core.ResourceIdentifier addressResourceId = null, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState?)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState left, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState left, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SiteProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteProperties() { } + public Azure.Core.ResourceIdentifier AddressResourceId { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SiteUpdate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteUpdate() { } + public Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties Properties { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SiteUpdateProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteUpdateProperties() { } + public Azure.Core.ResourceIdentifier AddressResourceId { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.netstandard2.0.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.netstandard2.0.cs new file mode 100644 index 000000000000..d391e0ac9db6 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.netstandard2.0.cs @@ -0,0 +1,185 @@ +namespace Azure.ResourceManager.SiteManager +{ + public partial class ResourceGroupSiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ResourceGroupSiteCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class ResourceGroupSiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ResourceGroupSiteResource() { } + public virtual Azure.ResourceManager.SiteManager.SiteData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string siteName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.Response Update(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SiteData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteData() { } + public Azure.ResourceManager.SiteManager.Models.SiteProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class SiteManagerExtensions + { + public static Azure.Response GetResourceGroupSite(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetResourceGroupSiteAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.ResourceGroupSiteResource GetResourceGroupSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.ResourceGroupSiteCollection GetResourceGroupSites(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Response GetSubscriptionSite(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSubscriptionSiteAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.SubscriptionSiteResource GetSubscriptionSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.SubscriptionSiteCollection GetSubscriptionSites(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource) { throw null; } + } + public partial class SubscriptionSiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SubscriptionSiteCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class SubscriptionSiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SubscriptionSiteResource() { } + public virtual Azure.ResourceManager.SiteManager.SiteData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string siteName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.SiteData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.Response Update(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.SiteManager.Mocking +{ + public partial class MockableSiteManagerArmClient : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerArmClient() { } + public virtual Azure.ResourceManager.SiteManager.ResourceGroupSiteResource GetResourceGroupSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SubscriptionSiteResource GetSubscriptionSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableSiteManagerResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerResourceGroupResource() { } + public virtual Azure.Response GetResourceGroupSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetResourceGroupSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.ResourceGroupSiteCollection GetResourceGroupSites() { throw null; } + } + public partial class MockableSiteManagerSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerSubscriptionResource() { } + public virtual Azure.Response GetSubscriptionSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSubscriptionSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SubscriptionSiteCollection GetSubscriptionSites() { throw null; } + } +} +namespace Azure.ResourceManager.SiteManager.Models +{ + public static partial class ArmSiteManagerModelFactory + { + public static Azure.ResourceManager.SiteManager.SiteData SiteData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.SiteManager.Models.SiteProperties properties = null) { throw null; } + public static Azure.ResourceManager.SiteManager.Models.SiteProperties SiteProperties(string displayName = null, string description = null, Azure.Core.ResourceIdentifier addressResourceId = null, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState?)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState left, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState left, Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SiteProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteProperties() { } + public Azure.Core.ResourceIdentifier AddressResourceId { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SiteUpdate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteUpdate() { } + public Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties Properties { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SiteUpdateProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteUpdateProperties() { } + public Azure.Core.ResourceIdentifier AddressResourceId { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/assets.json b/sdk/sitemanager/Azure.ResourceManager.SiteManager/assets.json new file mode 100644 index 000000000000..fd8ce0868cf6 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/sitemanager/Azure.ResourceManager.SiteManager", + "Tag": "" +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Azure.ResourceManager.SiteManager.Samples.csproj b/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Azure.ResourceManager.SiteManager.Samples.csproj new file mode 100644 index 000000000000..ca7b4ed2fcd2 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Azure.ResourceManager.SiteManager.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Azure.ResourceManager.SiteManager.csproj b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Azure.ResourceManager.SiteManager.csproj new file mode 100644 index 000000000000..c8beaaf346a9 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Azure.ResourceManager.SiteManager.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider SiteManager. + 1.0.0-beta.1 + azure;management;arm;resource manager;sitemanager + Azure.ResourceManager.SiteManager + + diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs new file mode 100644 index 000000000000..4c3fd7407380 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.SiteManager.Models +{ + /// Model factory for models. + public static partial class ArmSiteManagerModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static SiteData SiteData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, SiteProperties properties = null) + { + return new SiteData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// displayName of Site resource. + /// Description of Site resource. + /// AddressResource ArmId of Site resource. + /// Provisioning state of last operation. + /// A new instance for mocking. + public static SiteProperties SiteProperties(string displayName = null, string description = null, ResourceIdentifier addressResourceId = null, ResourceProvisioningState? provisioningState = null) + { + return new SiteProperties(displayName, description, addressResourceId, provisioningState, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs new file mode 100644 index 000000000000..95b0363ade7a --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableSiteManagerArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableSiteManagerArmClient() + { + } + + /// 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 MockableSiteManagerArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableSiteManagerArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual ResourceGroupSiteResource GetResourceGroupSiteResource(ResourceIdentifier id) + { + ResourceGroupSiteResource.ValidateResourceId(id); + return new ResourceGroupSiteResource(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 SubscriptionSiteResource GetSubscriptionSiteResource(ResourceIdentifier id) + { + SubscriptionSiteResource.ValidateResourceId(id); + return new SubscriptionSiteResource(Client, id); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs new file mode 100644 index 000000000000..6d5f8ea54c99 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerResourceGroupResource.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableSiteManagerResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableSiteManagerResourceGroupResource() + { + } + + /// 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 MockableSiteManagerResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of ResourceGroupSiteResources in the ResourceGroupResource. + /// An object representing collection of ResourceGroupSiteResources and their operations over a ResourceGroupSiteResource. + public virtual ResourceGroupSiteCollection GetResourceGroupSites() + { + return GetCachedClient(client => new ResourceGroupSiteCollection(client, Id)); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetResourceGroupSiteAsync(string siteName, CancellationToken cancellationToken = default) + { + return await GetResourceGroupSites().GetAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetResourceGroupSite(string siteName, CancellationToken cancellationToken = default) + { + return GetResourceGroupSites().Get(siteName, cancellationToken); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs new file mode 100644 index 000000000000..9c3d22dc5900 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableSiteManagerSubscriptionResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableSiteManagerSubscriptionResource() + { + } + + /// 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 MockableSiteManagerSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of SubscriptionSiteResources in the SubscriptionResource. + /// An object representing collection of SubscriptionSiteResources and their operations over a SubscriptionSiteResource. + public virtual SubscriptionSiteCollection GetSubscriptionSites() + { + return GetCachedClient(client => new SubscriptionSiteCollection(client, Id)); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetSubscriptionSiteAsync(string siteName, CancellationToken cancellationToken = default) + { + return await GetSubscriptionSites().GetAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetSubscriptionSite(string siteName, CancellationToken cancellationToken = default) + { + return GetSubscriptionSites().Get(siteName, cancellationToken); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs new file mode 100644 index 000000000000..1fccc8c49cac --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs @@ -0,0 +1,259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager.Mocking; + +namespace Azure.ResourceManager.SiteManager +{ + /// A class to add extension methods to Azure.ResourceManager.SiteManager. + public static partial class SiteManagerExtensions + { + private static MockableSiteManagerArmClient GetMockableSiteManagerArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableSiteManagerArmClient(client0)); + } + + private static MockableSiteManagerResourceGroupResource GetMockableSiteManagerResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableSiteManagerResourceGroupResource(client, resource.Id)); + } + + private static MockableSiteManagerSubscriptionResource GetMockableSiteManagerSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableSiteManagerSubscriptionResource(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 ResourceGroupSiteResource GetResourceGroupSiteResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableSiteManagerArmClient(client).GetResourceGroupSiteResource(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 SubscriptionSiteResource GetSubscriptionSiteResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableSiteManagerArmClient(client).GetSubscriptionSiteResource(id); + } + + /// + /// Gets a collection of ResourceGroupSiteResources 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 ResourceGroupSiteResources and their operations over a ResourceGroupSiteResource. + public static ResourceGroupSiteCollection GetResourceGroupSites(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupSites(); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetResourceGroupSiteAsync(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupSiteAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetResourceGroupSite(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetResourceGroupSite(siteName, cancellationToken); + } + + /// + /// Gets a collection of SubscriptionSiteResources 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 SubscriptionSiteResources and their operations over a SubscriptionSiteResource. + public static SubscriptionSiteCollection GetSubscriptionSites(this SubscriptionResource subscriptionResource) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionSites(); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetSubscriptionSiteAsync(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionSiteAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetSubscriptionSite(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSubscriptionSite(siteName, cancellationToken); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..a33cae7b9b4a --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.SiteManager +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..d1195c913a7f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.SiteManager +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..d7c37dce15ea --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// 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.Linq; + +namespace Azure.ResourceManager.SiteManager +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..c8b89b2ca0d7 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// 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.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..eeaa7c102d82 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.SiteManager +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..5c17e9380373 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupSiteOperationSource.cs new file mode 100644 index 000000000000..965388afa483 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/ResourceGroupSiteOperationSource.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.SiteManager +{ + internal class ResourceGroupSiteOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ResourceGroupSiteOperationSource(ArmClient client) + { + _client = client; + } + + ResourceGroupSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = SiteData.DeserializeSiteData(document.RootElement); + return new ResourceGroupSiteResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = SiteData.DeserializeSiteData(document.RootElement); + return new ResourceGroupSiteResource(_client, data); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs new file mode 100644 index 000000000000..2cd25b7e0d02 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs @@ -0,0 +1,94 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SiteManager +{ +#pragma warning disable SA1649 // File name should match first type name + internal class SiteManagerArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of SiteManagerArmOperation for mocking. + protected SiteManagerArmOperation() + { + } + + internal SiteManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal SiteManagerArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "SiteManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs new file mode 100644 index 000000000000..fc904280a722 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperationOfT.cs @@ -0,0 +1,100 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SiteManager +{ +#pragma warning disable SA1649 // File name should match first type name + internal class SiteManagerArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of SiteManagerArmOperation for mocking. + protected SiteManagerArmOperation() + { + } + + internal SiteManagerArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal SiteManagerArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "SiteManagerArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionSiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionSiteOperationSource.cs new file mode 100644 index 000000000000..c7f8a93e914f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SubscriptionSiteOperationSource.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.SiteManager +{ + internal class SubscriptionSiteOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal SubscriptionSiteOperationSource(ArmClient client) + { + _client = client; + } + + SubscriptionSiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = SiteData.DeserializeSiteData(document.RootElement); + return new SubscriptionSiteResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = SiteData.DeserializeSiteData(document.RootElement); + return new SubscriptionSiteResource(_client, data); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/ResourceProvisioningState.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/ResourceProvisioningState.cs new file mode 100644 index 000000000000..e99e5b7d2b63 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/ResourceProvisioningState.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.SiteManager.Models +{ + /// The provisioning state of a resource type. + public readonly partial struct ResourceProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// Resource has been created. + public static ResourceProvisioningState Succeeded { get; } = new ResourceProvisioningState(SucceededValue); + /// Resource creation failed. + public static ResourceProvisioningState Failed { get; } = new ResourceProvisioningState(FailedValue); + /// Resource creation was canceled. + public static ResourceProvisioningState Canceled { get; } = new ResourceProvisioningState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceProvisioningState left, ResourceProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceProvisioningState left, ResourceProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResourceProvisioningState(string value) => new ResourceProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceProvisioningState other && Equals(other); + /// + public bool Equals(ResourceProvisioningState 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/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs new file mode 100644 index 000000000000..5eaa2d7616d9 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.SiteManager.Models +{ + internal partial class SiteListResult : 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(SiteListResult)} does not support writing '{format}' format."); + } + + 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.AbsoluteUri); + } + 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 + } + } + } + + SiteListResult 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(SiteListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteListResult(document.RootElement, options); + } + + internal static SiteListResult DeserializeSiteListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SiteData.DeserializeSiteData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteListResult(value, 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(SiteListResult)} does not support writing '{options.Format}' format."); + } + } + + SiteListResult 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 DeserializeSiteListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs new file mode 100644 index 000000000000..cdd5ac29edcd --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.SiteManager.Models +{ + /// The response of a Site list operation. + internal partial class SiteListResult + { + /// + /// 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 Site items on this page. + /// is null. + internal SiteListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Site items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal SiteListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SiteListResult() + { + } + + /// The Site items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.Serialization.cs new file mode 100644 index 000000000000..27fcbd284cef --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.Serialization.cs @@ -0,0 +1,170 @@ +// 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.SiteManager.Models +{ + public partial class SiteProperties : 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(SiteProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(AddressResourceId)) + { + writer.WritePropertyName("addressResourceId"u8); + writer.WriteStringValue(AddressResourceId); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + 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 + } + } + } + + SiteProperties 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(SiteProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteProperties(document.RootElement, options); + } + + internal static SiteProperties DeserializeSiteProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + string description = default; + ResourceIdentifier addressResourceId = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("addressResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + addressResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteProperties(displayName, description, addressResourceId, provisioningState, 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(SiteProperties)} does not support writing '{options.Format}' format."); + } + } + + SiteProperties 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 DeserializeSiteProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.cs new file mode 100644 index 000000000000..744e4baf8923 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager.Models +{ + /// Site properties. + public partial class SiteProperties + { + /// + /// 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 SiteProperties() + { + } + + /// Initializes a new instance of . + /// displayName of Site resource. + /// Description of Site resource. + /// AddressResource ArmId of Site resource. + /// Provisioning state of last operation. + /// Keeps track of any properties unknown to the library. + internal SiteProperties(string displayName, string description, ResourceIdentifier addressResourceId, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + Description = description; + AddressResourceId = addressResourceId; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// displayName of Site resource. + public string DisplayName { get; set; } + /// Description of Site resource. + public string Description { get; set; } + /// AddressResource ArmId of Site resource. + public ResourceIdentifier AddressResourceId { get; set; } + /// Provisioning state of last operation. + public ResourceProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.Serialization.cs new file mode 100644 index 000000000000..24c114e6a2b5 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.Serialization.cs @@ -0,0 +1,133 @@ +// 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.SiteManager.Models +{ + public partial class SiteUpdate : 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(SiteUpdate)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + 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 + } + } + } + + SiteUpdate 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(SiteUpdate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteUpdate(document.RootElement, options); + } + + internal static SiteUpdate DeserializeSiteUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SiteUpdateProperties properties = 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 = SiteUpdateProperties.DeserializeSiteUpdateProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteUpdate(properties, 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(SiteUpdate)} does not support writing '{options.Format}' format."); + } + } + + SiteUpdate 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 DeserializeSiteUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.cs new file mode 100644 index 000000000000..ed66baac9fcb --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdate.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.SiteManager.Models +{ + /// The type used for update operations of the Site. + public partial class SiteUpdate + { + /// + /// 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 SiteUpdate() + { + } + + /// Initializes a new instance of . + /// The updatable properties of the Site. + /// Keeps track of any properties unknown to the library. + internal SiteUpdate(SiteUpdateProperties properties, IDictionary serializedAdditionalRawData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The updatable properties of the Site. + public SiteUpdateProperties Properties { get; set; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.Serialization.cs new file mode 100644 index 000000000000..0d71b73bdf3e --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.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.SiteManager.Models +{ + public partial class SiteUpdateProperties : 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(SiteUpdateProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(AddressResourceId)) + { + writer.WritePropertyName("addressResourceId"u8); + writer.WriteStringValue(AddressResourceId); + } + 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 + } + } + } + + SiteUpdateProperties 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(SiteUpdateProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteUpdateProperties(document.RootElement, options); + } + + internal static SiteUpdateProperties DeserializeSiteUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + string description = default; + ResourceIdentifier addressResourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("addressResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + addressResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteUpdateProperties(displayName, description, addressResourceId, 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(SiteUpdateProperties)} does not support writing '{options.Format}' format."); + } + } + + SiteUpdateProperties 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 DeserializeSiteUpdateProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteUpdateProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.cs new file mode 100644 index 000000000000..a356c03675a9 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.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.SiteManager.Models +{ + /// The updatable properties of the Site. + public partial class SiteUpdateProperties + { + /// + /// 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 SiteUpdateProperties() + { + } + + /// Initializes a new instance of . + /// displayName of Site resource. + /// Description of Site resource. + /// AddressResource ArmId of Site resource. + /// Keeps track of any properties unknown to the library. + internal SiteUpdateProperties(string displayName, string description, ResourceIdentifier addressResourceId, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + Description = description; + AddressResourceId = addressResourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// displayName of Site resource. + public string DisplayName { get; set; } + /// Description of Site resource. + public string Description { get; set; } + /// AddressResource ArmId of Site resource. + public ResourceIdentifier AddressResourceId { get; set; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..ac5d9bb23fcf --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.SiteManager +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteCollection.cs new file mode 100644 index 000000000000..a548e85411f8 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteCollection.cs @@ -0,0 +1,494 @@ +// 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.SiteManager +{ + /// + /// 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 GetResourceGroupSites method from an instance of . + /// + public partial class ResourceGroupSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _resourceGroupSiteSitesClientDiagnostics; + private readonly SitesRestOperations _resourceGroupSiteSitesRestClient; + + /// Initializes a new instance of the class for mocking. + protected ResourceGroupSiteCollection() + { + } + + /// 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 ResourceGroupSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceGroupSiteSitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceGroupSiteResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceGroupSiteResource.ResourceType, out string resourceGroupSiteSitesApiVersion); + _resourceGroupSiteSitesRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGroupSiteSitesApiVersion); +#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)); + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of Site resource. + /// Resource create parameters. + /// 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 siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken).ConfigureAwait(false); + var operation = new SiteManagerArmOperation(new ResourceGroupSiteOperationSource(Client), _resourceGroupSiteSitesClientDiagnostics, Pipeline, _resourceGroupSiteSitesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of Site resource. + /// Resource create parameters. + /// 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 siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken); + var operation = new SiteManagerArmOperation(new ResourceGroupSiteOperationSource(Client), _resourceGroupSiteSitesClientDiagnostics, Pipeline, _resourceGroupSiteSitesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.Get"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.Get"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Site resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// 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) => _resourceGroupSiteSitesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGroupSiteSitesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ResourceGroupSiteResource(Client, SiteData.DeserializeSiteData(e)), _resourceGroupSiteSitesClientDiagnostics, Pipeline, "ResourceGroupSiteCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Site resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// 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) => _resourceGroupSiteSitesRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _resourceGroupSiteSitesRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ResourceGroupSiteResource(Client, SiteData.DeserializeSiteData(e)), _resourceGroupSiteSitesClientDiagnostics, Pipeline, "ResourceGroupSiteCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.Exists"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, 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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.Exists"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, 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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(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/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.Serialization.cs new file mode 100644 index 000000000000..65f3282ddd71 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.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.SiteManager +{ + public partial class ResourceGroupSiteResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + SiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + SiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.cs new file mode 100644 index 000000000000..23f443292d04 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ResourceGroupSiteResource.cs @@ -0,0 +1,344 @@ +// 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; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// A Class representing a ResourceGroupSite 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 GetResourceGroupSiteResource method. + /// Otherwise you can get one from its parent resource using the GetResourceGroupSite method. + /// + public partial class ResourceGroupSiteResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The siteName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string siteName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _resourceGroupSiteSitesClientDiagnostics; + private readonly SitesRestOperations _resourceGroupSiteSitesRestClient; + private readonly SiteData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; + + /// Initializes a new instance of the class for mocking. + protected ResourceGroupSiteResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ResourceGroupSiteResource(ArmClient client, SiteData 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 ResourceGroupSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _resourceGroupSiteSitesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string resourceGroupSiteSitesApiVersion); + _resourceGroupSiteSitesRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, resourceGroupSiteSitesApiVersion); +#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 SiteData 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)); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Get"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Get"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Delete"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _resourceGroupSiteSitesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Delete"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var uri = _resourceGroupSiteSitesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Update"); + scope.Start(); + try + { + var response = await _resourceGroupSiteSitesRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, properties, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = _resourceGroupSiteSitesClientDiagnostics.CreateScope("ResourceGroupSiteResource.Update"); + scope.Start(); + try + { + var response = _resourceGroupSiteSitesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, properties, cancellationToken); + return Response.FromValue(new ResourceGroupSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs new file mode 100644 index 000000000000..1a2056e49c34 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs @@ -0,0 +1,533 @@ +// 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.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesBySubscriptionRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of SitesBySubscriptionRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public SitesBySubscriptionRestOperations(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-02-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Site resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Site resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string siteName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string siteName) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(subscriptionId, siteName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SiteData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(subscriptionId, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SiteData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string siteName, SiteData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string siteName, SiteData 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("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, 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; + } + + /// Create a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, siteName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, siteName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string siteName, SiteUpdate properties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string siteName, SiteUpdate properties) + { + 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("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, 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(properties, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> UpdateAsync(string subscriptionId, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(subscriptionId, siteName, properties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(subscriptionId, siteName, properties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string siteName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string siteName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(subscriptionId, siteName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Site. + /// The ID of the target subscription. The value must be an UUID. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(subscriptionId, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Site resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Site resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs new file mode 100644 index 000000000000..e5f2fa596ec3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesRestOperations.cs @@ -0,0 +1,577 @@ +// 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.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + internal partial class SitesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of SitesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public SitesRestOperations(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-02-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string siteName) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string siteName) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, siteName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SiteData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SiteData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string siteName, SiteData 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string siteName, SiteData 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.Edge/sites/", false); + uri.AppendPath(siteName, 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; + } + + /// Create a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, siteName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// Resource create parameters. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, siteName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string siteName, SiteUpdate properties) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string siteName, SiteUpdate properties) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, 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(properties, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> UpdateAsync(string subscriptionId, string resourceGroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, siteName, properties); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, siteName, properties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string siteName) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string siteName) + { + 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.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, siteName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Site. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Name of Site resource. + /// 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 siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Site resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Site resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Site resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Site resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.Serialization.cs new file mode 100644 index 000000000000..b08e219457bf --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.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; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + public partial class SiteData : 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(SiteData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + SiteData 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(SiteData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteData(document.RootElement, options); + } + + internal static SiteData DeserializeSiteData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SiteProperties properties = 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 = SiteProperties.DeserializeSiteProperties(property.Value, options); + 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 SiteData( + id, + name, + type, + systemData, + properties, + 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(SiteData)} does not support writing '{options.Format}' format."); + } + } + + SiteData 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 DeserializeSiteData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.cs new file mode 100644 index 000000000000..a8eeede0bd0c --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.cs @@ -0,0 +1,75 @@ +// 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.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// A class representing the Site data model. + /// Site as ARM Resource + /// + public partial class SiteData : 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 SiteData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal SiteData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SiteProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public SiteProperties Properties { get; set; } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteCollection.cs new file mode 100644 index 000000000000..ff0fafd47b88 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteCollection.cs @@ -0,0 +1,494 @@ +// 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.SiteManager +{ + /// + /// 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 GetSubscriptionSites method from an instance of . + /// + public partial class SubscriptionSiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _subscriptionSiteSitesBySubscriptionClientDiagnostics; + private readonly SitesBySubscriptionRestOperations _subscriptionSiteSitesBySubscriptionRestClient; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionSiteCollection() + { + } + + /// 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 SubscriptionSiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _subscriptionSiteSitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", SubscriptionSiteResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(SubscriptionSiteResource.ResourceType, out string subscriptionSiteSitesBySubscriptionApiVersion); + _subscriptionSiteSitesBySubscriptionRestClient = new SitesBySubscriptionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionSiteSitesBySubscriptionApiVersion); +#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)); + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of Site resource. + /// Resource create parameters. + /// 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 siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, siteName, data, cancellationToken).ConfigureAwait(false); + var operation = new SiteManagerArmOperation(new SubscriptionSiteOperationSource(Client), _subscriptionSiteSitesBySubscriptionClientDiagnostics, Pipeline, _subscriptionSiteSitesBySubscriptionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Name of Site resource. + /// Resource create parameters. + /// 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 siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.CreateOrUpdate(Id.SubscriptionId, siteName, data, cancellationToken); + var operation = new SiteManagerArmOperation(new SubscriptionSiteOperationSource(Client), _subscriptionSiteSitesBySubscriptionClientDiagnostics, Pipeline, _subscriptionSiteSitesBySubscriptionRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.Get"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.Get"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// 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) => _subscriptionSiteSitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionSiteSitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SubscriptionSiteResource(Client, SiteData.DeserializeSiteData(e)), _subscriptionSiteSitesBySubscriptionClientDiagnostics, Pipeline, "SubscriptionSiteCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// 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) => _subscriptionSiteSitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _subscriptionSiteSitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SubscriptionSiteResource(Client, SiteData.DeserializeSiteData(e)), _subscriptionSiteSitesBySubscriptionClientDiagnostics, Pipeline, "SubscriptionSiteCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.Exists"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, 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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.Exists"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, 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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(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.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(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/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.Serialization.cs new file mode 100644 index 000000000000..f7b859676a15 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.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.SiteManager +{ + public partial class SubscriptionSiteResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + SiteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + SiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.cs new file mode 100644 index 000000000000..a39f0d085580 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SubscriptionSiteResource.cs @@ -0,0 +1,343 @@ +// 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; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// A Class representing a SubscriptionSite 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 GetSubscriptionSiteResource method. + /// Otherwise you can get one from its parent resource using the GetSubscriptionSite method. + /// + public partial class SubscriptionSiteResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The siteName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string siteName) + { + var resourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _subscriptionSiteSitesBySubscriptionClientDiagnostics; + private readonly SitesBySubscriptionRestOperations _subscriptionSiteSitesBySubscriptionRestClient; + private readonly SiteData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Edge/sites"; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionSiteResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SubscriptionSiteResource(ArmClient client, SiteData 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 SubscriptionSiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _subscriptionSiteSitesBySubscriptionClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string subscriptionSiteSitesBySubscriptionApiVersion); + _subscriptionSiteSitesBySubscriptionRestClient = new SitesBySubscriptionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, subscriptionSiteSitesBySubscriptionApiVersion); +#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 SiteData 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)); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Get"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Get"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Get(Id.SubscriptionId, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Delete"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.DeleteAsync(Id.SubscriptionId, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _subscriptionSiteSitesBySubscriptionRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Delete"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Delete(Id.SubscriptionId, Id.Name, cancellationToken); + var uri = _subscriptionSiteSitesBySubscriptionRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new SiteManagerArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Update"); + scope.Start(); + try + { + var response = await _subscriptionSiteSitesBySubscriptionRestClient.UpdateAsync(Id.SubscriptionId, Id.Name, properties, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2024-02-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = _subscriptionSiteSitesBySubscriptionClientDiagnostics.CreateScope("SubscriptionSiteResource.Update"); + scope.Start(); + try + { + var response = _subscriptionSiteSitesBySubscriptionRestClient.Update(Id.SubscriptionId, Id.Name, properties, cancellationToken); + return Response.FromValue(new SubscriptionSiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Properties/AssemblyInfo.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..ae2291871033 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.ResourceManager.SiteManager.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("SiteManager")] diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml new file mode 100644 index 000000000000..9e9524084f6c --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/edge/Microsoft.Edge.Sites.Management +commit: 218bab65fbfd15c2e7a8940de2a3e787eb7bf858 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/sitemanager/ci.mgmt.yml b/sdk/sitemanager/ci.mgmt.yml new file mode 100644 index 000000000000..b64b81600c03 --- /dev/null +++ b/sdk/sitemanager/ci.mgmt.yml @@ -0,0 +1,26 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/sitemanager /ci.mgmt.yml + - sdk/sitemanager /Azure.ResourceManager.SiteManager / + + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: sitemanager + ArtifactName: packages + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.SiteManager + safeName: AzureResourceManagerSiteManager