diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ea7cc9035abc..6ee05e341a6d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1115,6 +1115,12 @@ # ServiceLabel: %Service Fabric # ServiceOwners: @QingChenmsft @vaishnavk @juhacket +# PRLabel: %SiteManager +/sdk/sitemanager/Azure.ResourceManager.*/ @bsomeshekar + +# ServiceLabel: %SiteManager %Mgmt +# ServiceOwners: @bsomeshekar + # PRLabel: %Spring App Discovery /sdk/springappdiscovery/Azure.ResourceManager.*/ @sunkun99 @ArcturusZhang @ArthurMa1978 @@ -1133,6 +1139,7 @@ # ServiceLabel: %Weights & Biases %Mgmt # ServiceOwners: @aggarwalsw + # ######## Eng Sys ######## /eng/ @hallipr @weshaggard @benbp /eng/common/ @Azure/azure-sdk-eng diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index 9ae0a7e75290..1cc42793477b 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -189,6 +189,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 @@ -405,6 +406,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..6afedab8de5d --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/Azure.ResourceManager.SiteManager.sln @@ -0,0 +1,65 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30309.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F903E55E-0FDE-4855-AC34-AFAC1F7FC419}") = "Azure.ResourceManager.SiteManager", "src\Azure.ResourceManager.SiteManager.csproj", "{0979AD14-7A51-4266-9CEA-3847B2C6BD5C}" +EndProject +Project("{F903E55E-0FDE-4855-AC34-AFAC1F7FC419}") = "Azure.ResourceManager.SiteManager.Tests", "tests\Azure.ResourceManager.SiteManager.Tests.csproj", "{39B18B76-C158-40EB-B1F7-95ED36BAC834}" +EndProject +Project("{F903E55E-0FDE-4855-AC34-AFAC1F7FC419}") = "Azure.ResourceManager.SiteManager.Samples", "samples\Azure.ResourceManager.SiteManager.Samples.csproj", "{87DBDED0-0F32-40C0-B899-3CC2451AB541}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DA55A19E-27FF-46F2-8063-96AA7F1A7B01} + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|x64.ActiveCfg = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|x64.Build.0 = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|x86.ActiveCfg = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Debug|x86.Build.0 = Debug|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|Any CPU.Build.0 = Release|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|x64.ActiveCfg = Release|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|x64.Build.0 = Release|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|x86.ActiveCfg = Release|Any CPU + {0979AD14-7A51-4266-9CEA-3847B2C6BD5C}.Release|x86.Build.0 = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|x64.ActiveCfg = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|x64.Build.0 = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|x86.ActiveCfg = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Debug|x86.Build.0 = Debug|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|Any CPU.Build.0 = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|x64.ActiveCfg = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|x64.Build.0 = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|x86.ActiveCfg = Release|Any CPU + {39B18B76-C158-40EB-B1F7-95ED36BAC834}.Release|x86.Build.0 = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|x64.ActiveCfg = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|x64.Build.0 = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|x86.ActiveCfg = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Debug|x86.Build.0 = Debug|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|Any CPU.Build.0 = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|x64.ActiveCfg = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|x64.Build.0 = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|x86.ActiveCfg = Release|Any CPU + {87DBDED0-0F32-40C0-B899-3CC2451AB541}.Release|x86.Build.0 = Release|Any CPU + 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..1a85987a15b9 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/CHANGELOG.md @@ -0,0 +1,19 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + + + +### Features Added + +This package 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. + +This package is a Public Preview version, so expect incompatible changes in subsequent releases as we improve the product. To provide feedback, submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues). + +> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet). \ 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..1a9611bd4924 --- /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..9b2f35517245 --- /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://docs.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..eaab09624fb3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.net8.0.cs @@ -0,0 +1,209 @@ +namespace Azure.ResourceManager.SiteManager +{ + public partial class AzureResourceManagerSiteManagerContext : System.ClientModel.Primitives.ModelReaderWriterContext + { + internal AzureResourceManagerSiteManagerContext() { } + public static Azure.ResourceManager.SiteManager.AzureResourceManagerSiteManagerContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } + } + public partial class SiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SiteCollection() { } + 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 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.ResourceManager.ArmOperation CreateOrUpdateSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateOrUpdateSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ArmOperation CreateOrUpdateSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateOrUpdateSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response DeleteSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task DeleteSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response DeleteSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task DeleteSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSite(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSiteAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.SiteResource GetSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.SiteCollection GetSites(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetSites(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetSites(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetSitesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetSitesAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response UpdateSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> UpdateSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response UpdateSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> UpdateSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SiteResource() { } + 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; } + } +} +namespace Azure.ResourceManager.SiteManager.Mocking +{ + public partial class MockableSiteManagerArmClient : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerArmClient() { } + public virtual Azure.ResourceManager.SiteManager.SiteResource GetSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableSiteManagerResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerResourceGroupResource() { } + public virtual Azure.Response GetSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SiteCollection GetSites() { throw null; } + } + public partial class MockableSiteManagerSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerSubscriptionResource() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdateSitesBySubscription(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> CreateOrUpdateSitesBySubscriptionAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DeleteSitesBySubscription(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteSitesBySubscriptionAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetSites(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetSitesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetSitesBySubscription(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSitesBySubscriptionAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateSitesBySubscription(string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateSitesBySubscriptionAsync(string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class MockableSiteManagerTenantResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerTenantResource() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdateSitesByServiceGroup(Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateSitesByServiceGroupAsync(Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DeleteSitesByServiceGroup(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteSitesByServiceGroupAsync(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetSites(string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetSitesAsync(string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetSitesByServiceGroup(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSitesByServiceGroupAsync(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateSitesByServiceGroup(string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateSitesByServiceGroupAsync(string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { 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.ResourceManager.SiteManager.Models.SiteAddressProperties siteAddress = null, System.Collections.Generic.IDictionary labels = 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 SiteAddressProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteAddressProperties() { } + public string City { get { throw null; } set { } } + public string Country { get { throw null; } set { } } + public string PostalCode { get { throw null; } set { } } + public string StateOrProvince { get { throw null; } set { } } + public string StreetAddress1 { get { throw null; } set { } } + public string StreetAddress2 { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteAddressProperties 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.SiteAddressProperties 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 SiteProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteProperties() { } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.SiteAddressProperties SiteAddress { get { throw null; } set { } } + 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 string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.SiteAddressProperties SiteAddress { 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..eaab09624fb3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/api/Azure.ResourceManager.SiteManager.netstandard2.0.cs @@ -0,0 +1,209 @@ +namespace Azure.ResourceManager.SiteManager +{ + public partial class AzureResourceManagerSiteManagerContext : System.ClientModel.Primitives.ModelReaderWriterContext + { + internal AzureResourceManagerSiteManagerContext() { } + public static Azure.ResourceManager.SiteManager.AzureResourceManagerSiteManagerContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } + } + public partial class SiteCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SiteCollection() { } + 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 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.ResourceManager.ArmOperation CreateOrUpdateSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateOrUpdateSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.ArmOperation CreateOrUpdateSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateOrUpdateSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response DeleteSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task DeleteSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response DeleteSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task DeleteSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSite(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSiteAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.SiteManager.SiteResource GetSiteResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.SiteManager.SiteCollection GetSites(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetSites(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Pageable GetSites(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetSitesAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetSitesAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response GetSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response UpdateSitesByServiceGroup(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> UpdateSitesByServiceGroupAsync(this Azure.ResourceManager.Resources.TenantResource tenantResource, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Response UpdateSitesBySubscription(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> UpdateSitesBySubscriptionAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SiteResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SiteResource() { } + 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; } + } +} +namespace Azure.ResourceManager.SiteManager.Mocking +{ + public partial class MockableSiteManagerArmClient : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerArmClient() { } + public virtual Azure.ResourceManager.SiteManager.SiteResource GetSiteResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableSiteManagerResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerResourceGroupResource() { } + public virtual Azure.Response GetSite(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSiteAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.SiteManager.SiteCollection GetSites() { throw null; } + } + public partial class MockableSiteManagerSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerSubscriptionResource() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdateSitesBySubscription(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> CreateOrUpdateSitesBySubscriptionAsync(Azure.WaitUntil waitUntil, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DeleteSitesBySubscription(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteSitesBySubscriptionAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetSites(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetSitesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetSitesBySubscription(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSitesBySubscriptionAsync(string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateSitesBySubscription(string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateSitesBySubscriptionAsync(string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class MockableSiteManagerTenantResource : Azure.ResourceManager.ArmResource + { + protected MockableSiteManagerTenantResource() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdateSitesByServiceGroup(Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateSitesByServiceGroupAsync(Azure.WaitUntil waitUntil, string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.SiteData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response DeleteSitesByServiceGroup(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteSitesByServiceGroupAsync(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetSites(string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetSitesAsync(string servicegroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetSitesByServiceGroup(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSitesByServiceGroupAsync(string servicegroupName, string siteName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response UpdateSitesByServiceGroup(string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateSitesByServiceGroupAsync(string servicegroupName, string siteName, Azure.ResourceManager.SiteManager.Models.SiteUpdate properties, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { 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.ResourceManager.SiteManager.Models.SiteAddressProperties siteAddress = null, System.Collections.Generic.IDictionary labels = 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 SiteAddressProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteAddressProperties() { } + public string City { get { throw null; } set { } } + public string Country { get { throw null; } set { } } + public string PostalCode { get { throw null; } set { } } + public string StateOrProvince { get { throw null; } set { } } + public string StreetAddress1 { get { throw null; } set { } } + public string StreetAddress2 { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.SiteManager.Models.SiteAddressProperties 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.SiteAddressProperties 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 SiteProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SiteProperties() { } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.SiteAddressProperties SiteAddress { get { throw null; } set { } } + 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 string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Labels { get { throw null; } } + public Azure.ResourceManager.SiteManager.Models.SiteAddressProperties SiteAddress { 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..0c5b0304514d --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/sitemanager/Azure.ResourceManager.SiteManager", + "Tag": "net/sitemanager/Azure.ResourceManager.SiteManager_0f34bc8fb9" +} 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..8807be9e8794 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Azure.ResourceManager.SiteManager.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Sample_SiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Sample_SiteResource.cs new file mode 100644 index 000000000000..51f8bc2d9634 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/samples/Sample_SiteResource.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.SiteManager.Samples +{ + public partial class Sample_SiteResource + { + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Create_Site() + { + // Get your Azure access token. For more details on how Azure SDK gets your access token, refer to: + // https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // Authenticate your client + ArmClient client = new ArmClient(cred); + + // Define the required parameters for creating a SiteResource + string subscriptionId = "f8a30ed0-310b-4f90-9435-d7e8a5cc0c91"; + string resourceGroupName = "test-rg"; + string siteName = "myNewSite"; + + // Get the parent resource (e.g., ResourceGroupResource or SiteCollection) + ResourceGroupResource resourceGroup = client.GetResourceGroupResource( + ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName)); + + // Create the SiteData object with required properties + SiteData siteData = new SiteData + { + Properties = new SiteProperties + { + DisplayName = "My New Site", + SiteAddress = new SiteAddressProperties + { + City = "Seattle", + Country = "USA" + } + } + }; + + // Use the parent resource to create the SiteResource + var lro = await resourceGroup.GetSites().CreateOrUpdateAsync(WaitUntil.Completed, siteName, siteData); + SiteResource site = lro.Value; + // The variable site is a resource. You could call other operations on this instance as well. + // For demo purposes, we get its data from this resource instance + SiteData resourceData = site.Data; + // For demo, we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_Site() + { + // Get your Azure access token. For more details on how Azure SDK gets your access token, refer to: + // https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // Authenticate your client + ArmClient client = new ArmClient(cred); + + // This example assumes you already have this SiteResource created on Azure + // For more information on creating SiteResource, refer to the documentation of SiteResource + string subscriptionId = "f8a30ed0-310b-4f90-9435-d7e8a5cc0c91"; + string resourceGroupName = "test-rg"; + string siteName = "mySite"; + ResourceIdentifier siteResourceId = SiteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName); + SiteResource site = client.GetSiteResource(siteResourceId); + + // Invoke the operation + SiteResource result = await site.GetAsync(); + + // The variable result is a resource. You could call other operations on this instance as well. + // For demo purposes, we get its data from this resource instance + SiteData resourceData = result.Data; + // For demo, we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_Site() + { + // Get your Azure access token. For more details on how Azure SDK gets your access token, refer to: + // https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // Authenticate your client + ArmClient client = new ArmClient(cred); + + // This example assumes you already have this SiteResource created on Azure + // For more information on creating SiteResource, refer to the documentation of SiteResource + string subscriptionId = "f8a30ed0-310b-4f90-9435-d7e8a5cc0c91"; + string resourceGroupName = "test-rg"; + string siteName = "mySite"; + ResourceIdentifier siteResourceId = SiteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName); + SiteResource site = client.GetSiteResource(siteResourceId); + + // Invoke the operation + SiteUpdate patch = new SiteUpdate + { + Properties = new SiteUpdateProperties + { + DisplayName = "Updated Site Name", + SiteAddress = new SiteAddressProperties + { + City = "New York", + Country = "USA" + } + } + }; + SiteResource result = await site.UpdateAsync(patch); + + // The variable result is a resource. You could call other operations on this instance as well. + // For demo purposes, we get its data from this resource instance + SiteData resourceData = result.Data; + // For demo, we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_Site() + { + // Get your Azure access token. For more details on how Azure SDK gets your access token, refer to: + // https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // Authenticate your client + ArmClient client = new ArmClient(cred); + + // This example assumes you already have this SiteResource created on Azure + // For more information on creating SiteResource, refer to the documentation of SiteResource + string subscriptionId = "f8a30ed0-310b-4f90-9435-d7e8a5cc0c91"; + string resourceGroupName = "test-rg"; + string siteName = "mySite"; + ResourceIdentifier siteResourceId = SiteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName); + SiteResource site = client.GetSiteResource(siteResourceId); + + // Invoke the operation + await site.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + } +} 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..26a5b9a64e4f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Azure.ResourceManager.SiteManager.csproj @@ -0,0 +1,8 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.SiteManager + Azure Resource Manager client SDK for Azure resource provider SiteManager. + azure;management;arm;resource manager;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..a2ba2a9e2d19 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/ArmSiteManagerModelFactory.cs @@ -0,0 +1,57 @@ +// 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. + /// Physical address of the site. + /// Key-value pairs for labeling the site resource. + /// Provisioning state of last operation. + /// A new instance for mocking. + public static SiteProperties SiteProperties(string displayName = null, string description = null, SiteAddressProperties siteAddress = null, IDictionary labels = null, ResourceProvisioningState? provisioningState = null) + { + labels ??= new Dictionary(); + + return new SiteProperties( + displayName, + description, + siteAddress, + labels, + 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..50aecfb5c13f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerArmClient.cs @@ -0,0 +1,49 @@ +// 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 SiteResource GetSiteResource(ResourceIdentifier id) + { + SiteResource.ValidateResourceId(id); + return new SiteResource(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..20016b8a38dc --- /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 SiteResources in the ResourceGroupResource. + /// An object representing collection of SiteResources and their operations over a SiteResource. + public virtual SiteCollection GetSites() + { + return GetCachedClient(client => new SiteCollection(client, Id)); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2025-03-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> GetSiteAsync(string siteName, CancellationToken cancellationToken = default) + { + return await GetSites().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 + /// 2025-03-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 GetSite(string siteName, CancellationToken cancellationToken = default) + { + return GetSites().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..14a2d322bc1f --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerSubscriptionResource.cs @@ -0,0 +1,425 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableSiteManagerSubscriptionResource : ArmResource + { + private ClientDiagnostics _sitesBySubscriptionClientDiagnostics; + private SitesBySubscriptionRestOperations _sitesBySubscriptionRestClient; + + /// 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 ClientDiagnostics SitesBySubscriptionClientDiagnostics => _sitesBySubscriptionClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SiteManager", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private SitesBySubscriptionRestOperations SitesBySubscriptionRestClient => _sitesBySubscriptionRestClient ??= new SitesBySubscriptionRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetSitesAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => SitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), SitesBySubscriptionClientDiagnostics, Pipeline, "MockableSiteManagerSubscriptionResource.GetSites", "value", "nextLink", cancellationToken); + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetSites(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => SitesBySubscriptionRestClient.CreateListRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SitesBySubscriptionRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), SitesBySubscriptionClientDiagnostics, Pipeline, "MockableSiteManagerSubscriptionResource.GetSites", "value", "nextLink", cancellationToken); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// 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> GetSitesBySubscriptionAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.GetSitesBySubscription"); + scope.Start(); + try + { + var response = await SitesBySubscriptionRestClient.GetAsync(Id.SubscriptionId, siteName, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SiteResource(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 + /// 2025-03-01-preview + /// + /// + /// + /// 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 GetSitesBySubscription(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.GetSitesBySubscription"); + scope.Start(); + try + { + var response = SitesBySubscriptionRestClient.Get(Id.SubscriptionId, siteName, cancellationToken); + return Response.FromValue(new SiteResource(Client, response.Value), response.GetRawResponse()); + } + 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 + /// 2025-03-01-preview + /// + /// + /// + /// 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> CreateOrUpdateSitesBySubscriptionAsync(WaitUntil waitUntil, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.CreateOrUpdateSitesBySubscription"); + scope.Start(); + try + { + var response = await SitesBySubscriptionRestClient.CreateOrUpdateAsync(Id.SubscriptionId, siteName, data, cancellationToken).ConfigureAwait(false); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), SitesBySubscriptionClientDiagnostics, Pipeline, SitesBySubscriptionRestClient.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 + /// 2025-03-01-preview + /// + /// + /// + /// 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 CreateOrUpdateSitesBySubscription(WaitUntil waitUntil, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.CreateOrUpdateSitesBySubscription"); + scope.Start(); + try + { + var response = SitesBySubscriptionRestClient.CreateOrUpdate(Id.SubscriptionId, siteName, data, cancellationToken); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), SitesBySubscriptionClientDiagnostics, Pipeline, SitesBySubscriptionRestClient.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; + } + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> UpdateSitesBySubscriptionAsync(string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.UpdateSitesBySubscription"); + scope.Start(); + try + { + var response = await SitesBySubscriptionRestClient.UpdateAsync(Id.SubscriptionId, siteName, properties, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SiteResource(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 + /// 2025-03-01-preview + /// + /// + /// + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response UpdateSitesBySubscription(string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.UpdateSitesBySubscription"); + scope.Start(); + try + { + var response = SitesBySubscriptionRestClient.Update(Id.SubscriptionId, siteName, properties, cancellationToken); + return Response.FromValue(new SiteResource(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 + /// 2025-03-01-preview + /// + /// + /// + /// 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 DeleteSitesBySubscriptionAsync(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.DeleteSitesBySubscription"); + scope.Start(); + try + { + var response = await SitesBySubscriptionRestClient.DeleteAsync(Id.SubscriptionId, siteName, cancellationToken).ConfigureAwait(false); + return response; + } + 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 + /// 2025-03-01-preview + /// + /// + /// + /// 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 DeleteSitesBySubscription(string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesBySubscriptionClientDiagnostics.CreateScope("MockableSiteManagerSubscriptionResource.DeleteSitesBySubscription"); + scope.Start(); + try + { + var response = SitesBySubscriptionRestClient.Delete(Id.SubscriptionId, siteName, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs new file mode 100644 index 000000000000..3612ec1ecbc3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/MockableSiteManagerTenantResource.cs @@ -0,0 +1,451 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.SiteManager.Models; + +namespace Azure.ResourceManager.SiteManager.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableSiteManagerTenantResource : ArmResource + { + private ClientDiagnostics _sitesByServiceGroupClientDiagnostics; + private SitesByServiceGroupRestOperations _sitesByServiceGroupRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableSiteManagerTenantResource() + { + } + + /// 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 MockableSiteManagerTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics SitesByServiceGroupClientDiagnostics => _sitesByServiceGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.SiteManager", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private SitesByServiceGroupRestOperations SitesByServiceGroupRestClient => _sitesByServiceGroupRestClient ??= new SitesByServiceGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// list Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// SitesByServiceGroup_ListByServiceGroup + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetSitesAsync(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => SitesByServiceGroupRestClient.CreateListByServiceGroupRequest(servicegroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SitesByServiceGroupRestClient.CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), SitesByServiceGroupClientDiagnostics, Pipeline, "MockableSiteManagerTenantResource.GetSites", "value", "nextLink", cancellationToken); + } + + /// + /// list Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// SitesByServiceGroup_ListByServiceGroup + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetSites(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => SitesByServiceGroupRestClient.CreateListByServiceGroupRequest(servicegroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => SitesByServiceGroupRestClient.CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), SitesByServiceGroupClientDiagnostics, Pipeline, "MockableSiteManagerTenantResource.GetSites", "value", "nextLink", cancellationToken); + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> GetSitesByServiceGroupAsync(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.GetSitesByServiceGroup"); + scope.Start(); + try + { + var response = await SitesByServiceGroupRestClient.GetAsync(servicegroupName, siteName, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response GetSitesByServiceGroup(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.GetSitesByServiceGroup"); + scope.Start(); + try + { + var response = SitesByServiceGroupRestClient.Get(servicegroupName, siteName, cancellationToken); + return Response.FromValue(new SiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// create or update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public virtual async Task> CreateOrUpdateSitesByServiceGroupAsync(WaitUntil waitUntil, string servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.CreateOrUpdateSitesByServiceGroup"); + scope.Start(); + try + { + var response = await SitesByServiceGroupRestClient.CreateOrUpdateAsync(servicegroupName, siteName, data, cancellationToken).ConfigureAwait(false); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), SitesByServiceGroupClientDiagnostics, Pipeline, SitesByServiceGroupRestClient.CreateCreateOrUpdateRequest(servicegroupName, 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 or update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public virtual ArmOperation CreateOrUpdateSitesByServiceGroup(WaitUntil waitUntil, string servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.CreateOrUpdateSitesByServiceGroup"); + scope.Start(); + try + { + var response = SitesByServiceGroupRestClient.CreateOrUpdate(servicegroupName, siteName, data, cancellationToken); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), SitesByServiceGroupClientDiagnostics, Pipeline, SitesByServiceGroupRestClient.CreateCreateOrUpdateRequest(servicegroupName, siteName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public virtual async Task> UpdateSitesByServiceGroupAsync(string servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.UpdateSitesByServiceGroup"); + scope.Start(); + try + { + var response = await SitesByServiceGroupRestClient.UpdateAsync(servicegroupName, siteName, properties, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public virtual Response UpdateSitesByServiceGroup(string servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.UpdateSitesByServiceGroup"); + scope.Start(); + try + { + var response = SitesByServiceGroupRestClient.Update(servicegroupName, siteName, properties, cancellationToken); + return Response.FromValue(new SiteResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task DeleteSitesByServiceGroupAsync(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.DeleteSitesByServiceGroup"); + scope.Start(); + try + { + var response = await SitesByServiceGroupRestClient.DeleteAsync(servicegroupName, siteName, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response DeleteSitesByServiceGroup(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var scope = SitesByServiceGroupClientDiagnostics.CreateScope("MockableSiteManagerTenantResource.DeleteSitesByServiceGroup"); + scope.Start(); + try + { + var response = SitesByServiceGroupRestClient.Delete(servicegroupName, siteName, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} 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..5d2265164815 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Extensions/SiteManagerExtensions.cs @@ -0,0 +1,833 @@ +// 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; +using Azure.ResourceManager.SiteManager.Models; + +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)); + } + + private static MockableSiteManagerTenantResource GetMockableSiteManagerTenantResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableSiteManagerTenantResource(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 SiteResource GetSiteResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableSiteManagerArmClient(client).GetSiteResource(id); + } + + /// + /// Gets a collection of SiteResources 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 SiteResources and their operations over a SiteResource. + public static SiteCollection GetSites(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetSites(); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2025-03-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> GetSiteAsync(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetSiteAsync(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 + /// 2025-03-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 GetSite(this ResourceGroupResource resourceGroupResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableSiteManagerResourceGroupResource(resourceGroupResource).GetSite(siteName, cancellationToken); + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetSitesAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSitesAsync(cancellationToken); + } + + /// + /// List Site resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// Site_List + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetSites(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSites(cancellationToken); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public static async Task> GetSitesBySubscriptionAsync(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSitesBySubscriptionAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public static Response GetSitesBySubscription(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).GetSitesBySubscription(siteName, cancellationToken); + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// 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 static async Task> CreateOrUpdateSitesBySubscriptionAsync(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).CreateOrUpdateSitesBySubscriptionAsync(waitUntil, siteName, data, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// 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 static ArmOperation CreateOrUpdateSitesBySubscription(this SubscriptionResource subscriptionResource, WaitUntil waitUntil, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).CreateOrUpdateSitesBySubscription(waitUntil, siteName, data, cancellationToken); + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> UpdateSitesBySubscriptionAsync(this SubscriptionResource subscriptionResource, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).UpdateSitesBySubscriptionAsync(siteName, properties, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response UpdateSitesBySubscription(this SubscriptionResource subscriptionResource, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).UpdateSitesBySubscription(siteName, properties, cancellationToken); + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public static async Task DeleteSitesBySubscriptionAsync(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableSiteManagerSubscriptionResource(subscriptionResource).DeleteSitesBySubscriptionAsync(siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete a Site + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// Site_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Name of Site resource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public static Response DeleteSitesBySubscription(this SubscriptionResource subscriptionResource, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableSiteManagerSubscriptionResource(subscriptionResource).DeleteSitesBySubscription(siteName, cancellationToken); + } + + /// + /// list Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// SitesByServiceGroup_ListByServiceGroup + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetSitesAsync(this TenantResource tenantResource, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).GetSitesAsync(servicegroupName, cancellationToken); + } + + /// + /// list Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites + /// + /// + /// Operation Id + /// SitesByServiceGroup_ListByServiceGroup + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetSites(this TenantResource tenantResource, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).GetSites(servicegroupName, cancellationToken); + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> GetSitesByServiceGroupAsync(this TenantResource tenantResource, string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return await GetMockableSiteManagerTenantResource(tenantResource).GetSitesByServiceGroupAsync(servicegroupName, siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Get + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response GetSitesByServiceGroup(this TenantResource tenantResource, string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).GetSitesByServiceGroup(servicegroupName, siteName, cancellationToken); + } + + /// + /// create or update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static async Task> CreateOrUpdateSitesByServiceGroupAsync(this TenantResource tenantResource, WaitUntil waitUntil, string servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return await GetMockableSiteManagerTenantResource(tenantResource).CreateOrUpdateSitesByServiceGroupAsync(waitUntil, servicegroupName, siteName, data, cancellationToken).ConfigureAwait(false); + } + + /// + /// create or update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static ArmOperation CreateOrUpdateSitesByServiceGroup(this TenantResource tenantResource, WaitUntil waitUntil, string servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).CreateOrUpdateSitesByServiceGroup(waitUntil, servicegroupName, siteName, data, cancellationToken); + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static async Task> UpdateSitesByServiceGroupAsync(this TenantResource tenantResource, string servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return await GetMockableSiteManagerTenantResource(tenantResource).UpdateSitesByServiceGroupAsync(servicegroupName, siteName, properties, cancellationToken).ConfigureAwait(false); + } + + /// + /// update Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Update + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , , or is null. + public static Response UpdateSitesByServiceGroup(this TenantResource tenantResource, string servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).UpdateSitesByServiceGroup(servicegroupName, siteName, properties, cancellationToken); + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task DeleteSitesByServiceGroupAsync(this TenantResource tenantResource, string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return await GetMockableSiteManagerTenantResource(tenantResource).DeleteSitesByServiceGroupAsync(servicegroupName, siteName, cancellationToken).ConfigureAwait(false); + } + + /// + /// delete Site at SG scope + /// + /// + /// Request Path + /// /providers/Microsoft.Management/serviceGroups/{servicegroupName}/providers/Microsoft.Edge/sites/{siteName} + /// + /// + /// Operation Id + /// SitesByServiceGroup_Delete + /// + /// + /// Default Api Version + /// 2025-03-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response DeleteSitesByServiceGroup(this TenantResource tenantResource, string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableSiteManagerTenantResource(tenantResource).DeleteSitesByServiceGroup(servicegroupName, 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..c37eb6c8ba22 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,407 @@ +// 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 JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + + 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 bool IsSentinelValue(BinaryData value) + { + ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan valueSpan = value.ToMemory().Span; + return sentinelSpan.SequenceEqual(valueSpan); + } + + 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/SiteManagerArmOperation.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteManagerArmOperation.cs new file mode 100644 index 000000000000..9cc583e78499 --- /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, AzureResourceManagerSiteManagerContext.Default).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..e5249794f34c --- /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, AzureResourceManagerSiteManagerContext.Default).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/SiteOperationSource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteOperationSource.cs new file mode 100644 index 000000000000..a0ce19a9d1fa --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/LongRunningOperation/SiteOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.SiteManager +{ + internal class SiteOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal SiteOperationSource(ArmClient client) + { + _client = client; + } + + SiteResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); + return new SiteResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerSiteManagerContext.Default); + return await Task.FromResult(new SiteResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs new file mode 100644 index 000000000000..27f4598b17be --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/AzureResourceManagerSiteManagerContext.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Azure.ResourceManager.SiteManager +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// + public partial class AzureResourceManagerSiteManagerContext : ModelReaderWriterContext + { + } +} 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/SiteAddressProperties.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteAddressProperties.Serialization.cs new file mode 100644 index 000000000000..32ac8a0c00ea --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteAddressProperties.Serialization.cs @@ -0,0 +1,191 @@ +// 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 SiteAddressProperties : 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(SiteAddressProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(StreetAddress1)) + { + writer.WritePropertyName("streetAddress1"u8); + writer.WriteStringValue(StreetAddress1); + } + if (Optional.IsDefined(StreetAddress2)) + { + writer.WritePropertyName("streetAddress2"u8); + writer.WriteStringValue(StreetAddress2); + } + if (Optional.IsDefined(City)) + { + writer.WritePropertyName("city"u8); + writer.WriteStringValue(City); + } + if (Optional.IsDefined(StateOrProvince)) + { + writer.WritePropertyName("stateOrProvince"u8); + writer.WriteStringValue(StateOrProvince); + } + if (Optional.IsDefined(Country)) + { + writer.WritePropertyName("country"u8); + writer.WriteStringValue(Country); + } + if (Optional.IsDefined(PostalCode)) + { + writer.WritePropertyName("postalCode"u8); + writer.WriteStringValue(PostalCode); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SiteAddressProperties 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(SiteAddressProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSiteAddressProperties(document.RootElement, options); + } + + internal static SiteAddressProperties DeserializeSiteAddressProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string streetAddress1 = default; + string streetAddress2 = default; + string city = default; + string stateOrProvince = default; + string country = default; + string postalCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("streetAddress1"u8)) + { + streetAddress1 = property.Value.GetString(); + continue; + } + if (property.NameEquals("streetAddress2"u8)) + { + streetAddress2 = property.Value.GetString(); + continue; + } + if (property.NameEquals("city"u8)) + { + city = property.Value.GetString(); + continue; + } + if (property.NameEquals("stateOrProvince"u8)) + { + stateOrProvince = property.Value.GetString(); + continue; + } + if (property.NameEquals("country"u8)) + { + country = property.Value.GetString(); + continue; + } + if (property.NameEquals("postalCode"u8)) + { + postalCode = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteAddressProperties( + streetAddress1, + streetAddress2, + city, + stateOrProvince, + country, + postalCode, + 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, AzureResourceManagerSiteManagerContext.Default); + default: + throw new FormatException($"The model {nameof(SiteAddressProperties)} does not support writing '{options.Format}' format."); + } + } + + SiteAddressProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSiteAddressProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SiteAddressProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteAddressProperties.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteAddressProperties.cs new file mode 100644 index 000000000000..c38848513bd9 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteAddressProperties.cs @@ -0,0 +1,85 @@ +// 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 +{ + /// Site address properties. + public partial class SiteAddressProperties + { + /// + /// 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 SiteAddressProperties() + { + } + + /// Initializes a new instance of . + /// First line of the street address. + /// Second line of the street address. + /// City of the address. + /// State or province of the address. + /// Country of the address. + /// Postal or ZIP code of the address. + /// Keeps track of any properties unknown to the library. + internal SiteAddressProperties(string streetAddress1, string streetAddress2, string city, string stateOrProvince, string country, string postalCode, IDictionary serializedAdditionalRawData) + { + StreetAddress1 = streetAddress1; + StreetAddress2 = streetAddress2; + City = city; + StateOrProvince = stateOrProvince; + Country = country; + PostalCode = postalCode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// First line of the street address. + public string StreetAddress1 { get; set; } + /// Second line of the street address. + public string StreetAddress2 { get; set; } + /// City of the address. + public string City { get; set; } + /// State or province of the address. + public string StateOrProvince { get; set; } + /// Country of the address. + public string Country { get; set; } + /// Postal or ZIP code of the address. + public string PostalCode { get; set; } + } +} 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..98d8b3f600bb --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, AzureResourceManagerSiteManagerContext.Default); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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..53de9c30b8e4 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.Serialization.cs @@ -0,0 +1,202 @@ +// 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(SiteAddress)) + { + writer.WritePropertyName("siteAddress"u8); + writer.WriteObjectValue(SiteAddress, options); + } + if (Optional.IsCollectionDefined(Labels)) + { + writer.WritePropertyName("labels"u8); + writer.WriteStartObject(); + foreach (var item in Labels) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + SiteAddressProperties siteAddress = default; + IDictionary labels = 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("siteAddress"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + siteAddress = SiteAddressProperties.DeserializeSiteAddressProperties(property.Value, options); + continue; + } + if (property.NameEquals("labels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + labels = dictionary; + 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, + siteAddress, + labels ?? new ChangeTrackingDictionary(), + 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, AzureResourceManagerSiteManagerContext.Default); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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..a19e594d3009 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteProperties.cs @@ -0,0 +1,82 @@ +// 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 +{ + /// 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() + { + Labels = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// displayName of Site resource. + /// Description of Site resource. + /// Physical address of the site. + /// Key-value pairs for labeling the site resource. + /// Provisioning state of last operation. + /// Keeps track of any properties unknown to the library. + internal SiteProperties(string displayName, string description, SiteAddressProperties siteAddress, IDictionary labels, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + Description = description; + SiteAddress = siteAddress; + Labels = labels; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// displayName of Site resource. + public string DisplayName { get; set; } + /// Description of Site resource. + public string Description { get; set; } + /// Physical address of the site. + public SiteAddressProperties SiteAddress { get; set; } + /// Key-value pairs for labeling the site resource. + public IDictionary Labels { get; } + /// 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..0b99bacb6e35 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, AzureResourceManagerSiteManagerContext.Default); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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..b9ec25a8980d --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.Serialization.cs @@ -0,0 +1,181 @@ +// 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(SiteAddress)) + { + writer.WritePropertyName("siteAddress"u8); + writer.WriteObjectValue(SiteAddress, options); + } + if (Optional.IsCollectionDefined(Labels)) + { + writer.WritePropertyName("labels"u8); + writer.WriteStartObject(); + foreach (var item in Labels) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + SiteAddressProperties siteAddress = default; + IDictionary labels = 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("siteAddress"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + siteAddress = SiteAddressProperties.DeserializeSiteAddressProperties(property.Value, options); + continue; + } + if (property.NameEquals("labels"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + labels = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SiteUpdateProperties(displayName, description, siteAddress, labels ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerSiteManagerContext.Default); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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..eca3c8f9d9f7 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/Models/SiteUpdateProperties.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; + +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() + { + Labels = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// displayName of Site resource. + /// Description of Site resource. + /// Physical address of the site. + /// Key-value pairs for labeling the site resource. + /// Keeps track of any properties unknown to the library. + internal SiteUpdateProperties(string displayName, string description, SiteAddressProperties siteAddress, IDictionary labels, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + Description = description; + SiteAddress = siteAddress; + Labels = labels; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// displayName of Site resource. + public string DisplayName { get; set; } + /// Description of Site resource. + public string Description { get; set; } + /// Physical address of the site. + public SiteAddressProperties SiteAddress { get; set; } + /// Key-value pairs for labeling the site resource. + public IDictionary Labels { get; } + } +} 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/RestOperations/SitesByServiceGroupRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs new file mode 100644 index 000000000000..d4e83d97eda3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesByServiceGroupRestOperations.cs @@ -0,0 +1,529 @@ +// 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 SitesByServiceGroupRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of SitesByServiceGroupRestOperations. + /// 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 SitesByServiceGroupRestOperations(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 ?? "2025-03-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListByServiceGroupRequestUri(string servicegroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByServiceGroupRequest(string servicegroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, 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 at SG scope. + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListByServiceGroupAsync(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using var message = CreateListByServiceGroupRequest(servicegroupName); + 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, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// list Site at SG scope. + /// The name of the service group. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListByServiceGroup(string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using var message = CreateListByServiceGroupRequest(servicegroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetRequestUri(string servicegroupName, string siteName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string servicegroupName, string siteName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, 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 Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// 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 servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(servicegroupName, 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, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Get(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateGetRequest(servicegroupName, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string servicegroupName, string siteName, SiteData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string servicegroupName, 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("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, 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 or update Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// 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 servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(servicegroupName, 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 or update Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdate(string servicegroupName, string siteName, SiteData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(servicegroupName, 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 servicegroupName, string siteName, SiteUpdate properties) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string servicegroupName, 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("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, 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 Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// 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 servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(servicegroupName, 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, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// update Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The properties of the site. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Update(string servicegroupName, string siteName, SiteUpdate properties, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + Argument.AssertNotNull(properties, nameof(properties)); + + using var message = CreateUpdateRequest(servicegroupName, siteName, properties); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string servicegroupName, string siteName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, true); + uri.AppendPath("/providers/Microsoft.Edge/sites/", false); + uri.AppendPath(siteName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string servicegroupName, string siteName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.Management/serviceGroups/", false); + uri.AppendPath(servicegroupName, 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 Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// 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 servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(servicegroupName, 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 Site at SG scope. + /// The name of the service group. + /// The name of the site. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response Delete(string servicegroupName, string siteName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + Argument.AssertNotNullOrEmpty(siteName, nameof(siteName)); + + using var message = CreateDeleteRequest(servicegroupName, siteName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByServiceGroupNextPageRequestUri(string nextLink, string servicegroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByServiceGroupNextPageRequest(string nextLink, string servicegroupName) + { + 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 at SG scope. + /// The URL to the next page of results. + /// The name of the service group. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListByServiceGroupNextPageAsync(string nextLink, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using var message = CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); + 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, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SiteListResult.DeserializeSiteListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// list Site at SG scope. + /// The URL to the next page of results. + /// The name of the service group. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListByServiceGroupNextPage(string nextLink, string servicegroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(servicegroupName, nameof(servicegroupName)); + + using var message = CreateListByServiceGroupNextPageRequest(nextLink, servicegroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SiteListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + 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/SitesBySubscriptionRestOperations.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs new file mode 100644 index 000000000000..4fe75a7f9492 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/RestOperations/SitesBySubscriptionRestOperations.cs @@ -0,0 +1,529 @@ +// 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 ?? "2025-03-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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, 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, ModelSerializationExtensions.JsonDocumentOptions); + value = SiteData.DeserializeSiteData(document.RootElement); + return Response.FromValue(value, 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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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..1359ad970890 --- /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 ?? "2025-03-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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions, 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, ModelSerializationExtensions.JsonDocumentOptions); + 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/SiteCollection.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteCollection.cs new file mode 100644 index 000000000000..7cf5c95570d4 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteCollection.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 GetSites method from an instance of . + /// + public partial class SiteCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _siteClientDiagnostics; + private readonly SitesRestOperations _siteRestClient; + + /// Initializes a new instance of the class for mocking. + protected SiteCollection() + { + } + + /// 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 SiteCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _siteClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", SiteResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(SiteResource.ResourceType, out string siteApiVersion); + _siteRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, siteApiVersion); +#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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _siteRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken).ConfigureAwait(false); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), _siteClientDiagnostics, Pipeline, _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _siteRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, siteName, data, cancellationToken); + var operation = new SiteManagerArmOperation(new SiteOperationSource(Client), _siteClientDiagnostics, Pipeline, _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.Get"); + scope.Start(); + try + { + var response = await _siteRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.Get"); + scope.Start(); + try + { + var response = _siteRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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 + /// 2025-03-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) => _siteRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _siteRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), _siteClientDiagnostics, Pipeline, "SiteCollection.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 + /// 2025-03-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) => _siteRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _siteRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SiteResource(Client, SiteData.DeserializeSiteData(e)), _siteClientDiagnostics, Pipeline, "SiteCollection.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.Exists"); + scope.Start(); + try + { + var response = await _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.Exists"); + scope.Start(); + try + { + var response = _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _siteRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteCollection.GetIfExists"); + scope.Start(); + try + { + var response = _siteRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, siteName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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/SiteData.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteData.Serialization.cs new file mode 100644 index 000000000000..fa51fb0cc478 --- /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, AzureResourceManagerSiteManagerContext.Default); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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/SiteResource.Serialization.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteResource.Serialization.cs new file mode 100644 index 000000000000..3f4196d79f31 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteResource.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 SiteResource : 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, AzureResourceManagerSiteManagerContext.Default); + + SiteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerSiteManagerContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteResource.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteResource.cs new file mode 100644 index 000000000000..aa979e27e450 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Generated/SiteResource.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 Site 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 GetSiteResource method. + /// Otherwise you can get one from its parent resource using the GetSite method. + /// + public partial class SiteResource : 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 _siteClientDiagnostics; + private readonly SitesRestOperations _siteRestClient; + 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 SiteResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SiteResource(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 SiteResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _siteClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.SiteManager", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string siteApiVersion); + _siteRestClient = new SitesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, siteApiVersion); +#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 + /// 2025-03-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _siteClientDiagnostics.CreateScope("SiteResource.Get"); + scope.Start(); + try + { + var response = await _siteRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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 + /// 2025-03-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _siteClientDiagnostics.CreateScope("SiteResource.Get"); + scope.Start(); + try + { + var response = _siteRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SiteResource(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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteResource.Delete"); + scope.Start(); + try + { + var response = await _siteRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteResource.Delete"); + scope.Start(); + try + { + var response = _siteRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var uri = _siteRestClient.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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteResource.Update"); + scope.Start(); + try + { + var response = await _siteRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, properties, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new SiteResource(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 + /// 2025-03-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 = _siteClientDiagnostics.CreateScope("SiteResource.Update"); + scope.Start(); + try + { + var response = _siteRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, properties, cancellationToken); + return Response.FromValue(new SiteResource(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..8a01c73db263 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/src/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: Azure.Core.AzureResourceProviderNamespace("SiteManager")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.SiteManager.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Azure.ResourceManager.SiteManager.Tests.csproj b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Azure.ResourceManager.SiteManager.Tests.csproj new file mode 100644 index 000000000000..f91dc199c063 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Azure.ResourceManager.SiteManager.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/ServiceGroupSiteCollectionTests.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/ServiceGroupSiteCollectionTests.cs new file mode 100644 index 000000000000..c763b2a3379e --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/ServiceGroupSiteCollectionTests.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.SiteManager.Tests +{ + [TestFixture] + public class ServiceGroupSiteCollectionTests : SiteManagerManagementTestBase + { + public ServiceGroupSiteCollectionTests() : base(true) + { + } + + [TestCase] + [RecordedTest] + public async Task TestSiteCRUDOperations() + { + var location = AzureLocation.EastUS; + var siteName = Recording.GenerateAssetName("SeattleSite"); + + // Create + var site = await CreateServiceGroupSiteAsync(DefaultTenant, siteName, "BasavarajSG"); + var siteData = site.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "Seattle Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + + // Get + SiteResource siteResourceFromGet = await DefaultTenant.GetSitesByServiceGroupAsync("BasavarajSG", siteName); + siteData = siteResourceFromGet.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "Seattle Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + Assert.That(siteData.Properties.Labels, Does.ContainKey("city").WithValue("Seattle")); + + // Update + var UpdatedSite = await UpdateServiceGroupSiteAsync(DefaultTenant, siteName, "BasavarajSG"); + var UpdatedSiteData = UpdatedSite.Data; + Assert.AreEqual(UpdatedSiteData.Name, siteName); + Assert.AreEqual(UpdatedSiteData.Properties.DisplayName, "New York Site"); + Assert.AreEqual(UpdatedSiteData.Properties.SiteAddress.Country, "USA"); + Assert.AreEqual(UpdatedSiteData.Properties.SiteAddress.City, "New York"); + + // Get + siteResourceFromGet = await DefaultTenant.GetSitesByServiceGroupAsync("BasavarajSG", siteName); + siteData = siteResourceFromGet.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "New York Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + Assert.That(UpdatedSiteData.Properties.Labels, Does.ContainKey("city").WithValue("New York")); + + // Delete + var deleteSite = await DefaultTenant.DeleteSitesByServiceGroupAsync("BasavarajSG", siteName); + Assert.AreEqual(deleteSite.Status, 200); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/SiteCollectionTests.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/SiteCollectionTests.cs new file mode 100644 index 000000000000..93c9f2c37ce7 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/Scenario/SiteCollectionTests.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.ResourceManager.SiteManager.Tests +{ + [TestFixture] + public class SiteCollectionTests : SiteManagerManagementTestBase + { + public SiteCollectionTests() : base(true) + { + } + + [TestCase] + [RecordedTest] + public async Task TestSiteCRUDOperations() + { + var location = AzureLocation.EastUS; + var resourceGroup = await CreateResourceGroup(DefaultSubscription, "sites-rg", location); + var siteCollection = resourceGroup.GetSites(); + var siteName = Recording.GenerateAssetName("SeattleSite"); + + // Create + var site = await CreateSiteAsync(resourceGroup, siteName); + var siteData = site.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "Seattle Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + + // Get + SiteResource siteResourceFromGet = await siteCollection.GetAsync(siteName); + siteData = siteResourceFromGet.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "Seattle Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + Assert.That(siteData.Properties.Labels, Does.ContainKey("city").WithValue("Seattle")); + + await foreach (SiteResource siteResourceFromCollection in siteCollection) + { + Assert.AreEqual(siteResourceFromCollection.Data.Name, siteName); + Assert.AreEqual(siteResourceFromCollection.Data.Properties.DisplayName, "Seattle Site"); + Assert.AreEqual(siteResourceFromCollection.Data.Properties.SiteAddress.Country, "USA"); + } + + // Update + var UpdatedSite = await UpdateSiteAsync(resourceGroup, siteName); + var UpdatedSiteData = UpdatedSite.Data; + Assert.AreEqual(UpdatedSiteData.Name, siteName); + Assert.AreEqual(UpdatedSiteData.Properties.DisplayName, "New York Site"); + Assert.AreEqual(UpdatedSiteData.Properties.SiteAddress.Country, "USA"); + Assert.AreEqual(UpdatedSiteData.Properties.SiteAddress.City, "New York"); + + // Get + siteResourceFromGet = await siteCollection.GetAsync(siteName); + siteData = siteResourceFromGet.Data; + Assert.AreEqual(siteData.Name, siteName); + Assert.AreEqual(siteData.Properties.DisplayName, "New York Site"); + Assert.AreEqual(siteData.Properties.SiteAddress.Country, "USA"); + Assert.That(UpdatedSiteData.Properties.Labels, Does.ContainKey("city").WithValue("New York")); + + // Delete + var deleteSite = await siteResourceFromGet.DeleteAsync(WaitUntil.Completed); + await deleteSite.WaitForCompletionResponseAsync(); + Assert.IsTrue(deleteSite.HasCompleted); + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestBase.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestBase.cs new file mode 100644 index 000000000000..deb96c868d78 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestBase.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.SiteManager.Models; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System; +using System.Linq; +using System.Reflection.Emit; +using System.Reflection.Metadata; +using System.Security.AccessControl; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.SiteManager.Tests +{ + public class SiteManagerManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + protected TenantResource DefaultTenant { get; private set; } + + protected SiteManagerManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected SiteManagerManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + DefaultTenant = (await Client.GetTenants().ToEnumerableAsync().ConfigureAwait(false)).FirstOrDefault(); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + + protected async Task CreateSiteAsync(ResourceGroupResource resourceGroup, string siteName) + { + string displayName, description; + System.Collections.Generic.Dictionary labels; + SiteAddressProperties siteAddress; + InitializeSiteDetails(out displayName, out description, out labels, out siteAddress); + + var siteProperties = ArmSiteManagerModelFactory.SiteProperties(displayName, description, siteAddress, labels); + var siteData = ArmSiteManagerModelFactory.SiteData(resourceGroup.Id, siteName, default, null, siteProperties); + + var lro = await resourceGroup.GetSites().CreateOrUpdateAsync(WaitUntil.Completed, siteName, siteData); + return lro.Value; + } + + protected async Task CreateServiceGroupSiteAsync(TenantResource tenantResource, string siteName, string serviceGroupName) + { + string displayName, description; + System.Collections.Generic.Dictionary labels; + SiteAddressProperties siteAddress; + InitializeSiteDetails(out displayName, out description, out labels, out siteAddress); + + var siteProperties = ArmSiteManagerModelFactory.SiteProperties(displayName, description, siteAddress, labels); + var siteData = ArmSiteManagerModelFactory.SiteData(tenantResource.Id, siteName, default, null, siteProperties); + + var lro = await tenantResource.CreateOrUpdateSitesByServiceGroupAsync(WaitUntil.Completed, serviceGroupName, siteName, siteData); + return lro.Value; + } + + private static void InitializeSiteDetails(out string displayName, out string description, out System.Collections.Generic.Dictionary labels, out SiteAddressProperties siteAddress) + { + displayName = "Seattle Site"; + description = "Seattle Site Description"; + labels = new System.Collections.Generic.Dictionary + { + { "city", "Seattle" }, + { "country", "USA" } + }; + siteAddress = new SiteAddressProperties() + { + StreetAddress1 = "Apt 4B", + StreetAddress2 = "123 Main St", + City = "Seattle", + StateOrProvince = "WA", + Country = "USA", + PostalCode = "98101" + }; + } + + protected async Task UpdateSiteAsync(ResourceGroupResource resourceGroup, string siteName) + { + var displayName = "New York Site"; + var description = "New York Site Description"; + + var labels = new System.Collections.Generic.Dictionary + { + { "city", "New York" } + }; + + SiteAddressProperties siteAddress = new SiteAddressProperties() + { + City = "New York", + Country = "USA", + }; + + var siteProperties = ArmSiteManagerModelFactory.SiteProperties(displayName, description, siteAddress, labels); + var siteData = ArmSiteManagerModelFactory.SiteData(resourceGroup.Id, siteName, default, null, siteProperties); + + var lro = await resourceGroup.GetSites().CreateOrUpdateAsync(WaitUntil.Completed, siteName, siteData); + return lro.Value; + } + + protected async Task UpdateServiceGroupSiteAsync(TenantResource tenantResource, string siteName, string serviceGroupName) + { + var displayName = "New York Site"; + var description = "New York Site Description"; + + var labels = new System.Collections.Generic.Dictionary + { + { "city", "New York" } + }; + + SiteAddressProperties siteAddress = new SiteAddressProperties() + { + City = "New York", + Country = "USA", + }; + + var siteProperties = ArmSiteManagerModelFactory.SiteProperties(displayName, description, siteAddress, labels); + var siteData = ArmSiteManagerModelFactory.SiteData(tenantResource.Id, siteName, default, null, siteProperties); + + var lro = await tenantResource.CreateOrUpdateSitesByServiceGroupAsync(WaitUntil.Completed, serviceGroupName, siteName, siteData); + return lro.Value; + } + } +} diff --git a/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestEnvironment.cs b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestEnvironment.cs new file mode 100644 index 000000000000..98e55cd251e0 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tests/SiteManagerManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.SiteManager.Tests +{ + public class SiteManagerManagementTestEnvironment : TestEnvironment + { + } +} \ No newline at end of file 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..aab771829ed3 --- /dev/null +++ b/sdk/sitemanager/Azure.ResourceManager.SiteManager/tsp-location.yaml @@ -0,0 +1,3 @@ +directory: specification/edge/Microsoft.Edge.Sites.Management +commit: 532b1b8f4efdb960efce95c6694164303d79a3fc +repo: Azure/azure-rest-api-specs \ No newline at end of file diff --git a/sdk/sitemanager/ci.mgmt.yml b/sdk/sitemanager/ci.mgmt.yml new file mode 100644 index 000000000000..7abc1a632539 --- /dev/null +++ b/sdk/sitemanager/ci.mgmt.yml @@ -0,0 +1,23 @@ +# 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 + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.SiteManager + safeName: AzureResourceManagerSiteManager