diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/Azure.ResourceManager.Sphere.sln b/sdk/sphere/Azure.ResourceManager.Sphere/Azure.ResourceManager.Sphere.sln new file mode 100644 index 0000000000000..ff0538fb3aa63 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/Azure.ResourceManager.Sphere.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("{29997D6D-DC9A-4CE2-94C0-452E7E9ACEC6}") = "Azure.ResourceManager.Sphere", "src\Azure.ResourceManager.Sphere.csproj", "{6490C51E-3F0D-4F4C-902B-6F3D5B39657B}" +EndProject +Project("{29997D6D-DC9A-4CE2-94C0-452E7E9ACEC6}") = "Azure.ResourceManager.Sphere.Tests", "tests\Azure.ResourceManager.Sphere.Tests.csproj", "{39C41709-9003-4BBB-9B23-D2873A80B377}" +EndProject +Project("{29997D6D-DC9A-4CE2-94C0-452E7E9ACEC6}") = "Azure.ResourceManager.Sphere.Samples", "samples\Azure.ResourceManager.Sphere.Samples.csproj", "{625A8C42-AFF5-4D2C-A85D-7AD5390D0001}" +EndProject +Global + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BC3DB41F-2150-441D-AB1D-EFE0ACD23DEB} + 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 + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|x64.ActiveCfg = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|x64.Build.0 = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|x86.ActiveCfg = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Debug|x86.Build.0 = Debug|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|Any CPU.Build.0 = Release|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|x64.ActiveCfg = Release|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|x64.Build.0 = Release|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|x86.ActiveCfg = Release|Any CPU + {6490C51E-3F0D-4F4C-902B-6F3D5B39657B}.Release|x86.Build.0 = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|x64.ActiveCfg = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|x64.Build.0 = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|x86.ActiveCfg = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Debug|x86.Build.0 = Debug|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|Any CPU.Build.0 = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|x64.ActiveCfg = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|x64.Build.0 = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|x86.ActiveCfg = Release|Any CPU + {39C41709-9003-4BBB-9B23-D2873A80B377}.Release|x86.Build.0 = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|Any CPU.Build.0 = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|x64.ActiveCfg = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|x64.Build.0 = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|x86.ActiveCfg = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Debug|x86.Build.0 = Debug|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|Any CPU.ActiveCfg = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|Any CPU.Build.0 = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|x64.ActiveCfg = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|x64.Build.0 = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|x86.ActiveCfg = Release|Any CPU + {625A8C42-AFF5-4D2C-A85D-7AD5390D0001}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/CHANGELOG.md b/sdk/sphere/Azure.ResourceManager.Sphere/CHANGELOG.md new file mode 100644 index 0000000000000..23f86d1e896ee --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/CHANGELOG.md @@ -0,0 +1,17 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### General New Features + +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/sphere/Azure.ResourceManager.Sphere/Directory.Build.props b/sdk/sphere/Azure.ResourceManager.Sphere/Directory.Build.props new file mode 100644 index 0000000000000..1a9611bd49242 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/README.md b/sdk/sphere/Azure.ResourceManager.Sphere/README.md new file mode 100644 index 0000000000000..c65ce5755c6bc --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure sphere 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 sphere management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Sphere --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/sphere/Azure.ResourceManager.Sphere/api/Azure.ResourceManager.Sphere.netstandard2.0.cs b/sdk/sphere/Azure.ResourceManager.Sphere/api/Azure.ResourceManager.Sphere.netstandard2.0.cs new file mode 100644 index 0000000000000..2d64f5012cfab --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/api/Azure.ResourceManager.Sphere.netstandard2.0.cs @@ -0,0 +1,611 @@ +namespace Azure.ResourceManager.Sphere +{ + public partial class CatalogCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected CatalogCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string catalogName, Azure.ResourceManager.Sphere.CatalogData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string catalogName, Azure.ResourceManager.Sphere.CatalogData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string catalogName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string catalogName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string catalogName, 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 catalogName, 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 CatalogData : Azure.ResourceManager.Models.TrackedResourceData + { + public CatalogData(Azure.Core.AzureLocation location) : base (default(Azure.Core.AzureLocation)) { } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + } + public partial class CatalogResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected CatalogResource() { } + public virtual Azure.ResourceManager.Sphere.CatalogData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CountDevices(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CountDevicesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetCertificate(string serialNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetCertificateAsync(string serialNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.CertificateCollection GetCertificates() { throw null; } + public virtual Azure.Pageable GetDeployments(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDeploymentsAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetDeviceGroups(Azure.ResourceManager.Sphere.Models.ListDeviceGroupsContent content, string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDeviceGroupsAsync(Azure.ResourceManager.Sphere.Models.ListDeviceGroupsContent content, string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetDeviceInsights(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDeviceInsightsAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetDevices(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetDevicesAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetImage(string imageName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetImageAsync(string imageName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.ImageCollection GetImages() { throw null; } + public virtual Azure.Response GetProduct(string productName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetProductAsync(string productName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.ProductCollection GetProducts() { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Update(Azure.ResourceManager.Sphere.Models.CatalogPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.ResourceManager.Sphere.Models.CatalogPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class CertificateCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected CertificateCollection() { } + public virtual Azure.Response Exists(string serialNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string serialNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string serialNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string serialNumber, 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 CertificateData : Azure.ResourceManager.Models.ResourceData + { + public CertificateData() { } + public string Certificate { get { throw null; } } + public System.DateTimeOffset? ExpiryUtc { get { throw null; } } + public System.DateTimeOffset? NotBeforeUtc { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.CertificateStatus? Status { get { throw null; } } + public string Subject { get { throw null; } } + public string Thumbprint { get { throw null; } } + } + public partial class CertificateResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected CertificateResource() { } + public virtual Azure.ResourceManager.Sphere.CertificateData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RetrieveCertChain(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RetrieveCertChainAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response RetrieveProofOfPossessionNonce(Azure.ResourceManager.Sphere.Models.ProofOfPossessionNonceContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RetrieveProofOfPossessionNonceAsync(Azure.ResourceManager.Sphere.Models.ProofOfPossessionNonceContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class DeploymentCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected DeploymentCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string deploymentName, Azure.ResourceManager.Sphere.DeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string deploymentName, Azure.ResourceManager.Sphere.DeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string deploymentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string deploymentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string deploymentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string deploymentName, 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 DeploymentData : Azure.ResourceManager.Models.ResourceData + { + public DeploymentData() { } + public System.Collections.Generic.IList DeployedImages { get { throw null; } } + public System.DateTimeOffset? DeploymentDateUtc { get { throw null; } } + public string DeploymentId { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + } + public partial class DeploymentResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected DeploymentResource() { } + public virtual Azure.ResourceManager.Sphere.DeploymentData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deploymentName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.DeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.DeploymentData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class DeviceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected DeviceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string deviceName, Azure.ResourceManager.Sphere.DeviceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string deviceName, Azure.ResourceManager.Sphere.DeviceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string deviceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string deviceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string deviceName, 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 deviceName, 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 DeviceData : Azure.ResourceManager.Models.ResourceData + { + public DeviceData() { } + public string ChipSku { get { throw null; } } + public string DeviceId { get { throw null; } set { } } + public string LastAvailableOSVersion { get { throw null; } } + public string LastInstalledOSVersion { get { throw null; } } + public System.DateTimeOffset? LastOSUpdateUtc { get { throw null; } } + public System.DateTimeOffset? LastUpdateRequestUtc { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + } + public partial class DeviceGroupCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected DeviceGroupCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string deviceGroupName, Azure.ResourceManager.Sphere.DeviceGroupData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string deviceGroupName, Azure.ResourceManager.Sphere.DeviceGroupData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string deviceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string deviceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string deviceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string deviceGroupName, 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 DeviceGroupData : Azure.ResourceManager.Models.ResourceData + { + public DeviceGroupData() { } + public Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection? AllowCrashDumpsCollection { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public bool? HasDeployment { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.OSFeedType? OSFeedType { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.RegionalDataBoundary? RegionalDataBoundary { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.UpdatePolicy? UpdatePolicy { get { throw null; } set { } } + } + public partial class DeviceGroupResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected DeviceGroupResource() { } + public virtual Azure.ResourceManager.Sphere.DeviceGroupData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.ResourceManager.ArmOperation ClaimDevices(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.ClaimDevicesContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task ClaimDevicesAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.ClaimDevicesContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response CountDevices(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CountDevicesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetDeployment(string deploymentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetDeploymentAsync(string deploymentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.DeploymentCollection GetDeployments() { throw null; } + public virtual Azure.Response GetDevice(string deviceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetDeviceAsync(string deviceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.DeviceCollection GetDevices() { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.DeviceGroupPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.DeviceGroupPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class DeviceResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected DeviceResource() { } + public virtual Azure.ResourceManager.Sphere.DeviceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName) { 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.ResourceManager.ArmOperation GenerateCapabilityImage(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.GenerateCapabilityImageContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GenerateCapabilityImageAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.GenerateCapabilityImageContent content, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.DevicePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.DevicePatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ImageCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ImageCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string imageName, Azure.ResourceManager.Sphere.ImageData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string imageName, Azure.ResourceManager.Sphere.ImageData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string imageName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string imageName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string imageName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(string filter = null, int? top = default(int?), int? skip = default(int?), int? maxpagesize = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string imageName, 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 ImageData : Azure.ResourceManager.Models.ResourceData + { + public ImageData() { } + public string ComponentId { get { throw null; } } + public string Description { get { throw null; } } + public string Image { get { throw null; } set { } } + public string ImageId { get { throw null; } set { } } + public string ImageName { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.ImageType? ImageType { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.RegionalDataBoundary? RegionalDataBoundary { get { throw null; } set { } } + public System.Uri Uri { get { throw null; } } + } + public partial class ImageResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ImageResource() { } + public virtual Azure.ResourceManager.Sphere.ImageData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string imageName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.ImageData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.ImageData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ProductCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected ProductCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string productName, Azure.ResourceManager.Sphere.ProductData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string productName, Azure.ResourceManager.Sphere.ProductData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string productName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string productName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string productName, 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 productName, 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 ProductData : Azure.ResourceManager.Models.ResourceData + { + public ProductData() { } + public string Description { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + } + public partial class ProductResource : Azure.ResourceManager.ArmResource + { + public static readonly Azure.Core.ResourceType ResourceType; + protected ProductResource() { } + public virtual Azure.ResourceManager.Sphere.ProductData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response CountDevices(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CountDevicesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName) { 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.Pageable GenerateDefaultDeviceGroups(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GenerateDefaultDeviceGroupsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetDeviceGroup(string deviceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetDeviceGroupAsync(string deviceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.Sphere.DeviceGroupCollection GetDeviceGroups() { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.ProductPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.Sphere.Models.ProductPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public static partial class SphereExtensions + { + public static Azure.Response GetCatalog(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string catalogName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetCatalogAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string catalogName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.Sphere.CatalogResource GetCatalogResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.CatalogCollection GetCatalogs(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetCatalogs(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetCatalogsAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.Sphere.CertificateResource GetCertificateResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.DeploymentResource GetDeploymentResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.DeviceGroupResource GetDeviceGroupResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.DeviceResource GetDeviceResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.ImageResource GetImageResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.Sphere.ProductResource GetProductResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + } +} +namespace Azure.ResourceManager.Sphere.Models +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AllowCrashDumpCollection : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AllowCrashDumpCollection(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection Disabled { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection Enabled { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection 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.Sphere.Models.AllowCrashDumpCollection left, Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection left, Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection right) { throw null; } + public override string ToString() { throw null; } + } + public static partial class ArmSphereModelFactory + { + public static Azure.ResourceManager.Sphere.CatalogData CatalogData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CertificateChainResponse CertificateChainResponse(string certificateChain = null) { throw null; } + public static Azure.ResourceManager.Sphere.CertificateData CertificateData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string certificate = null, Azure.ResourceManager.Sphere.Models.CertificateStatus? status = default(Azure.ResourceManager.Sphere.Models.CertificateStatus?), string subject = null, string thumbprint = null, System.DateTimeOffset? expiryUtc = default(System.DateTimeOffset?), System.DateTimeOffset? notBeforeUtc = default(System.DateTimeOffset?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CertificateProperties CertificateProperties(string certificate = null, Azure.ResourceManager.Sphere.Models.CertificateStatus? status = default(Azure.ResourceManager.Sphere.Models.CertificateStatus?), string subject = null, string thumbprint = null, System.DateTimeOffset? expiryUtc = default(System.DateTimeOffset?), System.DateTimeOffset? notBeforeUtc = default(System.DateTimeOffset?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CountDeviceResponse CountDeviceResponse(int value = 0) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CountElementsResponse CountElementsResponse(int value = 0) { throw null; } + public static Azure.ResourceManager.Sphere.DeploymentData DeploymentData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string deploymentId = null, System.Collections.Generic.IEnumerable deployedImages = null, System.DateTimeOffset? deploymentDateUtc = default(System.DateTimeOffset?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.DeviceData DeviceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string deviceId = null, string chipSku = null, string lastAvailableOSVersion = null, string lastInstalledOSVersion = null, System.DateTimeOffset? lastOSUpdateUtc = default(System.DateTimeOffset?), System.DateTimeOffset? lastUpdateRequestUtc = default(System.DateTimeOffset?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.DeviceGroupData DeviceGroupData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string description = null, Azure.ResourceManager.Sphere.Models.OSFeedType? osFeedType = default(Azure.ResourceManager.Sphere.Models.OSFeedType?), Azure.ResourceManager.Sphere.Models.UpdatePolicy? updatePolicy = default(Azure.ResourceManager.Sphere.Models.UpdatePolicy?), Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection? allowCrashDumpsCollection = default(Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection?), Azure.ResourceManager.Sphere.Models.RegionalDataBoundary? regionalDataBoundary = default(Azure.ResourceManager.Sphere.Models.RegionalDataBoundary?), bool? hasDeployment = default(bool?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.DeviceInsight DeviceInsight(string deviceId = null, string description = null, System.DateTimeOffset startTimestampUtc = default(System.DateTimeOffset), System.DateTimeOffset endTimestampUtc = default(System.DateTimeOffset), string eventCategory = null, string eventClass = null, string eventType = null, int eventCount = 0) { throw null; } + public static Azure.ResourceManager.Sphere.ImageData ImageData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string image = null, string imageId = null, string imageName = null, Azure.ResourceManager.Sphere.Models.RegionalDataBoundary? regionalDataBoundary = default(Azure.ResourceManager.Sphere.Models.RegionalDataBoundary?), System.Uri uri = null, string description = null, string componentId = null, Azure.ResourceManager.Sphere.Models.ImageType? imageType = default(Azure.ResourceManager.Sphere.Models.ImageType?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.ProductData ProductData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, string description = null, Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.ProofOfPossessionNonceResponse ProofOfPossessionNonceResponse(string certificate = null, Azure.ResourceManager.Sphere.Models.CertificateStatus? status = default(Azure.ResourceManager.Sphere.Models.CertificateStatus?), string subject = null, string thumbprint = null, System.DateTimeOffset? expiryUtc = default(System.DateTimeOffset?), System.DateTimeOffset? notBeforeUtc = default(System.DateTimeOffset?), Azure.ResourceManager.Sphere.Models.ProvisioningState? provisioningState = default(Azure.ResourceManager.Sphere.Models.ProvisioningState?)) { throw null; } + public static Azure.ResourceManager.Sphere.Models.SignedCapabilityImageResponse SignedCapabilityImageResponse(string image = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CapabilityType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CapabilityType(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CapabilityType ApplicationDevelopment { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.CapabilityType FieldServicing { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.CapabilityType 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.Sphere.Models.CapabilityType left, Azure.ResourceManager.Sphere.Models.CapabilityType right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.CapabilityType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.CapabilityType left, Azure.ResourceManager.Sphere.Models.CapabilityType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class CatalogPatch + { + public CatalogPatch() { } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + } + public partial class CertificateChainResponse + { + internal CertificateChainResponse() { } + public string CertificateChain { get { throw null; } } + } + public partial class CertificateProperties + { + internal CertificateProperties() { } + public string Certificate { get { throw null; } } + public System.DateTimeOffset? ExpiryUtc { get { throw null; } } + public System.DateTimeOffset? NotBeforeUtc { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.ProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.Sphere.Models.CertificateStatus? Status { get { throw null; } } + public string Subject { get { throw null; } } + public string Thumbprint { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct CertificateStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public CertificateStatus(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.CertificateStatus Active { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.CertificateStatus Expired { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.CertificateStatus Inactive { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.CertificateStatus Revoked { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.CertificateStatus 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.Sphere.Models.CertificateStatus left, Azure.ResourceManager.Sphere.Models.CertificateStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.CertificateStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.CertificateStatus left, Azure.ResourceManager.Sphere.Models.CertificateStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ClaimDevicesContent + { + public ClaimDevicesContent(System.Collections.Generic.IEnumerable deviceIdentifiers) { } + public System.Collections.Generic.IList DeviceIdentifiers { get { throw null; } } + } + public partial class CountDeviceResponse : Azure.ResourceManager.Sphere.Models.CountElementsResponse + { + internal CountDeviceResponse() { } + } + public partial class CountElementsResponse + { + internal CountElementsResponse() { } + public int Value { get { throw null; } } + } + public partial class DeviceGroupPatch + { + public DeviceGroupPatch() { } + public Azure.ResourceManager.Sphere.Models.AllowCrashDumpCollection? AllowCrashDumpsCollection { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.OSFeedType? OSFeedType { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.RegionalDataBoundary? RegionalDataBoundary { get { throw null; } set { } } + public Azure.ResourceManager.Sphere.Models.UpdatePolicy? UpdatePolicy { get { throw null; } set { } } + } + public partial class DeviceInsight + { + internal DeviceInsight() { } + public string Description { get { throw null; } } + public string DeviceId { get { throw null; } } + public System.DateTimeOffset EndTimestampUtc { get { throw null; } } + public string EventCategory { get { throw null; } } + public string EventClass { get { throw null; } } + public int EventCount { get { throw null; } } + public string EventType { get { throw null; } } + public System.DateTimeOffset StartTimestampUtc { get { throw null; } } + } + public partial class DevicePatch + { + public DevicePatch() { } + public string DeviceGroupId { get { throw null; } set { } } + } + public partial class GenerateCapabilityImageContent + { + public GenerateCapabilityImageContent(System.Collections.Generic.IEnumerable capabilities) { } + public System.Collections.Generic.IList Capabilities { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ImageType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ImageType(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.ImageType Applications { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType BaseSystemUpdateManifest { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType BootManifest { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType CustomerBoardConfig { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType CustomerUpdateManifest { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType FirmwareUpdateManifest { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType FwConfig { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType InvalidImageType { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType ManifestSet { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType NormalWorldDtb { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType NormalWorldKernel { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType NormalWorldLoader { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType Nwfs { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType OneBl { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType Other { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType PlutonRuntime { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType Policy { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType RecoveryManifest { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType RootFs { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType SecurityMonitor { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType Services { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType TrustedKeystore { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType UpdateCertStore { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ImageType WifiFirmware { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.ImageType 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.Sphere.Models.ImageType left, Azure.ResourceManager.Sphere.Models.ImageType right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.ImageType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.ImageType left, Azure.ResourceManager.Sphere.Models.ImageType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ListDeviceGroupsContent + { + public ListDeviceGroupsContent() { } + public string DeviceGroupName { get { throw null; } set { } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OSFeedType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OSFeedType(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.OSFeedType Retail { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.OSFeedType RetailEval { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.OSFeedType 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.Sphere.Models.OSFeedType left, Azure.ResourceManager.Sphere.Models.OSFeedType right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.OSFeedType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.OSFeedType left, Azure.ResourceManager.Sphere.Models.OSFeedType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ProductPatch + { + public ProductPatch() { } + public string Description { get { throw null; } set { } } + } + public partial class ProofOfPossessionNonceContent + { + public ProofOfPossessionNonceContent(string proofOfPossessionNonce) { } + public string ProofOfPossessionNonce { get { throw null; } } + } + public partial class ProofOfPossessionNonceResponse : Azure.ResourceManager.Sphere.Models.CertificateProperties + { + internal ProofOfPossessionNonceResponse() { } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Accepted { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Deleting { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Provisioning { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Succeeded { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.ProvisioningState Updating { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.ProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.Sphere.Models.ProvisioningState left, Azure.ResourceManager.Sphere.Models.ProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.ProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.ProvisioningState left, Azure.ResourceManager.Sphere.Models.ProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RegionalDataBoundary : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RegionalDataBoundary(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.RegionalDataBoundary EU { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.RegionalDataBoundary None { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.RegionalDataBoundary 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.Sphere.Models.RegionalDataBoundary left, Azure.ResourceManager.Sphere.Models.RegionalDataBoundary right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.RegionalDataBoundary (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.RegionalDataBoundary left, Azure.ResourceManager.Sphere.Models.RegionalDataBoundary right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SignedCapabilityImageResponse + { + internal SignedCapabilityImageResponse() { } + public string Image { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct UpdatePolicy : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public UpdatePolicy(string value) { throw null; } + public static Azure.ResourceManager.Sphere.Models.UpdatePolicy No3RdPartyAppUpdates { get { throw null; } } + public static Azure.ResourceManager.Sphere.Models.UpdatePolicy UpdateAll { get { throw null; } } + public bool Equals(Azure.ResourceManager.Sphere.Models.UpdatePolicy 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.Sphere.Models.UpdatePolicy left, Azure.ResourceManager.Sphere.Models.UpdatePolicy right) { throw null; } + public static implicit operator Azure.ResourceManager.Sphere.Models.UpdatePolicy (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.Sphere.Models.UpdatePolicy left, Azure.ResourceManager.Sphere.Models.UpdatePolicy right) { throw null; } + public override string ToString() { throw null; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Azure.ResourceManager.Sphere.Samples.csproj b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Azure.ResourceManager.Sphere.Samples.csproj new file mode 100644 index 0000000000000..096809cffa53e --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Azure.ResourceManager.Sphere.Samples.csproj @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/autorest.tests.md b/sdk/sphere/Azure.ResourceManager.Sphere/samples/autorest.tests.md new file mode 100644 index 0000000000000..509dda31a7b61 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/autorest.tests.md @@ -0,0 +1,13 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateTests` to generate code. + +# Azure.ResourceManager.sphere.Tests + +> see https://aka.ms/autorest +``` yaml +require: ../src/autorest.md +include-x-ms-examples-original-file: true +testgen: + sample: true +``` \ No newline at end of file diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Azure.ResourceManager.Sphere.csproj b/sdk/sphere/Azure.ResourceManager.Sphere/src/Azure.ResourceManager.Sphere.csproj new file mode 100644 index 0000000000000..7c0b1c94e6ee2 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Azure.ResourceManager.Sphere.csproj @@ -0,0 +1,8 @@ + + + 1.0.0-beta.1 + Azure.ResourceManager.Sphere + Azure Resource Manager client SDK for Azure resource provider sphere. + azure;management;arm;resource manager;sphere + + diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ArmSphereModelFactory.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ArmSphereModelFactory.cs new file mode 100644 index 0000000000000..6c57d72968d5c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ArmSphereModelFactory.cs @@ -0,0 +1,237 @@ +// 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; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Model factory for models. + public static partial class ArmSphereModelFactory + { + /// Initializes a new instance of CatalogData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The status of the last operation. + /// A new instance for mocking. + public static CatalogData CatalogData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, ProvisioningState? provisioningState = null) + { + tags ??= new Dictionary(); + + return new CatalogData(id, name, resourceType, systemData, tags, location, provisioningState); + } + + /// Initializes a new instance of CertificateData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + /// A new instance for mocking. + public static CertificateData CertificateData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string certificate = null, CertificateStatus? status = null, string subject = null, string thumbprint = null, DateTimeOffset? expiryUtc = null, DateTimeOffset? notBeforeUtc = null, ProvisioningState? provisioningState = null) + { + return new CertificateData(id, name, resourceType, systemData, certificate, status, subject, thumbprint, expiryUtc, notBeforeUtc, provisioningState); + } + + /// Initializes a new instance of CertificateProperties. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + /// A new instance for mocking. + public static CertificateProperties CertificateProperties(string certificate = null, CertificateStatus? status = null, string subject = null, string thumbprint = null, DateTimeOffset? expiryUtc = null, DateTimeOffset? notBeforeUtc = null, ProvisioningState? provisioningState = null) + { + return new CertificateProperties(certificate, status, subject, thumbprint, expiryUtc, notBeforeUtc, provisioningState); + } + + /// Initializes a new instance of CertificateChainResponse. + /// The certificate chain. + /// A new instance for mocking. + public static CertificateChainResponse CertificateChainResponse(string certificateChain = null) + { + return new CertificateChainResponse(certificateChain); + } + + /// Initializes a new instance of ProofOfPossessionNonceResponse. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + /// A new instance for mocking. + public static ProofOfPossessionNonceResponse ProofOfPossessionNonceResponse(string certificate = null, CertificateStatus? status = null, string subject = null, string thumbprint = null, DateTimeOffset? expiryUtc = null, DateTimeOffset? notBeforeUtc = null, ProvisioningState? provisioningState = null) + { + return new ProofOfPossessionNonceResponse(certificate, status, subject, thumbprint, expiryUtc, notBeforeUtc, provisioningState); + } + + /// Initializes a new instance of CountDeviceResponse. + /// Number of children resources in parent resource. + /// A new instance for mocking. + public static CountDeviceResponse CountDeviceResponse(int value = default) + { + return new CountDeviceResponse(value); + } + + /// Initializes a new instance of CountElementsResponse. + /// Number of children resources in parent resource. + /// A new instance for mocking. + public static CountElementsResponse CountElementsResponse(int value = default) + { + return new CountElementsResponse(value); + } + + /// Initializes a new instance of ImageData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Image as a UTF-8 encoded base 64 string on image create. This field contains the image URI on image reads. + /// Image ID. + /// Image name. + /// Regional data boundary for an image. + /// Location the image. + /// The image description. + /// The image component id. + /// The image type. + /// The status of the last operation. + /// A new instance for mocking. + public static ImageData ImageData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string image = null, string imageId = null, string imageName = null, RegionalDataBoundary? regionalDataBoundary = null, Uri uri = null, string description = null, string componentId = null, ImageType? imageType = null, ProvisioningState? provisioningState = null) + { + return new ImageData(id, name, resourceType, systemData, image, imageId, imageName, regionalDataBoundary, uri, description, componentId, imageType, provisioningState); + } + + /// Initializes a new instance of DeploymentData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Deployment ID. + /// Images deployed. + /// Deployment date UTC. + /// The status of the last operation. + /// A new instance for mocking. + public static DeploymentData DeploymentData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string deploymentId = null, IEnumerable deployedImages = null, DateTimeOffset? deploymentDateUtc = null, ProvisioningState? provisioningState = null) + { + deployedImages ??= new List(); + + return new DeploymentData(id, name, resourceType, systemData, deploymentId, deployedImages?.ToList(), deploymentDateUtc, provisioningState); + } + + /// Initializes a new instance of DeviceGroupData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of the device group. + /// Operating system feed type of the device group. + /// Update policy of the device group. + /// Flag to define if the user allows for crash dump collection. + /// Regional data boundary for the device group. + /// Deployment status for the device group. + /// The status of the last operation. + /// A new instance for mocking. + public static DeviceGroupData DeviceGroupData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string description = null, OSFeedType? osFeedType = null, UpdatePolicy? updatePolicy = null, AllowCrashDumpCollection? allowCrashDumpsCollection = null, RegionalDataBoundary? regionalDataBoundary = null, bool? hasDeployment = null, ProvisioningState? provisioningState = null) + { + return new DeviceGroupData(id, name, resourceType, systemData, description, osFeedType, updatePolicy, allowCrashDumpsCollection, regionalDataBoundary, hasDeployment, provisioningState); + } + + /// Initializes a new instance of DeviceInsight. + /// Device ID. + /// Event description. + /// Event start timestamp. + /// Event end timestamp. + /// Event category. + /// Event class. + /// Event type. + /// Event count. + /// , , , or is null. + /// A new instance for mocking. + public static DeviceInsight DeviceInsight(string deviceId = null, string description = null, DateTimeOffset startTimestampUtc = default, DateTimeOffset endTimestampUtc = default, string eventCategory = null, string eventClass = null, string eventType = null, int eventCount = default) + { + if (deviceId == null) + { + throw new ArgumentNullException(nameof(deviceId)); + } + if (description == null) + { + throw new ArgumentNullException(nameof(description)); + } + if (eventCategory == null) + { + throw new ArgumentNullException(nameof(eventCategory)); + } + if (eventClass == null) + { + throw new ArgumentNullException(nameof(eventClass)); + } + if (eventType == null) + { + throw new ArgumentNullException(nameof(eventType)); + } + + return new DeviceInsight(deviceId, description, startTimestampUtc, endTimestampUtc, eventCategory, eventClass, eventType, eventCount); + } + + /// Initializes a new instance of DeviceData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Device ID. + /// SKU of the chip. + /// OS version available for installation when update requested. + /// OS version running on device when update requested. + /// Time when update requested and new OS version available. + /// Time when update was last requested. + /// The status of the last operation. + /// A new instance for mocking. + public static DeviceData DeviceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string deviceId = null, string chipSku = null, string lastAvailableOSVersion = null, string lastInstalledOSVersion = null, DateTimeOffset? lastOSUpdateUtc = null, DateTimeOffset? lastUpdateRequestUtc = null, ProvisioningState? provisioningState = null) + { + return new DeviceData(id, name, resourceType, systemData, deviceId, chipSku, lastAvailableOSVersion, lastInstalledOSVersion, lastOSUpdateUtc, lastUpdateRequestUtc, provisioningState); + } + + /// Initializes a new instance of ProductData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of the product. + /// The status of the last operation. + /// A new instance for mocking. + public static ProductData ProductData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string description = null, ProvisioningState? provisioningState = null) + { + return new ProductData(id, name, resourceType, systemData, description, provisioningState); + } + + /// Initializes a new instance of SignedCapabilityImageResponse. + /// The signed device capability image as a UTF-8 encoded base 64 string. + /// A new instance for mocking. + public static SignedCapabilityImageResponse SignedCapabilityImageResponse(string image = null) + { + return new SignedCapabilityImageResponse(image); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogCollection.cs new file mode 100644 index 0000000000000..91924c8350e45 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogCollection.cs @@ -0,0 +1,341 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetCatalogs method from an instance of . + /// + public partial class CatalogCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _catalogClientDiagnostics; + private readonly CatalogsRestOperations _catalogRestClient; + + /// Initializes a new instance of the class for mocking. + protected CatalogCollection() + { + } + + /// 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 CatalogCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _catalogClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", CatalogResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CatalogResource.ResourceType, out string catalogApiVersion); + _catalogRestClient = new CatalogsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, catalogApiVersion); +#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 Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_CreateOrUpdate + /// + /// + /// + /// 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 catalog. + /// 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 catalogName, CatalogData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _catalogRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, catalogName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new CatalogOperationSource(Client), _catalogClientDiagnostics, Pipeline, _catalogRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, catalogName, 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 Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_CreateOrUpdate + /// + /// + /// + /// 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 catalog. + /// 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 catalogName, CatalogData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _catalogRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, catalogName, data, cancellationToken); + var operation = new SphereArmOperation(new CatalogOperationSource(Client), _catalogClientDiagnostics, Pipeline, _catalogRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, catalogName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.Get"); + scope.Start(); + try + { + var response = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, catalogName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.Get"); + scope.Start(); + try + { + var response = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, catalogName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Catalog resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListByResourceGroup + /// + /// + /// + /// 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) => _catalogRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CatalogResource(Client, CatalogData.DeserializeCatalogData(e)), _catalogClientDiagnostics, Pipeline, "CatalogCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Catalog resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListByResourceGroup + /// + /// + /// + /// 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) => _catalogRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CatalogResource(Client, CatalogData.DeserializeCatalogData(e)), _catalogClientDiagnostics, Pipeline, "CatalogCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.Exists"); + scope.Start(); + try + { + var response = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, catalogName, 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.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogCollection.Exists"); + scope.Start(); + try + { + var response = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, catalogName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogData.cs new file mode 100644 index 0000000000000..0bb955b3edbe1 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Catalog data model. + /// An Azure Sphere catalog + /// + public partial class CatalogData : TrackedResourceData + { + /// Initializes a new instance of CatalogData. + /// The location. + public CatalogData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of CatalogData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The status of the last operation. + internal CatalogData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData, tags, location) + { + ProvisioningState = provisioningState; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogResource.cs new file mode 100644 index 0000000000000..ee69d613cb85e --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CatalogResource.cs @@ -0,0 +1,1037 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a Catalog 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 GetCatalogResource method. + /// Otherwise you can get one from its parent resource using the GetCatalog method. + /// + public partial class CatalogResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _catalogClientDiagnostics; + private readonly CatalogsRestOperations _catalogRestClient; + private readonly CatalogData _data; + + /// Initializes a new instance of the class for mocking. + protected CatalogResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CatalogResource(ArmClient client, CatalogData 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 CatalogResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _catalogClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string catalogApiVersion); + _catalogRestClient = new CatalogsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, catalogApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs"; + + /// 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 CatalogData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of CertificateResources in the Catalog. + /// An object representing collection of CertificateResources and their operations over a CertificateResource. + public virtual CertificateCollection GetCertificates() + { + return GetCachedClient(Client => new CertificateCollection(Client, Id)); + } + + /// + /// Get a Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetCertificateAsync(string serialNumber, CancellationToken cancellationToken = default) + { + return await GetCertificates().GetAsync(serialNumber, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetCertificate(string serialNumber, CancellationToken cancellationToken = default) + { + return GetCertificates().Get(serialNumber, cancellationToken); + } + + /// Gets a collection of ImageResources in the Catalog. + /// An object representing collection of ImageResources and their operations over a ImageResource. + public virtual ImageCollection GetImages() + { + return GetCachedClient(Client => new ImageCollection(Client, Id)); + } + + /// + /// Get a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetImageAsync(string imageName, CancellationToken cancellationToken = default) + { + return await GetImages().GetAsync(imageName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetImage(string imageName, CancellationToken cancellationToken = default) + { + return GetImages().Get(imageName, cancellationToken); + } + + /// Gets a collection of ProductResources in the Catalog. + /// An object representing collection of ProductResources and their operations over a ProductResource. + public virtual ProductCollection GetProducts() + { + return GetCachedClient(Client => new ProductCollection(Client, Id)); + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetProductAsync(string productName, CancellationToken cancellationToken = default) + { + return await GetProducts().GetAsync(productName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetProduct(string productName, CancellationToken cancellationToken = default) + { + return GetProducts().Get(productName, cancellationToken); + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.Get"); + scope.Start(); + try + { + var response = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.Get"); + scope.Start(); + try + { + var response = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Delete + /// + /// + /// + /// 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 = _catalogClientDiagnostics.CreateScope("CatalogResource.Delete"); + scope.Start(); + try + { + var response = await _catalogRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_catalogClientDiagnostics, Pipeline, _catalogRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Delete + /// + /// + /// + /// 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 = _catalogClientDiagnostics.CreateScope("CatalogResource.Delete"); + scope.Start(); + try + { + var response = _catalogRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_catalogClientDiagnostics, Pipeline, _catalogRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(CatalogPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.Update"); + scope.Start(); + try + { + var response = await _catalogRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Update + /// + /// + /// + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual Response Update(CatalogPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.Update"); + scope.Start(); + try + { + var response = _catalogRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new CatalogResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/countDevices + /// + /// + /// Operation Id + /// Catalogs_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> CountDevicesAsync(CancellationToken cancellationToken = default) + { + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.CountDevices"); + scope.Start(); + try + { + var response = await _catalogRestClient.CountDevicesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/countDevices + /// + /// + /// Operation Id + /// Catalogs_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual Response CountDevices(CancellationToken cancellationToken = default) + { + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.CountDevices"); + scope.Start(); + try + { + var response = _catalogRestClient.CountDevices(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists deployments for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeployments + /// + /// + /// Operation Id + /// Catalogs_ListDeployments + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDeploymentsAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeploymentsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeploymentsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeploymentResource(Client, DeploymentData.DeserializeDeploymentData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeployments", "value", "nextLink", cancellationToken); + } + + /// + /// Lists deployments for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeployments + /// + /// + /// Operation Id + /// Catalogs_ListDeployments + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetDeployments(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeploymentsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeploymentsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeploymentResource(Client, DeploymentData.DeserializeDeploymentData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeployments", "value", "nextLink", cancellationToken); + } + + /// + /// List the device groups for the catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceGroups + /// + /// + /// Operation Id + /// Catalogs_ListDeviceGroups + /// + /// + /// + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDeviceGroupsAsync(ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeviceGroupsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeviceGroupsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeviceGroups", "value", "nextLink", cancellationToken); + } + + /// + /// List the device groups for the catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceGroups + /// + /// + /// Operation Id + /// Catalogs_ListDeviceGroups + /// + /// + /// + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetDeviceGroups(ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeviceGroupsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeviceGroupsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeviceGroups", "value", "nextLink", cancellationToken); + } + + /// + /// Lists device insights for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceInsights + /// + /// + /// Operation Id + /// Catalogs_ListDeviceInsights + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDeviceInsightsAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeviceInsightsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeviceInsightsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, DeviceInsight.DeserializeDeviceInsight, _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeviceInsights", "value", "nextLink", cancellationToken); + } + + /// + /// Lists device insights for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDeviceInsights + /// + /// + /// Operation Id + /// Catalogs_ListDeviceInsights + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetDeviceInsights(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDeviceInsightsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDeviceInsightsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, DeviceInsight.DeserializeDeviceInsight, _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDeviceInsights", "value", "nextLink", cancellationToken); + } + + /// + /// Lists devices for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDevices + /// + /// + /// Operation Id + /// Catalogs_ListDevices + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetDevicesAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDevicesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDevicesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceResource(Client, DeviceData.DeserializeDeviceData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDevices", "value", "nextLink", cancellationToken); + } + + /// + /// Lists devices for catalog. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/listDevices + /// + /// + /// Operation Id + /// Catalogs_ListDevices + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetDevices(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _catalogRestClient.CreateListDevicesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _catalogRestClient.CreateListDevicesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceResource(Client, DeviceData.DeserializeDeviceData(e)), _catalogClientDiagnostics, Pipeline, "CatalogResource.GetDevices", "value", "nextLink", cancellationToken); + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CatalogPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CatalogPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CatalogPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CatalogPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _catalogRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new CatalogPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _catalogClientDiagnostics.CreateScope("CatalogResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _catalogRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new CatalogResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new CatalogPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(patch, cancellationToken: cancellationToken); + return result; + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateCollection.cs new file mode 100644 index 0000000000000..001df66c9fcee --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateCollection.cs @@ -0,0 +1,266 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetCertificates method from an instance of . + /// + public partial class CertificateCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _certificateClientDiagnostics; + private readonly CertificatesRestOperations _certificateRestClient; + + /// Initializes a new instance of the class for mocking. + protected CertificateCollection() + { + } + + /// 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 CertificateCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _certificateClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", CertificateResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(CertificateResource.ResourceType, out string certificateApiVersion); + _certificateRestClient = new CertificatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, certificateApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CatalogResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CatalogResource.ResourceType), nameof(id)); + } + + /// + /// Get a Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateCollection.Get"); + scope.Start(); + try + { + var response = await _certificateRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serialNumber, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CertificateResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateCollection.Get"); + scope.Start(); + try + { + var response = _certificateRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serialNumber, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CertificateResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Certificate resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates + /// + /// + /// Operation Id + /// Certificates_ListByCatalog + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _certificateRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _certificateRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CertificateResource(Client, CertificateData.DeserializeCertificateData(e)), _certificateClientDiagnostics, Pipeline, "CertificateCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Certificate resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates + /// + /// + /// Operation Id + /// Certificates_ListByCatalog + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _certificateRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _certificateRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CertificateResource(Client, CertificateData.DeserializeCertificateData(e)), _certificateClientDiagnostics, Pipeline, "CertificateCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateCollection.Exists"); + scope.Start(); + try + { + var response = await _certificateRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serialNumber, 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.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateCollection.Exists"); + scope.Start(); + try + { + var response = _certificateRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, serialNumber, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateData.cs new file mode 100644 index 0000000000000..c9a87e7f3952b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateData.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Certificate data model. + /// An certificate resource belonging to a catalog resource. + /// + public partial class CertificateData : ResourceData + { + /// Initializes a new instance of CertificateData. + public CertificateData() + { + } + + /// Initializes a new instance of CertificateData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + internal CertificateData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string certificate, CertificateStatus? status, string subject, string thumbprint, DateTimeOffset? expiryUtc, DateTimeOffset? notBeforeUtc, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + Certificate = certificate; + Status = status; + Subject = subject; + Thumbprint = thumbprint; + ExpiryUtc = expiryUtc; + NotBeforeUtc = notBeforeUtc; + ProvisioningState = provisioningState; + } + + /// The certificate as a UTF-8 encoded base 64 string. + public string Certificate { get; } + /// The certificate status. + public CertificateStatus? Status { get; } + /// The certificate subject. + public string Subject { get; } + /// The certificate thumbprint. + public string Thumbprint { get; } + /// The certificate expiry date. + public DateTimeOffset? ExpiryUtc { get; } + /// The certificate not before date. + public DateTimeOffset? NotBeforeUtc { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateResource.cs new file mode 100644 index 0000000000000..85a87801bdb73 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/CertificateResource.cs @@ -0,0 +1,282 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a Certificate 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 GetCertificateResource method. + /// Otherwise you can get one from its parent resource using the GetCertificate method. + /// + public partial class CertificateResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _certificateClientDiagnostics; + private readonly CertificatesRestOperations _certificateRestClient; + private readonly CertificateData _data; + + /// Initializes a new instance of the class for mocking. + protected CertificateResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal CertificateResource(ArmClient client, CertificateData 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 CertificateResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _certificateClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string certificateApiVersion); + _certificateRestClient = new CertificatesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, certificateApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/certificates"; + + /// 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 CertificateData 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 Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.Get"); + scope.Start(); + try + { + var response = await _certificateRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CertificateResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Certificate + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber} + /// + /// + /// Operation Id + /// Certificates_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.Get"); + scope.Start(); + try + { + var response = _certificateRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new CertificateResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Retrieves cert chain. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveCertChain + /// + /// + /// Operation Id + /// Certificates_RetrieveCertChain + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> RetrieveCertChainAsync(CancellationToken cancellationToken = default) + { + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.RetrieveCertChain"); + scope.Start(); + try + { + var response = await _certificateRestClient.RetrieveCertChainAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Retrieves cert chain. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveCertChain + /// + /// + /// Operation Id + /// Certificates_RetrieveCertChain + /// + /// + /// + /// The cancellation token to use. + public virtual Response RetrieveCertChain(CancellationToken cancellationToken = default) + { + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.RetrieveCertChain"); + scope.Start(); + try + { + var response = _certificateRestClient.RetrieveCertChain(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the proof of possession nonce. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveProofOfPossessionNonce + /// + /// + /// Operation Id + /// Certificates_RetrieveProofOfPossessionNonce + /// + /// + /// + /// Proof of possession nonce request body. + /// The cancellation token to use. + /// is null. + public virtual async Task> RetrieveProofOfPossessionNonceAsync(ProofOfPossessionNonceContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.RetrieveProofOfPossessionNonce"); + scope.Start(); + try + { + var response = await _certificateRestClient.RetrieveProofOfPossessionNonceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the proof of possession nonce. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/certificates/{serialNumber}/retrieveProofOfPossessionNonce + /// + /// + /// Operation Id + /// Certificates_RetrieveProofOfPossessionNonce + /// + /// + /// + /// Proof of possession nonce request body. + /// The cancellation token to use. + /// is null. + public virtual Response RetrieveProofOfPossessionNonce(ProofOfPossessionNonceContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _certificateClientDiagnostics.CreateScope("CertificateResource.RetrieveProofOfPossessionNonce"); + scope.Start(); + try + { + var response = _certificateRestClient.RetrieveProofOfPossessionNonce(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentCollection.cs new file mode 100644 index 0000000000000..5990df4020af3 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentCollection.cs @@ -0,0 +1,348 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetDeployments method from an instance of . + /// + public partial class DeploymentCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _deploymentClientDiagnostics; + private readonly DeploymentsRestOperations _deploymentRestClient; + + /// Initializes a new instance of the class for mocking. + protected DeploymentCollection() + { + } + + /// 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 DeploymentCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deploymentClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", DeploymentResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DeploymentResource.ResourceType, out string deploymentApiVersion); + _deploymentRestClient = new DeploymentsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deploymentApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != DeviceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DeviceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_CreateOrUpdate + /// + /// + /// + /// 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. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 deploymentName, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _deploymentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeploymentOperationSource(Client), _deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, 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 Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_CreateOrUpdate + /// + /// + /// + /// 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. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 deploymentName, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _deploymentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, data, cancellationToken); + var operation = new SphereArmOperation(new DeploymentOperationSource(Client), _deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.Get"); + scope.Start(); + try + { + var response = await _deploymentRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.Get"); + scope.Start(); + try + { + var response = _deploymentRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments + /// + /// + /// Operation Id + /// Deployments_ListByDeviceGroup + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _deploymentRestClient.CreateListByDeviceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deploymentRestClient.CreateListByDeviceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeploymentResource(Client, DeploymentData.DeserializeDeploymentData(e)), _deploymentClientDiagnostics, Pipeline, "DeploymentCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments + /// + /// + /// Operation Id + /// Deployments_ListByDeviceGroup + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _deploymentRestClient.CreateListByDeviceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deploymentRestClient.CreateListByDeviceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeploymentResource(Client, DeploymentData.DeserializeDeploymentData(e)), _deploymentClientDiagnostics, Pipeline, "DeploymentCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.Exists"); + scope.Start(); + try + { + var response = await _deploymentRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, 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.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentCollection.Exists"); + scope.Start(); + try + { + var response = _deploymentRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deploymentName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentData.cs new file mode 100644 index 0000000000000..4baba9da5167b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentData.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Deployment data model. + /// An deployment resource belonging to a device group resource. + /// + public partial class DeploymentData : ResourceData + { + /// Initializes a new instance of DeploymentData. + public DeploymentData() + { + DeployedImages = new ChangeTrackingList(); + } + + /// Initializes a new instance of DeploymentData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Deployment ID. + /// Images deployed. + /// Deployment date UTC. + /// The status of the last operation. + internal DeploymentData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string deploymentId, IList deployedImages, DateTimeOffset? deploymentDateUtc, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + DeploymentId = deploymentId; + DeployedImages = deployedImages; + DeploymentDateUtc = deploymentDateUtc; + ProvisioningState = provisioningState; + } + + /// Deployment ID. + public string DeploymentId { get; set; } + /// Images deployed. + public IList DeployedImages { get; } + /// Deployment date UTC. + public DateTimeOffset? DeploymentDateUtc { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentResource.cs new file mode 100644 index 0000000000000..23ef35e7d50a5 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeploymentResource.cs @@ -0,0 +1,297 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a Deployment 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 GetDeploymentResource method. + /// Otherwise you can get one from its parent resource using the GetDeployment method. + /// + public partial class DeploymentResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deploymentName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _deploymentClientDiagnostics; + private readonly DeploymentsRestOperations _deploymentRestClient; + private readonly DeploymentData _data; + + /// Initializes a new instance of the class for mocking. + protected DeploymentResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DeploymentResource(ArmClient client, DeploymentData 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 DeploymentResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deploymentClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string deploymentApiVersion); + _deploymentRestClient = new DeploymentsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deploymentApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/products/deviceGroups/deployments"; + + /// 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 DeploymentData 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 Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Get"); + scope.Start(); + try + { + var response = await _deploymentRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Get"); + scope.Start(); + try + { + var response = _deploymentRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeploymentResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Delete + /// + /// + /// + /// 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 = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Delete"); + scope.Start(); + try + { + var response = await _deploymentRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Delete + /// + /// + /// + /// 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 = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Delete"); + scope.Start(); + try + { + var response = _deploymentRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_CreateOrUpdate + /// + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Update"); + scope.Start(); + try + { + var response = await _deploymentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeploymentOperationSource(Client), _deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, 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 Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_CreateOrUpdate + /// + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deploymentClientDiagnostics.CreateScope("DeploymentResource.Update"); + scope.Start(); + try + { + var response = _deploymentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new SphereArmOperation(new DeploymentOperationSource(Client), _deploymentClientDiagnostics, Pipeline, _deploymentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceCollection.cs new file mode 100644 index 0000000000000..f1de477a3f740 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceCollection.cs @@ -0,0 +1,340 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetDevices method from an instance of . + /// + public partial class DeviceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _deviceClientDiagnostics; + private readonly DevicesRestOperations _deviceRestClient; + + /// Initializes a new instance of the class for mocking. + protected DeviceCollection() + { + } + + /// 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 DeviceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deviceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", DeviceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DeviceResource.ResourceType, out string deviceApiVersion); + _deviceRestClient = new DevicesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != DeviceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DeviceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a Device. Use '.unassigned' or '.default' for the device group and product names to claim a device to the catalog only. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_CreateOrUpdate + /// + /// + /// + /// 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. + /// Device name. + /// 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 deviceName, DeviceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _deviceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeviceOperationSource(Client), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, 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 Device. Use '.unassigned' or '.default' for the device group and product names to claim a device to the catalog only. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_CreateOrUpdate + /// + /// + /// + /// 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. + /// Device name. + /// 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 deviceName, DeviceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _deviceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, data, cancellationToken); + var operation = new SphereArmOperation(new DeviceOperationSource(Client), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.Get"); + scope.Start(); + try + { + var response = await _deviceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.Get"); + scope.Start(); + try + { + var response = _deviceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices + /// + /// + /// Operation Id + /// Devices_ListByDeviceGroup + /// + /// + /// + /// 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) => _deviceRestClient.CreateListByDeviceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceRestClient.CreateListByDeviceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceResource(Client, DeviceData.DeserializeDeviceData(e)), _deviceClientDiagnostics, Pipeline, "DeviceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices + /// + /// + /// Operation Id + /// Devices_ListByDeviceGroup + /// + /// + /// + /// 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) => _deviceRestClient.CreateListByDeviceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceRestClient.CreateListByDeviceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceResource(Client, DeviceData.DeserializeDeviceData(e)), _deviceClientDiagnostics, Pipeline, "DeviceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.Exists"); + scope.Start(); + try + { + var response = await _deviceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, 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.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceCollection.Exists"); + scope.Start(); + try + { + var response = _deviceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, deviceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceData.cs new file mode 100644 index 0000000000000..3002e5268f4de --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceData.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Device data model. + /// An device resource belonging to a device group resource. + /// + public partial class DeviceData : ResourceData + { + /// Initializes a new instance of DeviceData. + public DeviceData() + { + } + + /// Initializes a new instance of DeviceData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Device ID. + /// SKU of the chip. + /// OS version available for installation when update requested. + /// OS version running on device when update requested. + /// Time when update requested and new OS version available. + /// Time when update was last requested. + /// The status of the last operation. + internal DeviceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string deviceId, string chipSku, string lastAvailableOSVersion, string lastInstalledOSVersion, DateTimeOffset? lastOSUpdateUtc, DateTimeOffset? lastUpdateRequestUtc, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + DeviceId = deviceId; + ChipSku = chipSku; + LastAvailableOSVersion = lastAvailableOSVersion; + LastInstalledOSVersion = lastInstalledOSVersion; + LastOSUpdateUtc = lastOSUpdateUtc; + LastUpdateRequestUtc = lastUpdateRequestUtc; + ProvisioningState = provisioningState; + } + + /// Device ID. + public string DeviceId { get; set; } + /// SKU of the chip. + public string ChipSku { get; } + /// OS version available for installation when update requested. + public string LastAvailableOSVersion { get; } + /// OS version running on device when update requested. + public string LastInstalledOSVersion { get; } + /// Time when update requested and new OS version available. + public DateTimeOffset? LastOSUpdateUtc { get; } + /// Time when update was last requested. + public DateTimeOffset? LastUpdateRequestUtc { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupCollection.cs new file mode 100644 index 0000000000000..3f75c5264d5d3 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupCollection.cs @@ -0,0 +1,348 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetDeviceGroups method from an instance of . + /// + public partial class DeviceGroupCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _deviceGroupClientDiagnostics; + private readonly DeviceGroupsRestOperations _deviceGroupRestClient; + + /// Initializes a new instance of the class for mocking. + protected DeviceGroupCollection() + { + } + + /// 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 DeviceGroupCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deviceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", DeviceGroupResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(DeviceGroupResource.ResourceType, out string deviceGroupApiVersion); + _deviceGroupRestClient = new DeviceGroupsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceGroupApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ProductResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ProductResource.ResourceType), nameof(id)); + } + + /// + /// Create a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_CreateOrUpdate + /// + /// + /// + /// 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 device group. + /// 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 deviceGroupName, DeviceGroupData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeviceGroupOperationSource(Client), _deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, 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 DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_CreateOrUpdate + /// + /// + /// + /// 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 device group. + /// 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 deviceGroupName, DeviceGroupData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, data, cancellationToken); + var operation = new SphereArmOperation(new DeviceGroupOperationSource(Client), _deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.Get"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceGroupResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.Get"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceGroupResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups + /// + /// + /// Operation Id + /// DeviceGroups_ListByProduct + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceGroupRestClient.CreateListByProductRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceGroupRestClient.CreateListByProductNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _deviceGroupClientDiagnostics, Pipeline, "DeviceGroupCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups + /// + /// + /// Operation Id + /// DeviceGroups_ListByProduct + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _deviceGroupRestClient.CreateListByProductRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _deviceGroupRestClient.CreateListByProductNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _deviceGroupClientDiagnostics, Pipeline, "DeviceGroupCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.Exists"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, 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.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupCollection.Exists"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, deviceGroupName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupData.cs new file mode 100644 index 0000000000000..9a1c938011600 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupData.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the DeviceGroup data model. + /// An device group resource belonging to a product resource. + /// + public partial class DeviceGroupData : ResourceData + { + /// Initializes a new instance of DeviceGroupData. + public DeviceGroupData() + { + } + + /// Initializes a new instance of DeviceGroupData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of the device group. + /// Operating system feed type of the device group. + /// Update policy of the device group. + /// Flag to define if the user allows for crash dump collection. + /// Regional data boundary for the device group. + /// Deployment status for the device group. + /// The status of the last operation. + internal DeviceGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string description, OSFeedType? osFeedType, UpdatePolicy? updatePolicy, AllowCrashDumpCollection? allowCrashDumpsCollection, RegionalDataBoundary? regionalDataBoundary, bool? hasDeployment, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + Description = description; + OSFeedType = osFeedType; + UpdatePolicy = updatePolicy; + AllowCrashDumpsCollection = allowCrashDumpsCollection; + RegionalDataBoundary = regionalDataBoundary; + HasDeployment = hasDeployment; + ProvisioningState = provisioningState; + } + + /// Description of the device group. + public string Description { get; set; } + /// Operating system feed type of the device group. + public OSFeedType? OSFeedType { get; set; } + /// Update policy of the device group. + public UpdatePolicy? UpdatePolicy { get; set; } + /// Flag to define if the user allows for crash dump collection. + public AllowCrashDumpCollection? AllowCrashDumpsCollection { get; set; } + /// Regional data boundary for the device group. + public RegionalDataBoundary? RegionalDataBoundary { get; set; } + /// Deployment status for the device group. + public bool? HasDeployment { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupResource.cs new file mode 100644 index 0000000000000..8a52e3fa161c8 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceGroupResource.cs @@ -0,0 +1,540 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a DeviceGroup 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 GetDeviceGroupResource method. + /// Otherwise you can get one from its parent resource using the GetDeviceGroup method. + /// + public partial class DeviceGroupResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _deviceGroupClientDiagnostics; + private readonly DeviceGroupsRestOperations _deviceGroupRestClient; + private readonly DeviceGroupData _data; + + /// Initializes a new instance of the class for mocking. + protected DeviceGroupResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DeviceGroupResource(ArmClient client, DeviceGroupData 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 DeviceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deviceGroupClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string deviceGroupApiVersion); + _deviceGroupRestClient = new DeviceGroupsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceGroupApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/products/deviceGroups"; + + /// 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 DeviceGroupData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of DeploymentResources in the DeviceGroup. + /// An object representing collection of DeploymentResources and their operations over a DeploymentResource. + public virtual DeploymentCollection GetDeployments() + { + return GetCachedClient(Client => new DeploymentCollection(Client, Id)); + } + + /// + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetDeploymentAsync(string deploymentName, CancellationToken cancellationToken = default) + { + return await GetDeployments().GetAsync(deploymentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/deployments/{deploymentName} + /// + /// + /// Operation Id + /// Deployments_Get + /// + /// + /// + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetDeployment(string deploymentName, CancellationToken cancellationToken = default) + { + return GetDeployments().Get(deploymentName, cancellationToken); + } + + /// Gets a collection of DeviceResources in the DeviceGroup. + /// An object representing collection of DeviceResources and their operations over a DeviceResource. + public virtual DeviceCollection GetDevices() + { + return GetCachedClient(Client => new DeviceCollection(Client, Id)); + } + + /// + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetDeviceAsync(string deviceName, CancellationToken cancellationToken = default) + { + return await GetDevices().GetAsync(deviceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// Device name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetDevice(string deviceName, CancellationToken cancellationToken = default) + { + return GetDevices().Get(deviceName, cancellationToken); + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Get"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceGroupResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Get"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceGroupResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Delete + /// + /// + /// + /// 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 = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Delete"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Delete + /// + /// + /// + /// 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 = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Delete"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DeviceGroupPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Update"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeviceGroupOperationSource(Client), _deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DeviceGroupPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.Update"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new SphereArmOperation(new DeviceGroupOperationSource(Client), _deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when bulk claiming devices to a catalog only. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/claimDevices + /// + /// + /// Operation Id + /// DeviceGroups_ClaimDevices + /// + /// + /// + /// 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. + /// Bulk claim devices request body. + /// The cancellation token to use. + /// is null. + public virtual async Task ClaimDevicesAsync(WaitUntil waitUntil, ClaimDevicesContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.ClaimDevices"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.ClaimDevicesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateClaimDevicesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when bulk claiming devices to a catalog only. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/claimDevices + /// + /// + /// Operation Id + /// DeviceGroups_ClaimDevices + /// + /// + /// + /// 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. + /// Bulk claim devices request body. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation ClaimDevices(WaitUntil waitUntil, ClaimDevicesContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.ClaimDevices"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.ClaimDevices(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content, cancellationToken); + var operation = new SphereArmOperation(_deviceGroupClientDiagnostics, Pipeline, _deviceGroupRestClient.CreateClaimDevicesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in device group. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/countDevices + /// + /// + /// Operation Id + /// DeviceGroups_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> CountDevicesAsync(CancellationToken cancellationToken = default) + { + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.CountDevices"); + scope.Start(); + try + { + var response = await _deviceGroupRestClient.CountDevicesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in device group. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/countDevices + /// + /// + /// Operation Id + /// DeviceGroups_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual Response CountDevices(CancellationToken cancellationToken = default) + { + using var scope = _deviceGroupClientDiagnostics.CreateScope("DeviceGroupResource.CountDevices"); + scope.Start(); + try + { + var response = _deviceGroupRestClient.CountDevices(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceResource.cs new file mode 100644 index 0000000000000..fb18f0ac46305 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/DeviceResource.cs @@ -0,0 +1,374 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a Device 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 GetDeviceResource method. + /// Otherwise you can get one from its parent resource using the GetDevice method. + /// + public partial class DeviceResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _deviceClientDiagnostics; + private readonly DevicesRestOperations _deviceRestClient; + private readonly DeviceData _data; + + /// Initializes a new instance of the class for mocking. + protected DeviceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DeviceResource(ArmClient client, DeviceData 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 DeviceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _deviceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string deviceApiVersion); + _deviceRestClient = new DevicesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, deviceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/products/deviceGroups/devices"; + + /// 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 DeviceData 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 Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.Get"); + scope.Start(); + try + { + var response = await _deviceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.Get"); + scope.Start(); + try + { + var response = _deviceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DeviceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Device + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Delete + /// + /// + /// + /// 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 = _deviceClientDiagnostics.CreateScope("DeviceResource.Delete"); + scope.Start(); + try + { + var response = await _deviceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Device + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Delete + /// + /// + /// + /// 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 = _deviceClientDiagnostics.CreateScope("DeviceResource.Delete"); + scope.Start(); + try + { + var response = _deviceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device to the catalog level. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DevicePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.Update"); + scope.Start(); + try + { + var response = await _deviceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new DeviceOperationSource(Client), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device to the catalog level. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName} + /// + /// + /// Operation Id + /// Devices_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DevicePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.Update"); + scope.Start(); + try + { + var response = _deviceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new SphereArmOperation(new DeviceOperationSource(Client), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Generates the capability image for the device. Use '.unassigned' or '.default' for the device group and product names to generate the image for a device that does not belong to a specific device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}/generateCapabilityImage + /// + /// + /// Operation Id + /// Devices_GenerateCapabilityImage + /// + /// + /// + /// 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. + /// Generate capability image request body. + /// The cancellation token to use. + /// is null. + public virtual async Task> GenerateCapabilityImageAsync(WaitUntil waitUntil, GenerateCapabilityImageContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.GenerateCapabilityImage"); + scope.Start(); + try + { + var response = await _deviceRestClient.GenerateCapabilityImageAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new SignedCapabilityImageResponseOperationSource(), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateGenerateCapabilityImageRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Generates the capability image for the device. Use '.unassigned' or '.default' for the device group and product names to generate the image for a device that does not belong to a specific device group and product. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName}/devices/{deviceName}/generateCapabilityImage + /// + /// + /// Operation Id + /// Devices_GenerateCapabilityImage + /// + /// + /// + /// 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. + /// Generate capability image request body. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation GenerateCapabilityImage(WaitUntil waitUntil, GenerateCapabilityImageContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _deviceClientDiagnostics.CreateScope("DeviceResource.GenerateCapabilityImage"); + scope.Start(); + try + { + var response = _deviceRestClient.GenerateCapabilityImage(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content, cancellationToken); + var operation = new SphereArmOperation(new SignedCapabilityImageResponseOperationSource(), _deviceClientDiagnostics, Pipeline, _deviceRestClient.CreateGenerateCapabilityImageRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Parent.Name, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs new file mode 100644 index 0000000000000..7d681f9f3e5b8 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/ResourceGroupResourceExtensionClient.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// A class to add extension methods to ResourceGroupResource. + internal partial class ResourceGroupResourceExtensionClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected ResourceGroupResourceExtensionClient() + { + } + + /// 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 ResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of CatalogResources in the ResourceGroupResource. + /// An object representing collection of CatalogResources and their operations over a CatalogResource. + public virtual CatalogCollection GetCatalogs() + { + return GetCachedClient(Client => new CatalogCollection(Client, Id)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SphereExtensions.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SphereExtensions.cs new file mode 100644 index 0000000000000..ba28fe71b28f9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SphereExtensions.cs @@ -0,0 +1,283 @@ +// 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; +using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Sphere +{ + /// A class to add extension methods to Azure.ResourceManager.Sphere. + public static partial class SphereExtensions + { + private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmResource resource) + { + return resource.GetCachedClient(client => + { + return new ResourceGroupResourceExtensionClient(client, resource.Id); + }); + } + + private static ResourceGroupResourceExtensionClient GetResourceGroupResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + { + return client.GetResourceClient(() => + { + return new ResourceGroupResourceExtensionClient(client, scope); + }); + } + + private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmResource resource) + { + return resource.GetCachedClient(client => + { + return new SubscriptionResourceExtensionClient(client, resource.Id); + }); + } + + private static SubscriptionResourceExtensionClient GetSubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier scope) + { + return client.GetResourceClient(() => + { + return new SubscriptionResourceExtensionClient(client, scope); + }); + } + #region CatalogResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static CatalogResource GetCatalogResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + CatalogResource.ValidateResourceId(id); + return new CatalogResource(client, id); + } + ); + } + #endregion + + #region CertificateResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static CertificateResource GetCertificateResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + CertificateResource.ValidateResourceId(id); + return new CertificateResource(client, id); + } + ); + } + #endregion + + #region ImageResource + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ImageResource GetImageResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + ImageResource.ValidateResourceId(id); + return new ImageResource(client, id); + } + ); + } + #endregion + + #region ProductResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ProductResource GetProductResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + ProductResource.ValidateResourceId(id); + return new ProductResource(client, id); + } + ); + } + #endregion + + #region DeviceGroupResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static DeviceGroupResource GetDeviceGroupResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + DeviceGroupResource.ValidateResourceId(id); + return new DeviceGroupResource(client, id); + } + ); + } + #endregion + + #region DeploymentResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static DeploymentResource GetDeploymentResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + DeploymentResource.ValidateResourceId(id); + return new DeploymentResource(client, id); + } + ); + } + #endregion + + #region DeviceResource + /// + /// 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 instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static DeviceResource GetDeviceResource(this ArmClient client, ResourceIdentifier id) + { + return client.GetResourceClient(() => + { + DeviceResource.ValidateResourceId(id); + return new DeviceResource(client, id); + } + ); + } + #endregion + + /// Gets a collection of CatalogResources in the ResourceGroupResource. + /// The instance the method will execute against. + /// An object representing collection of CatalogResources and their operations over a CatalogResource. + public static CatalogCollection GetCatalogs(this ResourceGroupResource resourceGroupResource) + { + return GetResourceGroupResourceExtensionClient(resourceGroupResource).GetCatalogs(); + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The instance the method will execute against. + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static async Task> GetCatalogAsync(this ResourceGroupResource resourceGroupResource, string catalogName, CancellationToken cancellationToken = default) + { + return await resourceGroupResource.GetCatalogs().GetAsync(catalogName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName} + /// + /// + /// Operation Id + /// Catalogs_Get + /// + /// + /// + /// The instance the method will execute against. + /// Name of catalog. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public static Response GetCatalog(this ResourceGroupResource resourceGroupResource, string catalogName, CancellationToken cancellationToken = default) + { + return resourceGroupResource.GetCatalogs().Get(catalogName, cancellationToken); + } + + /// + /// List Catalog resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetCatalogsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetSubscriptionResourceExtensionClient(subscriptionResource).GetCatalogsAsync(cancellationToken); + } + + /// + /// List Catalog resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListBySubscription + /// + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetCatalogs(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + return GetSubscriptionResourceExtensionClient(subscriptionResource).GetCatalogs(cancellationToken); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs new file mode 100644 index 0000000000000..a2617db199228 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Extensions/SubscriptionResourceExtensionClient.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// A class to add extension methods to SubscriptionResource. + internal partial class SubscriptionResourceExtensionClient : ArmResource + { + private ClientDiagnostics _catalogClientDiagnostics; + private CatalogsRestOperations _catalogRestClient; + + /// Initializes a new instance of the class for mocking. + protected SubscriptionResourceExtensionClient() + { + } + + /// 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 SubscriptionResourceExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics CatalogClientDiagnostics => _catalogClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Sphere", CatalogResource.ResourceType.Namespace, Diagnostics); + private CatalogsRestOperations CatalogRestClient => _catalogRestClient ??= new CatalogsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(CatalogResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List Catalog resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetCatalogsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CatalogRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CatalogRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new CatalogResource(Client, CatalogData.DeserializeCatalogData(e)), CatalogClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetCatalogs", "value", "nextLink", cancellationToken); + } + + /// + /// List Catalog resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureSphere/catalogs + /// + /// + /// Operation Id + /// Catalogs_ListBySubscription + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetCatalogs(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CatalogRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CatalogRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new CatalogResource(Client, CatalogData.DeserializeCatalogData(e)), CatalogClientDiagnostics, Pipeline, "SubscriptionResourceExtensionClient.GetCatalogs", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageCollection.cs new file mode 100644 index 0000000000000..732b0491d9ebb --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageCollection.cs @@ -0,0 +1,348 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetImages method from an instance of . + /// + public partial class ImageCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _imageClientDiagnostics; + private readonly ImagesRestOperations _imageRestClient; + + /// Initializes a new instance of the class for mocking. + protected ImageCollection() + { + } + + /// 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 ImageCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _imageClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ImageResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ImageResource.ResourceType, out string imageApiVersion); + _imageRestClient = new ImagesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, imageApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CatalogResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CatalogResource.ResourceType), nameof(id)); + } + + /// + /// Create a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_CreateOrUpdate + /// + /// + /// + /// 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. + /// Image name. Use .default for image creation. + /// 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 imageName, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _imageRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new ImageOperationSource(Client), _imageClientDiagnostics, Pipeline, _imageRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, 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 Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_CreateOrUpdate + /// + /// + /// + /// 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. + /// Image name. Use .default for image creation. + /// 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 imageName, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _imageRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, data, cancellationToken); + var operation = new SphereArmOperation(new ImageOperationSource(Client), _imageClientDiagnostics, Pipeline, _imageRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.Get"); + scope.Start(); + try + { + var response = await _imageRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ImageResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.Get"); + scope.Start(); + try + { + var response = _imageRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ImageResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Image resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images + /// + /// + /// Operation Id + /// Images_ListByCatalog + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _imageRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _imageRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), _imageClientDiagnostics, Pipeline, "ImageCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Image resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images + /// + /// + /// Operation Id + /// Images_ListByCatalog + /// + /// + /// + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _imageRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _imageRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, filter, top, skip, pageSizeHint); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ImageResource(Client, ImageData.DeserializeImageData(e)), _imageClientDiagnostics, Pipeline, "ImageCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.Exists"); + scope.Start(); + try + { + var response = await _imageRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, 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.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// Image name. Use .default for image creation. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageCollection.Exists"); + scope.Start(); + try + { + var response = _imageRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, imageName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageData.cs new file mode 100644 index 0000000000000..63141e6b470c7 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageData.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Image data model. + /// An image resource belonging to a catalog resource. + /// + public partial class ImageData : ResourceData + { + /// Initializes a new instance of ImageData. + public ImageData() + { + } + + /// Initializes a new instance of ImageData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Image as a UTF-8 encoded base 64 string on image create. This field contains the image URI on image reads. + /// Image ID. + /// Image name. + /// Regional data boundary for an image. + /// Location the image. + /// The image description. + /// The image component id. + /// The image type. + /// The status of the last operation. + internal ImageData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string image, string imageId, string imageName, RegionalDataBoundary? regionalDataBoundary, Uri uri, string description, string componentId, ImageType? imageType, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + Image = image; + ImageId = imageId; + ImageName = imageName; + RegionalDataBoundary = regionalDataBoundary; + Uri = uri; + Description = description; + ComponentId = componentId; + ImageType = imageType; + ProvisioningState = provisioningState; + } + + /// Image as a UTF-8 encoded base 64 string on image create. This field contains the image URI on image reads. + public string Image { get; set; } + /// Image ID. + public string ImageId { get; set; } + /// Image name. + public string ImageName { get; } + /// Regional data boundary for an image. + public RegionalDataBoundary? RegionalDataBoundary { get; set; } + /// Location the image. + public Uri Uri { get; } + /// The image description. + public string Description { get; } + /// The image component id. + public string ComponentId { get; } + /// The image type. + public ImageType? ImageType { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageResource.cs new file mode 100644 index 0000000000000..2c20325b27aae --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ImageResource.cs @@ -0,0 +1,297 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing an Image along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetImageResource method. + /// Otherwise you can get one from its parent resource using the GetImage method. + /// + public partial class ImageResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string imageName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _imageClientDiagnostics; + private readonly ImagesRestOperations _imageRestClient; + private readonly ImageData _data; + + /// Initializes a new instance of the class for mocking. + protected ImageResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ImageResource(ArmClient client, ImageData 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 ImageResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _imageClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string imageApiVersion); + _imageRestClient = new ImagesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, imageApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/images"; + + /// 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 ImageData 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 Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _imageClientDiagnostics.CreateScope("ImageResource.Get"); + scope.Start(); + try + { + var response = await _imageRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ImageResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _imageClientDiagnostics.CreateScope("ImageResource.Get"); + scope.Start(); + try + { + var response = _imageRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ImageResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Delete + /// + /// + /// + /// 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 = _imageClientDiagnostics.CreateScope("ImageResource.Delete"); + scope.Start(); + try + { + var response = await _imageRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_imageClientDiagnostics, Pipeline, _imageRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_Delete + /// + /// + /// + /// 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 = _imageClientDiagnostics.CreateScope("ImageResource.Delete"); + scope.Start(); + try + { + var response = _imageRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_imageClientDiagnostics, Pipeline, _imageRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_CreateOrUpdate + /// + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageResource.Update"); + scope.Start(); + try + { + var response = await _imageRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new ImageOperationSource(Client), _imageClientDiagnostics, Pipeline, _imageRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, 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 Image + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/images/{imageName} + /// + /// + /// Operation Id + /// Images_CreateOrUpdate + /// + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _imageClientDiagnostics.CreateScope("ImageResource.Update"); + scope.Start(); + try + { + var response = _imageRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new SphereArmOperation(new ImageOperationSource(Client), _imageClientDiagnostics, Pipeline, _imageRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/CatalogOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/CatalogOperationSource.cs new file mode 100644 index 0000000000000..96e2bc8a425a7 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/CatalogOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class CatalogOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal CatalogOperationSource(ArmClient client) + { + _client = client; + } + + CatalogResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = CatalogData.DeserializeCatalogData(document.RootElement); + return new CatalogResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = CatalogData.DeserializeCatalogData(document.RootElement); + return new CatalogResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeploymentOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeploymentOperationSource.cs new file mode 100644 index 0000000000000..439fa463b116b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeploymentOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class DeploymentOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DeploymentOperationSource(ArmClient client) + { + _client = client; + } + + DeploymentResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DeploymentData.DeserializeDeploymentData(document.RootElement); + return new DeploymentResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DeploymentData.DeserializeDeploymentData(document.RootElement); + return new DeploymentResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceGroupOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceGroupOperationSource.cs new file mode 100644 index 0000000000000..b288c9210a2c9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceGroupOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class DeviceGroupOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DeviceGroupOperationSource(ArmClient client) + { + _client = client; + } + + DeviceGroupResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DeviceGroupData.DeserializeDeviceGroupData(document.RootElement); + return new DeviceGroupResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DeviceGroupData.DeserializeDeviceGroupData(document.RootElement); + return new DeviceGroupResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceOperationSource.cs new file mode 100644 index 0000000000000..98b3fb7ab6406 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/DeviceOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class DeviceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal DeviceOperationSource(ArmClient client) + { + _client = client; + } + + DeviceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = DeviceData.DeserializeDeviceData(document.RootElement); + return new DeviceResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = DeviceData.DeserializeDeviceData(document.RootElement); + return new DeviceResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ImageOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ImageOperationSource.cs new file mode 100644 index 0000000000000..4a605883e93c9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ImageOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class ImageOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ImageOperationSource(ArmClient client) + { + _client = client; + } + + ImageResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = ImageData.DeserializeImageData(document.RootElement); + return new ImageResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = ImageData.DeserializeImageData(document.RootElement); + return new ImageResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ProductOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ProductOperationSource.cs new file mode 100644 index 0000000000000..c35279fa26c5f --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/ProductOperationSource.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + internal class ProductOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal ProductOperationSource(ArmClient client) + { + _client = client; + } + + ProductResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = ProductData.DeserializeProductData(document.RootElement); + return new ProductResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = ProductData.DeserializeProductData(document.RootElement); + return new ProductResource(_client, data); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SignedCapabilityImageResponseOperationSource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SignedCapabilityImageResponseOperationSource.cs new file mode 100644 index 0000000000000..970d900dddf7e --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SignedCapabilityImageResponseOperationSource.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal class SignedCapabilityImageResponseOperationSource : IOperationSource + { + SignedCapabilityImageResponse IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + return SignedCapabilityImageResponse.DeserializeSignedCapabilityImageResponse(document.RootElement); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + return SignedCapabilityImageResponse.DeserializeSignedCapabilityImageResponse(document.RootElement); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperation.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperation.cs new file mode 100644 index 0000000000000..e11ad0a12705a --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperation.cs @@ -0,0 +1,70 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ +#pragma warning disable SA1649 // File name should match first type name + internal class SphereArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of SphereArmOperation for mocking. + protected SphereArmOperation() + { + } + + internal SphereArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response); + } + + internal SphereArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia); + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "SphereArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + 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/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperationOfT.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperationOfT.cs new file mode 100644 index 0000000000000..3bcd2ffcbb7da --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/LongRunningOperation/SphereArmOperationOfT.cs @@ -0,0 +1,76 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ +#pragma warning disable SA1649 // File name should match first type name + internal class SphereArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + + /// Initializes a new instance of SphereArmOperation for mocking. + protected SphereArmOperation() + { + } + + internal SphereArmOperation(Response response) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + } + + internal SphereArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(source, pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia); + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "SphereArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + /// +#pragma warning disable CA1822 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public override string Id => throw new NotImplementedException(); +#pragma warning restore CA1822 + + /// + 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/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/AllowCrashDumpCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/AllowCrashDumpCollection.cs new file mode 100644 index 0000000000000..4801cde753fc6 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/AllowCrashDumpCollection.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Allow crash dumps values. + public readonly partial struct AllowCrashDumpCollection : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AllowCrashDumpCollection(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; + + /// Enabled. + public static AllowCrashDumpCollection Enabled { get; } = new AllowCrashDumpCollection(EnabledValue); + /// Disabled. + public static AllowCrashDumpCollection Disabled { get; } = new AllowCrashDumpCollection(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(AllowCrashDumpCollection left, AllowCrashDumpCollection right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AllowCrashDumpCollection left, AllowCrashDumpCollection right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AllowCrashDumpCollection(string value) => new AllowCrashDumpCollection(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AllowCrashDumpCollection other && Equals(other); + /// + public bool Equals(AllowCrashDumpCollection other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CapabilityType.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CapabilityType.cs new file mode 100644 index 0000000000000..7a1e86a4e92f8 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CapabilityType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Capability image type. + public readonly partial struct CapabilityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CapabilityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApplicationDevelopmentValue = "ApplicationDevelopment"; + private const string FieldServicingValue = "FieldServicing"; + + /// ApplicationDevelopment. + public static CapabilityType ApplicationDevelopment { get; } = new CapabilityType(ApplicationDevelopmentValue); + /// FieldServicing. + public static CapabilityType FieldServicing { get; } = new CapabilityType(FieldServicingValue); + /// Determines if two values are the same. + public static bool operator ==(CapabilityType left, CapabilityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CapabilityType left, CapabilityType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CapabilityType(string value) => new CapabilityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CapabilityType other && Equals(other); + /// + public bool Equals(CapabilityType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogData.Serialization.cs new file mode 100644 index 0000000000000..2745dc60f67df --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogData.Serialization.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class CatalogData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static CatalogData DeserializeCatalogData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new CatalogData(id, name, type, systemData.Value, Optional.ToDictionary(tags), location, Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.Serialization.cs new file mode 100644 index 0000000000000..5814c7c57b461 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class CatalogListResult + { + internal static CatalogListResult DeserializeCatalogListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CatalogData.DeserializeCatalogData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new CatalogListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.cs new file mode 100644 index 0000000000000..3dd1f8f2bdcc9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Catalog list operation. + internal partial class CatalogListResult + { + /// Initializes a new instance of CatalogListResult. + /// The Catalog items on this page. + /// is null. + internal CatalogListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of CatalogListResult. + /// The Catalog items on this page. + /// The link to the next page of items. + internal CatalogListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Catalog items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.Serialization.cs new file mode 100644 index 0000000000000..afed483c67594 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.Serialization.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class CatalogPatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.cs new file mode 100644 index 0000000000000..f9be29af127df --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CatalogPatch.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The type used for update operations of the Catalog. + public partial class CatalogPatch + { + /// Initializes a new instance of CatalogPatch. + public CatalogPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Resource tags. + public IDictionary Tags { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.Serialization.cs new file mode 100644 index 0000000000000..012b97e3fe6d3 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.Serialization.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class CertificateChainResponse + { + internal static CertificateChainResponse DeserializeCertificateChainResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional certificateChain = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("certificateChain"u8)) + { + certificateChain = property.Value.GetString(); + continue; + } + } + return new CertificateChainResponse(certificateChain.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.cs new file mode 100644 index 0000000000000..f12eaa8f81921 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateChainResponse.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The certificate chain response. + public partial class CertificateChainResponse + { + /// Initializes a new instance of CertificateChainResponse. + internal CertificateChainResponse() + { + } + + /// Initializes a new instance of CertificateChainResponse. + /// The certificate chain. + internal CertificateChainResponse(string certificateChain) + { + CertificateChain = certificateChain; + } + + /// The certificate chain. + public string CertificateChain { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateData.Serialization.cs new file mode 100644 index 0000000000000..20ebd48b6533b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateData.Serialization.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class CertificateData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static CertificateData DeserializeCertificateData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional certificate = default; + Optional status = default; + Optional subject = default; + Optional thumbprint = default; + Optional expiryUtc = default; + Optional notBeforeUtc = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("certificate"u8)) + { + certificate = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new CertificateStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("subject"u8)) + { + subject = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("thumbprint"u8)) + { + thumbprint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("expiryUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiryUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("notBeforeUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notBeforeUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new CertificateData(id, name, type, systemData.Value, certificate.Value, Optional.ToNullable(status), subject.Value, thumbprint.Value, Optional.ToNullable(expiryUtc), Optional.ToNullable(notBeforeUtc), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.Serialization.cs new file mode 100644 index 0000000000000..b60792191474d --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class CertificateListResult + { + internal static CertificateListResult DeserializeCertificateListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CertificateData.DeserializeCertificateData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new CertificateListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.cs new file mode 100644 index 0000000000000..d6dac3a1fc3db --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Certificate list operation. + internal partial class CertificateListResult + { + /// Initializes a new instance of CertificateListResult. + /// The Certificate items on this page. + /// is null. + internal CertificateListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of CertificateListResult. + /// The Certificate items on this page. + /// The link to the next page of items. + internal CertificateListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Certificate items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.Serialization.cs new file mode 100644 index 0000000000000..d47c17e267704 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.Serialization.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class CertificateProperties + { + internal static CertificateProperties DeserializeCertificateProperties(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional certificate = default; + Optional status = default; + Optional subject = default; + Optional thumbprint = default; + Optional expiryUtc = default; + Optional notBeforeUtc = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("certificate"u8)) + { + certificate = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new CertificateStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("subject"u8)) + { + subject = property.Value.GetString(); + continue; + } + if (property.NameEquals("thumbprint"u8)) + { + thumbprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("expiryUtc"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiryUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("notBeforeUtc"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notBeforeUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + } + return new CertificateProperties(certificate.Value, Optional.ToNullable(status), subject.Value, thumbprint.Value, Optional.ToNullable(expiryUtc), Optional.ToNullable(notBeforeUtc), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.cs new file mode 100644 index 0000000000000..a189fca3b3307 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateProperties.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The properties of certificate. + public partial class CertificateProperties + { + /// Initializes a new instance of CertificateProperties. + internal CertificateProperties() + { + } + + /// Initializes a new instance of CertificateProperties. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + internal CertificateProperties(string certificate, CertificateStatus? status, string subject, string thumbprint, DateTimeOffset? expiryUtc, DateTimeOffset? notBeforeUtc, ProvisioningState? provisioningState) + { + Certificate = certificate; + Status = status; + Subject = subject; + Thumbprint = thumbprint; + ExpiryUtc = expiryUtc; + NotBeforeUtc = notBeforeUtc; + ProvisioningState = provisioningState; + } + + /// The certificate as a UTF-8 encoded base 64 string. + public string Certificate { get; } + /// The certificate status. + public CertificateStatus? Status { get; } + /// The certificate subject. + public string Subject { get; } + /// The certificate thumbprint. + public string Thumbprint { get; } + /// The certificate expiry date. + public DateTimeOffset? ExpiryUtc { get; } + /// The certificate not before date. + public DateTimeOffset? NotBeforeUtc { get; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateStatus.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateStatus.cs new file mode 100644 index 0000000000000..c4e2b98367e8a --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CertificateStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Certificate status values. + public readonly partial struct CertificateStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "Active"; + private const string InactiveValue = "Inactive"; + private const string ExpiredValue = "Expired"; + private const string RevokedValue = "Revoked"; + + /// Active. + public static CertificateStatus Active { get; } = new CertificateStatus(ActiveValue); + /// Inactive. + public static CertificateStatus Inactive { get; } = new CertificateStatus(InactiveValue); + /// Expired. + public static CertificateStatus Expired { get; } = new CertificateStatus(ExpiredValue); + /// Revoked. + public static CertificateStatus Revoked { get; } = new CertificateStatus(RevokedValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateStatus left, CertificateStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateStatus left, CertificateStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CertificateStatus(string value) => new CertificateStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateStatus other && Equals(other); + /// + public bool Equals(CertificateStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.Serialization.cs new file mode 100644 index 0000000000000..a20550615088a --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class ClaimDevicesContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("deviceIdentifiers"u8); + writer.WriteStartArray(); + foreach (var item in DeviceIdentifiers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.cs new file mode 100644 index 0000000000000..9048e4b5557ba --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ClaimDevicesContent.cs @@ -0,0 +1,31 @@ +// 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; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Request to the action call to bulk claim devices. + public partial class ClaimDevicesContent + { + /// Initializes a new instance of ClaimDevicesContent. + /// Device identifiers of the devices to be claimed. + /// is null. + public ClaimDevicesContent(IEnumerable deviceIdentifiers) + { + Argument.AssertNotNull(deviceIdentifiers, nameof(deviceIdentifiers)); + + DeviceIdentifiers = deviceIdentifiers.ToList(); + } + + /// Device identifiers of the devices to be claimed. + public IList DeviceIdentifiers { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.Serialization.cs new file mode 100644 index 0000000000000..79864b3ffc85d --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.Serialization.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class CountDeviceResponse + { + internal static CountDeviceResponse DeserializeCountDeviceResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetInt32(); + continue; + } + } + return new CountDeviceResponse(value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.cs new file mode 100644 index 0000000000000..48a7aa0ccbe2c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountDeviceResponse.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Response to the action call for count devices in a catalog. + public partial class CountDeviceResponse : CountElementsResponse + { + /// Initializes a new instance of CountDeviceResponse. + /// Number of children resources in parent resource. + internal CountDeviceResponse(int value) : base(value) + { + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.Serialization.cs new file mode 100644 index 0000000000000..5f1a668fdd612 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.Serialization.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class CountElementsResponse + { + internal static CountElementsResponse DeserializeCountElementsResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetInt32(); + continue; + } + } + return new CountElementsResponse(value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.cs new file mode 100644 index 0000000000000..01ccf54d61fed --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/CountElementsResponse.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Response of the count for elements. + public partial class CountElementsResponse + { + /// Initializes a new instance of CountElementsResponse. + /// Number of children resources in parent resource. + internal CountElementsResponse(int value) + { + Value = value; + } + + /// Number of children resources in parent resource. + public int Value { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentData.Serialization.cs new file mode 100644 index 0000000000000..12801a1b7157a --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentData.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class DeploymentData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(DeploymentId)) + { + writer.WritePropertyName("deploymentId"u8); + writer.WriteStringValue(DeploymentId); + } + if (Optional.IsCollectionDefined(DeployedImages)) + { + writer.WritePropertyName("deployedImages"u8); + writer.WriteStartArray(); + foreach (var item in DeployedImages) + { + writer.WriteObjectValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DeploymentData DeserializeDeploymentData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional deploymentId = default; + Optional> deployedImages = default; + Optional deploymentDateUtc = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("deploymentId"u8)) + { + deploymentId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("deployedImages"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(ImageData.DeserializeImageData(item)); + } + deployedImages = array; + continue; + } + if (property0.NameEquals("deploymentDateUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deploymentDateUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new DeploymentData(id, name, type, systemData.Value, deploymentId.Value, Optional.ToList(deployedImages), Optional.ToNullable(deploymentDateUtc), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.Serialization.cs new file mode 100644 index 0000000000000..4b0ab02b0aeaf --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class DeploymentListResult + { + internal static DeploymentListResult DeserializeDeploymentListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeploymentData.DeserializeDeploymentData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new DeploymentListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.cs new file mode 100644 index 0000000000000..e45a3b0e32a61 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeploymentListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Deployment list operation. + internal partial class DeploymentListResult + { + /// Initializes a new instance of DeploymentListResult. + /// The Deployment items on this page. + /// is null. + internal DeploymentListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of DeploymentListResult. + /// The Deployment items on this page. + /// The link to the next page of items. + internal DeploymentListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Deployment items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceData.Serialization.cs new file mode 100644 index 0000000000000..2c5df3a7595a0 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceData.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class DeviceData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(DeviceId)) + { + writer.WritePropertyName("deviceId"u8); + writer.WriteStringValue(DeviceId); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DeviceData DeserializeDeviceData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional deviceId = default; + Optional chipSku = default; + Optional lastAvailableOSVersion = default; + Optional lastInstalledOSVersion = default; + Optional lastOSUpdateUtc = default; + Optional lastUpdateRequestUtc = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("deviceId"u8)) + { + deviceId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("chipSku"u8)) + { + chipSku = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("lastAvailableOsVersion"u8)) + { + lastAvailableOSVersion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("lastInstalledOsVersion"u8)) + { + lastInstalledOSVersion = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("lastOsUpdateUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastOSUpdateUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("lastUpdateRequestUtc"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastUpdateRequestUtc = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new DeviceData(id, name, type, systemData.Value, deviceId.Value, chipSku.Value, lastAvailableOSVersion.Value, lastInstalledOSVersion.Value, Optional.ToNullable(lastOSUpdateUtc), Optional.ToNullable(lastUpdateRequestUtc), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupData.Serialization.cs new file mode 100644 index 0000000000000..559187b48167b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupData.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class DeviceGroupData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(OSFeedType)) + { + writer.WritePropertyName("osFeedType"u8); + writer.WriteStringValue(OSFeedType.Value.ToString()); + } + if (Optional.IsDefined(UpdatePolicy)) + { + writer.WritePropertyName("updatePolicy"u8); + writer.WriteStringValue(UpdatePolicy.Value.ToString()); + } + if (Optional.IsDefined(AllowCrashDumpsCollection)) + { + writer.WritePropertyName("allowCrashDumpsCollection"u8); + writer.WriteStringValue(AllowCrashDumpsCollection.Value.ToString()); + } + if (Optional.IsDefined(RegionalDataBoundary)) + { + writer.WritePropertyName("regionalDataBoundary"u8); + writer.WriteStringValue(RegionalDataBoundary.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DeviceGroupData DeserializeDeviceGroupData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional description = default; + Optional osFeedType = default; + Optional updatePolicy = default; + Optional allowCrashDumpsCollection = default; + Optional regionalDataBoundary = default; + Optional hasDeployment = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("osFeedType"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + osFeedType = new OSFeedType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("updatePolicy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatePolicy = new UpdatePolicy(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("allowCrashDumpsCollection"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allowCrashDumpsCollection = new AllowCrashDumpCollection(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("regionalDataBoundary"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + regionalDataBoundary = new RegionalDataBoundary(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("hasDeployment"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hasDeployment = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new DeviceGroupData(id, name, type, systemData.Value, description.Value, Optional.ToNullable(osFeedType), Optional.ToNullable(updatePolicy), Optional.ToNullable(allowCrashDumpsCollection), Optional.ToNullable(regionalDataBoundary), Optional.ToNullable(hasDeployment), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.Serialization.cs new file mode 100644 index 0000000000000..774affb2b4e8c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class DeviceGroupListResult + { + internal static DeviceGroupListResult DeserializeDeviceGroupListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeviceGroupData.DeserializeDeviceGroupData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new DeviceGroupListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.cs new file mode 100644 index 0000000000000..b68012cc3ab35 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a DeviceGroup list operation. + internal partial class DeviceGroupListResult + { + /// Initializes a new instance of DeviceGroupListResult. + /// The DeviceGroup items on this page. + /// is null. + internal DeviceGroupListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of DeviceGroupListResult. + /// The DeviceGroup items on this page. + /// The link to the next page of items. + internal DeviceGroupListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The DeviceGroup items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.Serialization.cs new file mode 100644 index 0000000000000..292a4be1e0b0d --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.Serialization.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class DeviceGroupPatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(OSFeedType)) + { + writer.WritePropertyName("osFeedType"u8); + writer.WriteStringValue(OSFeedType.Value.ToString()); + } + if (Optional.IsDefined(UpdatePolicy)) + { + writer.WritePropertyName("updatePolicy"u8); + writer.WriteStringValue(UpdatePolicy.Value.ToString()); + } + if (Optional.IsDefined(AllowCrashDumpsCollection)) + { + writer.WritePropertyName("allowCrashDumpsCollection"u8); + writer.WriteStringValue(AllowCrashDumpsCollection.Value.ToString()); + } + if (Optional.IsDefined(RegionalDataBoundary)) + { + writer.WritePropertyName("regionalDataBoundary"u8); + writer.WriteStringValue(RegionalDataBoundary.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.cs new file mode 100644 index 0000000000000..c46af4a8f163c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceGroupPatch.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The type used for update operations of the DeviceGroup. + public partial class DeviceGroupPatch + { + /// Initializes a new instance of DeviceGroupPatch. + public DeviceGroupPatch() + { + } + + /// Description of the device group. + public string Description { get; set; } + /// Operating system feed type of the device group. + public OSFeedType? OSFeedType { get; set; } + /// Update policy of the device group. + public UpdatePolicy? UpdatePolicy { get; set; } + /// Flag to define if the user allows for crash dump collection. + public AllowCrashDumpCollection? AllowCrashDumpsCollection { get; set; } + /// Regional data boundary for the device group. + public RegionalDataBoundary? RegionalDataBoundary { get; set; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.Serialization.cs new file mode 100644 index 0000000000000..2dce6bbccae65 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.Serialization.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class DeviceInsight + { + internal static DeviceInsight DeserializeDeviceInsight(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string deviceId = default; + string description = default; + DateTimeOffset startTimestampUtc = default; + DateTimeOffset endTimestampUtc = default; + string eventCategory = default; + string eventClass = default; + string eventType = default; + int eventCount = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("deviceId"u8)) + { + deviceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("startTimestampUtc"u8)) + { + startTimestampUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endTimestampUtc"u8)) + { + endTimestampUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("eventCategory"u8)) + { + eventCategory = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventClass"u8)) + { + eventClass = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventType"u8)) + { + eventType = property.Value.GetString(); + continue; + } + if (property.NameEquals("eventCount"u8)) + { + eventCount = property.Value.GetInt32(); + continue; + } + } + return new DeviceInsight(deviceId, description, startTimestampUtc, endTimestampUtc, eventCategory, eventClass, eventType, eventCount); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.cs new file mode 100644 index 0000000000000..34345dc144e46 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceInsight.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Device insight report. + public partial class DeviceInsight + { + /// Initializes a new instance of DeviceInsight. + /// Device ID. + /// Event description. + /// Event start timestamp. + /// Event end timestamp. + /// Event category. + /// Event class. + /// Event type. + /// Event count. + /// , , , or is null. + internal DeviceInsight(string deviceId, string description, DateTimeOffset startTimestampUtc, DateTimeOffset endTimestampUtc, string eventCategory, string eventClass, string eventType, int eventCount) + { + Argument.AssertNotNull(deviceId, nameof(deviceId)); + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(eventCategory, nameof(eventCategory)); + Argument.AssertNotNull(eventClass, nameof(eventClass)); + Argument.AssertNotNull(eventType, nameof(eventType)); + + DeviceId = deviceId; + Description = description; + StartTimestampUtc = startTimestampUtc; + EndTimestampUtc = endTimestampUtc; + EventCategory = eventCategory; + EventClass = eventClass; + EventType = eventType; + EventCount = eventCount; + } + + /// Device ID. + public string DeviceId { get; } + /// Event description. + public string Description { get; } + /// Event start timestamp. + public DateTimeOffset StartTimestampUtc { get; } + /// Event end timestamp. + public DateTimeOffset EndTimestampUtc { get; } + /// Event category. + public string EventCategory { get; } + /// Event class. + public string EventClass { get; } + /// Event type. + public string EventType { get; } + /// Event count. + public int EventCount { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.Serialization.cs new file mode 100644 index 0000000000000..ac90bde069a1a --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class DeviceListResult + { + internal static DeviceListResult DeserializeDeviceListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeviceData.DeserializeDeviceData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new DeviceListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.cs new file mode 100644 index 0000000000000..5cc9ea9198cd3 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DeviceListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Device list operation. + internal partial class DeviceListResult + { + /// Initializes a new instance of DeviceListResult. + /// The Device items on this page. + /// is null. + internal DeviceListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of DeviceListResult. + /// The Device items on this page. + /// The link to the next page of items. + internal DeviceListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Device items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.Serialization.cs new file mode 100644 index 0000000000000..4fd5b6f92ffa7 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class DevicePatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(DeviceGroupId)) + { + writer.WritePropertyName("deviceGroupId"u8); + writer.WriteStringValue(DeviceGroupId); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.cs new file mode 100644 index 0000000000000..a5b941475f5ca --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/DevicePatch.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The type used for update operations of the Device. + public partial class DevicePatch + { + /// Initializes a new instance of DevicePatch. + public DevicePatch() + { + } + + /// Device group id. + public string DeviceGroupId { get; set; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.Serialization.cs new file mode 100644 index 0000000000000..c5438146a26ff --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.Serialization.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class GenerateCapabilityImageContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("capabilities"u8); + writer.WriteStartArray(); + foreach (var item in Capabilities) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.cs new file mode 100644 index 0000000000000..e6b23fb63dda2 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/GenerateCapabilityImageContent.cs @@ -0,0 +1,31 @@ +// 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; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Request of the action to create a signed device capability image. + public partial class GenerateCapabilityImageContent + { + /// Initializes a new instance of GenerateCapabilityImageContent. + /// List of capabilities to create. + /// is null. + public GenerateCapabilityImageContent(IEnumerable capabilities) + { + Argument.AssertNotNull(capabilities, nameof(capabilities)); + + Capabilities = capabilities.ToList(); + } + + /// List of capabilities to create. + public IList Capabilities { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageData.Serialization.cs new file mode 100644 index 0000000000000..74f660ee74dc9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageData.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class ImageData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Image)) + { + writer.WritePropertyName("image"u8); + writer.WriteStringValue(Image); + } + if (Optional.IsDefined(ImageId)) + { + writer.WritePropertyName("imageId"u8); + writer.WriteStringValue(ImageId); + } + if (Optional.IsDefined(RegionalDataBoundary)) + { + writer.WritePropertyName("regionalDataBoundary"u8); + writer.WriteStringValue(RegionalDataBoundary.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static ImageData DeserializeImageData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional image = default; + Optional imageId = default; + Optional imageName = default; + Optional regionalDataBoundary = default; + Optional uri = default; + Optional description = default; + Optional componentId = default; + Optional imageType = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("image"u8)) + { + image = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("imageId"u8)) + { + imageId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("imageName"u8)) + { + imageName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("regionalDataBoundary"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + regionalDataBoundary = new RegionalDataBoundary(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("uri"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uri = new Uri(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("componentId"u8)) + { + componentId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("imageType"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageType = new ImageType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new ImageData(id, name, type, systemData.Value, image.Value, imageId.Value, imageName.Value, Optional.ToNullable(regionalDataBoundary), uri.Value, description.Value, componentId.Value, Optional.ToNullable(imageType), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.Serialization.cs new file mode 100644 index 0000000000000..21f63dc697f96 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class ImageListResult + { + internal static ImageListResult DeserializeImageListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ImageData.DeserializeImageData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new ImageListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.cs new file mode 100644 index 0000000000000..b1d3e8f0cfb99 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Image list operation. + internal partial class ImageListResult + { + /// Initializes a new instance of ImageListResult. + /// The Image items on this page. + /// is null. + internal ImageListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of ImageListResult. + /// The Image items on this page. + /// The link to the next page of items. + internal ImageListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Image items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageType.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageType.cs new file mode 100644 index 0000000000000..8844fb531f94c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ImageType.cs @@ -0,0 +1,117 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Image type values. + public readonly partial struct ImageType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImageType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InvalidImageTypeValue = "InvalidImageType"; + private const string OneBlValue = "OneBl"; + private const string PlutonRuntimeValue = "PlutonRuntime"; + private const string WifiFirmwareValue = "WifiFirmware"; + private const string SecurityMonitorValue = "SecurityMonitor"; + private const string NormalWorldLoaderValue = "NormalWorldLoader"; + private const string NormalWorldDtbValue = "NormalWorldDtb"; + private const string NormalWorldKernelValue = "NormalWorldKernel"; + private const string RootFsValue = "RootFs"; + private const string ServicesValue = "Services"; + private const string ApplicationsValue = "Applications"; + private const string FwConfigValue = "FwConfig"; + private const string BootManifestValue = "BootManifest"; + private const string NwfsValue = "Nwfs"; + private const string TrustedKeystoreValue = "TrustedKeystore"; + private const string PolicyValue = "Policy"; + private const string CustomerBoardConfigValue = "CustomerBoardConfig"; + private const string UpdateCertStoreValue = "UpdateCertStore"; + private const string BaseSystemUpdateManifestValue = "BaseSystemUpdateManifest"; + private const string FirmwareUpdateManifestValue = "FirmwareUpdateManifest"; + private const string CustomerUpdateManifestValue = "CustomerUpdateManifest"; + private const string RecoveryManifestValue = "RecoveryManifest"; + private const string ManifestSetValue = "ManifestSet"; + private const string OtherValue = "Other"; + + /// InvalidImageType. + public static ImageType InvalidImageType { get; } = new ImageType(InvalidImageTypeValue); + /// OneBl. + public static ImageType OneBl { get; } = new ImageType(OneBlValue); + /// PlutonRuntime. + public static ImageType PlutonRuntime { get; } = new ImageType(PlutonRuntimeValue); + /// WifiFirmware. + public static ImageType WifiFirmware { get; } = new ImageType(WifiFirmwareValue); + /// SecurityMonitor. + public static ImageType SecurityMonitor { get; } = new ImageType(SecurityMonitorValue); + /// NormalWorldLoader. + public static ImageType NormalWorldLoader { get; } = new ImageType(NormalWorldLoaderValue); + /// NormalWorldDtb. + public static ImageType NormalWorldDtb { get; } = new ImageType(NormalWorldDtbValue); + /// NormalWorldKernel. + public static ImageType NormalWorldKernel { get; } = new ImageType(NormalWorldKernelValue); + /// RootFs. + public static ImageType RootFs { get; } = new ImageType(RootFsValue); + /// Services. + public static ImageType Services { get; } = new ImageType(ServicesValue); + /// Applications. + public static ImageType Applications { get; } = new ImageType(ApplicationsValue); + /// FwConfig. + public static ImageType FwConfig { get; } = new ImageType(FwConfigValue); + /// BootManifest. + public static ImageType BootManifest { get; } = new ImageType(BootManifestValue); + /// Nwfs. + public static ImageType Nwfs { get; } = new ImageType(NwfsValue); + /// TrustedKeystore. + public static ImageType TrustedKeystore { get; } = new ImageType(TrustedKeystoreValue); + /// Policy. + public static ImageType Policy { get; } = new ImageType(PolicyValue); + /// CustomerBoardConfig. + public static ImageType CustomerBoardConfig { get; } = new ImageType(CustomerBoardConfigValue); + /// UpdateCertStore. + public static ImageType UpdateCertStore { get; } = new ImageType(UpdateCertStoreValue); + /// BaseSystemUpdateManifest. + public static ImageType BaseSystemUpdateManifest { get; } = new ImageType(BaseSystemUpdateManifestValue); + /// FirmwareUpdateManifest. + public static ImageType FirmwareUpdateManifest { get; } = new ImageType(FirmwareUpdateManifestValue); + /// CustomerUpdateManifest. + public static ImageType CustomerUpdateManifest { get; } = new ImageType(CustomerUpdateManifestValue); + /// RecoveryManifest. + public static ImageType RecoveryManifest { get; } = new ImageType(RecoveryManifestValue); + /// ManifestSet. + public static ImageType ManifestSet { get; } = new ImageType(ManifestSetValue); + /// Other. + public static ImageType Other { get; } = new ImageType(OtherValue); + /// Determines if two values are the same. + public static bool operator ==(ImageType left, ImageType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImageType left, ImageType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ImageType(string value) => new ImageType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageType other && Equals(other); + /// + public bool Equals(ImageType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.Serialization.cs new file mode 100644 index 0000000000000..5d4a54298a541 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class ListDeviceGroupsContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(DeviceGroupName)) + { + writer.WritePropertyName("deviceGroupName"u8); + writer.WriteStringValue(DeviceGroupName); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.cs new file mode 100644 index 0000000000000..cc001ed783e66 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ListDeviceGroupsContent.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Request of the action to list device groups for a catalog. + public partial class ListDeviceGroupsContent + { + /// Initializes a new instance of ListDeviceGroupsContent. + public ListDeviceGroupsContent() + { + } + + /// Device Group name. + public string DeviceGroupName { get; set; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/OSFeedType.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/OSFeedType.cs new file mode 100644 index 0000000000000..3cf176fe06604 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/OSFeedType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// OS feed type values. + public readonly partial struct OSFeedType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OSFeedType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RetailValue = "Retail"; + private const string RetailEvalValue = "RetailEval"; + + /// Retail. + public static OSFeedType Retail { get; } = new OSFeedType(RetailValue); + /// RetailEval. + public static OSFeedType RetailEval { get; } = new OSFeedType(RetailEvalValue); + /// Determines if two values are the same. + public static bool operator ==(OSFeedType left, OSFeedType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OSFeedType left, OSFeedType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OSFeedType(string value) => new OSFeedType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OSFeedType other && Equals(other); + /// + public bool Equals(OSFeedType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.Serialization.cs new file mode 100644 index 0000000000000..a46dd9af2e263 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.Serialization.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class PagedDeviceInsight + { + internal static PagedDeviceInsight DeserializePagedDeviceInsight(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DeviceInsight.DeserializeDeviceInsight(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new PagedDeviceInsight(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.cs new file mode 100644 index 0000000000000..f93e73e364dc9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/PagedDeviceInsight.cs @@ -0,0 +1,42 @@ +// 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; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Paged collection of DeviceInsight items. + internal partial class PagedDeviceInsight + { + /// Initializes a new instance of PagedDeviceInsight. + /// The DeviceInsight items on this page. + /// is null. + internal PagedDeviceInsight(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of PagedDeviceInsight. + /// The DeviceInsight items on this page. + /// The link to the next page of items. + internal PagedDeviceInsight(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The DeviceInsight items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductData.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductData.Serialization.cs new file mode 100644 index 0000000000000..2cd21022a0989 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductData.Serialization.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + public partial class ProductData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static ProductData DeserializeProductData(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional systemData = default; + Optional description = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("description"u8)) + { + description = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("provisioningState"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property0.Value.GetString()); + continue; + } + } + continue; + } + } + return new ProductData(id, name, type, systemData.Value, description.Value, Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.Serialization.cs new file mode 100644 index 0000000000000..9070cbc0f85dc --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.Serialization.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + internal partial class ProductListResult + { + internal static ProductListResult DeserializeProductListResult(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Optional nextLink = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ProductData.DeserializeProductData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + } + return new ProductListResult(value, nextLink.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.cs new file mode 100644 index 0000000000000..8a27d26b20336 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductListResult.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Sphere; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The response of a Product list operation. + internal partial class ProductListResult + { + /// Initializes a new instance of ProductListResult. + /// The Product items on this page. + /// is null. + internal ProductListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of ProductListResult. + /// The Product items on this page. + /// The link to the next page of items. + internal ProductListResult(IReadOnlyList value, Uri nextLink) + { + Value = value; + NextLink = nextLink; + } + + /// The Product items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.Serialization.cs new file mode 100644 index 0000000000000..e701d61a828b9 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.Serialization.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class ProductPatch : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.cs new file mode 100644 index 0000000000000..0a8827335d43c --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProductPatch.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The type used for update operations of the Product. + public partial class ProductPatch + { + /// Initializes a new instance of ProductPatch. + public ProductPatch() + { + } + + /// Description of the product. + public string Description { get; set; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.Serialization.cs new file mode 100644 index 0000000000000..64ff188e641fc --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.Serialization.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class ProofOfPossessionNonceContent : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("proofOfPossessionNonce"u8); + writer.WriteStringValue(ProofOfPossessionNonce); + writer.WriteEndObject(); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.cs new file mode 100644 index 0000000000000..29ce21e16c4a6 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceContent.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Request for the proof of possession nonce. + public partial class ProofOfPossessionNonceContent + { + /// Initializes a new instance of ProofOfPossessionNonceContent. + /// The proof of possession nonce. + /// is null. + public ProofOfPossessionNonceContent(string proofOfPossessionNonce) + { + Argument.AssertNotNull(proofOfPossessionNonce, nameof(proofOfPossessionNonce)); + + ProofOfPossessionNonce = proofOfPossessionNonce; + } + + /// The proof of possession nonce. + public string ProofOfPossessionNonce { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.Serialization.cs new file mode 100644 index 0000000000000..7a619aa09c2fa --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.Serialization.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class ProofOfPossessionNonceResponse + { + internal static ProofOfPossessionNonceResponse DeserializeProofOfPossessionNonceResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional certificate = default; + Optional status = default; + Optional subject = default; + Optional thumbprint = default; + Optional expiryUtc = default; + Optional notBeforeUtc = default; + Optional provisioningState = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("certificate"u8)) + { + certificate = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new CertificateStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("subject"u8)) + { + subject = property.Value.GetString(); + continue; + } + if (property.NameEquals("thumbprint"u8)) + { + thumbprint = property.Value.GetString(); + continue; + } + if (property.NameEquals("expiryUtc"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiryUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("notBeforeUtc"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + notBeforeUtc = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + } + return new ProofOfPossessionNonceResponse(certificate.Value, Optional.ToNullable(status), subject.Value, thumbprint.Value, Optional.ToNullable(expiryUtc), Optional.ToNullable(notBeforeUtc), Optional.ToNullable(provisioningState)); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.cs new file mode 100644 index 0000000000000..cf9be89bcf2ac --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProofOfPossessionNonceResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Result of the action to generate a proof of possession nonce. + public partial class ProofOfPossessionNonceResponse : CertificateProperties + { + /// Initializes a new instance of ProofOfPossessionNonceResponse. + internal ProofOfPossessionNonceResponse() + { + } + + /// Initializes a new instance of ProofOfPossessionNonceResponse. + /// The certificate as a UTF-8 encoded base 64 string. + /// The certificate status. + /// The certificate subject. + /// The certificate thumbprint. + /// The certificate expiry date. + /// The certificate not before date. + /// The status of the last operation. + internal ProofOfPossessionNonceResponse(string certificate, CertificateStatus? status, string subject, string thumbprint, DateTimeOffset? expiryUtc, DateTimeOffset? notBeforeUtc, ProvisioningState? provisioningState) : base(certificate, status, subject, thumbprint, expiryUtc, notBeforeUtc, provisioningState) + { + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProvisioningState.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 0000000000000..44f1bed9031b4 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// The ProvisioningState. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string ProvisioningValue = "Provisioning"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// Succeeded. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Provisioning. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + /// Updating. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + /// Deleting. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + /// Determines if two values are the same. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + /// + public bool Equals(ProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/RegionalDataBoundary.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/RegionalDataBoundary.cs new file mode 100644 index 0000000000000..774b1fbe2e0a8 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/RegionalDataBoundary.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Regional data boundary values. + public readonly partial struct RegionalDataBoundary : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RegionalDataBoundary(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string EUValue = "EU"; + + /// None. + public static RegionalDataBoundary None { get; } = new RegionalDataBoundary(NoneValue); + /// EU. + public static RegionalDataBoundary EU { get; } = new RegionalDataBoundary(EUValue); + /// Determines if two values are the same. + public static bool operator ==(RegionalDataBoundary left, RegionalDataBoundary right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RegionalDataBoundary left, RegionalDataBoundary right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RegionalDataBoundary(string value) => new RegionalDataBoundary(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RegionalDataBoundary other && Equals(other); + /// + public bool Equals(RegionalDataBoundary other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.Serialization.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.Serialization.cs new file mode 100644 index 0000000000000..c988c7e63eba2 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.Serialization.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sphere.Models +{ + public partial class SignedCapabilityImageResponse + { + internal static SignedCapabilityImageResponse DeserializeSignedCapabilityImageResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional image = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + image = property.Value.GetString(); + continue; + } + } + return new SignedCapabilityImageResponse(image.Value); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.cs new file mode 100644 index 0000000000000..3b62dbe445a3b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/SignedCapabilityImageResponse.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Signed device capability image response. + public partial class SignedCapabilityImageResponse + { + /// Initializes a new instance of SignedCapabilityImageResponse. + internal SignedCapabilityImageResponse() + { + } + + /// Initializes a new instance of SignedCapabilityImageResponse. + /// The signed device capability image as a UTF-8 encoded base 64 string. + internal SignedCapabilityImageResponse(string image) + { + Image = image; + } + + /// The signed device capability image as a UTF-8 encoded base 64 string. + public string Image { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/UpdatePolicy.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/UpdatePolicy.cs new file mode 100644 index 0000000000000..9a0a1b06b6128 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/Models/UpdatePolicy.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sphere.Models +{ + /// Update policy values. + public readonly partial struct UpdatePolicy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public UpdatePolicy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UpdateAllValue = "UpdateAll"; + private const string No3RdPartyAppUpdatesValue = "No3rdPartyAppUpdates"; + + /// UpdateAll. + public static UpdatePolicy UpdateAll { get; } = new UpdatePolicy(UpdateAllValue); + /// No3rdPartyAppUpdates. + public static UpdatePolicy No3RdPartyAppUpdates { get; } = new UpdatePolicy(No3RdPartyAppUpdatesValue); + /// Determines if two values are the same. + public static bool operator ==(UpdatePolicy left, UpdatePolicy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(UpdatePolicy left, UpdatePolicy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator UpdatePolicy(string value) => new UpdatePolicy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UpdatePolicy other && Equals(other); + /// + public bool Equals(UpdatePolicy other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductCollection.cs new file mode 100644 index 0000000000000..c66f21cd8395e --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductCollection.cs @@ -0,0 +1,340 @@ +// 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 Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// 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 GetProducts method from an instance of . + /// + public partial class ProductCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _productClientDiagnostics; + private readonly ProductsRestOperations _productRestClient; + + /// Initializes a new instance of the class for mocking. + protected ProductCollection() + { + } + + /// 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 ProductCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _productClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ProductResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ProductResource.ResourceType, out string productApiVersion); + _productRestClient = new ProductsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, productApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != CatalogResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, CatalogResource.ResourceType), nameof(id)); + } + + /// + /// Create a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_CreateOrUpdate + /// + /// + /// + /// 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 product. + /// 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 productName, ProductData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _productRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, data, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new ProductOperationSource(Client), _productClientDiagnostics, Pipeline, _productRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, 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 Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_CreateOrUpdate + /// + /// + /// + /// 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 product. + /// 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 productName, ProductData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _productRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, data, cancellationToken); + var operation = new SphereArmOperation(new ProductOperationSource(Client), _productClientDiagnostics, Pipeline, _productRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.Get"); + scope.Start(); + try + { + var response = await _productRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ProductResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.Get"); + scope.Start(); + try + { + var response = _productRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ProductResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Product resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products + /// + /// + /// Operation Id + /// Products_ListByCatalog + /// + /// + /// + /// 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) => _productRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _productRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new ProductResource(Client, ProductData.DeserializeProductData(e)), _productClientDiagnostics, Pipeline, "ProductCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Product resources by Catalog + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products + /// + /// + /// Operation Id + /// Products_ListByCatalog + /// + /// + /// + /// 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) => _productRestClient.CreateListByCatalogRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _productRestClient.CreateListByCatalogNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new ProductResource(Client, ProductData.DeserializeProductData(e)), _productClientDiagnostics, Pipeline, "ProductCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.Exists"); + scope.Start(); + try + { + var response = await _productRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, 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.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// Name of product. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var scope = _productClientDiagnostics.CreateScope("ProductCollection.Exists"); + scope.Start(); + try + { + var response = _productRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, productName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, 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/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductData.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductData.cs new file mode 100644 index 0000000000000..353453744bc13 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductData.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A class representing the Product data model. + /// An product resource belonging to a catalog resource. + /// + public partial class ProductData : ResourceData + { + /// Initializes a new instance of ProductData. + public ProductData() + { + } + + /// Initializes a new instance of ProductData. + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of the product. + /// The status of the last operation. + internal ProductData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string description, ProvisioningState? provisioningState) : base(id, name, resourceType, systemData) + { + Description = description; + ProvisioningState = provisioningState; + } + + /// Description of the product. + public string Description { get; set; } + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductResource.cs new file mode 100644 index 0000000000000..102855fdc778f --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProductResource.cs @@ -0,0 +1,455 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + /// + /// A Class representing a Product 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 GetProductResource method. + /// Otherwise you can get one from its parent resource using the GetProduct method. + /// + public partial class ProductResource : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _productClientDiagnostics; + private readonly ProductsRestOperations _productRestClient; + private readonly ProductData _data; + + /// Initializes a new instance of the class for mocking. + protected ProductResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ProductResource(ArmClient client, ProductData 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 ProductResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _productClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sphere", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string productApiVersion); + _productRestClient = new ProductsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, productApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureSphere/catalogs/products"; + + /// 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 ProductData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of DeviceGroupResources in the Product. + /// An object representing collection of DeviceGroupResources and their operations over a DeviceGroupResource. + public virtual DeviceGroupCollection GetDeviceGroups() + { + return GetCachedClient(Client => new DeviceGroupCollection(Client, Id)); + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual async Task> GetDeviceGroupAsync(string deviceGroupName, CancellationToken cancellationToken = default) + { + return await GetDeviceGroups().GetAsync(deviceGroupName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/deviceGroups/{deviceGroupName} + /// + /// + /// Operation Id + /// DeviceGroups_Get + /// + /// + /// + /// Name of device group. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + [ForwardsClientCalls] + public virtual Response GetDeviceGroup(string deviceGroupName, CancellationToken cancellationToken = default) + { + return GetDeviceGroups().Get(deviceGroupName, cancellationToken); + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _productClientDiagnostics.CreateScope("ProductResource.Get"); + scope.Start(); + try + { + var response = await _productRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ProductResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Get + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _productClientDiagnostics.CreateScope("ProductResource.Get"); + scope.Start(); + try + { + var response = _productRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ProductResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name' + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Delete + /// + /// + /// + /// 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 = _productClientDiagnostics.CreateScope("ProductResource.Delete"); + scope.Start(); + try + { + var response = await _productRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(_productClientDiagnostics, Pipeline, _productRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name' + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Delete + /// + /// + /// + /// 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 = _productClientDiagnostics.CreateScope("ProductResource.Delete"); + scope.Start(); + try + { + var response = _productRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new SphereArmOperation(_productClientDiagnostics, Pipeline, _productRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, ProductPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _productClientDiagnostics.CreateScope("ProductResource.Update"); + scope.Start(); + try + { + var response = await _productRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new SphereArmOperation(new ProductOperationSource(Client), _productClientDiagnostics, Pipeline, _productRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName} + /// + /// + /// Operation Id + /// Products_Update + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, ProductPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _productClientDiagnostics.CreateScope("ProductResource.Update"); + scope.Start(); + try + { + var response = _productRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + var operation = new SphereArmOperation(new ProductOperationSource(Client), _productClientDiagnostics, Pipeline, _productRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/countDevices + /// + /// + /// Operation Id + /// Products_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> CountDevicesAsync(CancellationToken cancellationToken = default) + { + using var scope = _productClientDiagnostics.CreateScope("ProductResource.CountDevices"); + scope.Start(); + try + { + var response = await _productRestClient.CountDevicesAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Counts devices in product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/countDevices + /// + /// + /// Operation Id + /// Products_CountDevices + /// + /// + /// + /// The cancellation token to use. + public virtual Response CountDevices(CancellationToken cancellationToken = default) + { + using var scope = _productClientDiagnostics.CreateScope("ProductResource.CountDevices"); + scope.Start(); + try + { + var response = _productRestClient.CountDevices(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/generateDefaultDeviceGroups + /// + /// + /// Operation Id + /// Products_GenerateDefaultDeviceGroups + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GenerateDefaultDeviceGroupsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _productRestClient.CreateGenerateDefaultDeviceGroupsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _productRestClient.CreateGenerateDefaultDeviceGroupsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return PageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _productClientDiagnostics, Pipeline, "ProductResource.GenerateDefaultDeviceGroups", "value", "nextLink", cancellationToken); + } + + /// + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureSphere/catalogs/{catalogName}/products/{productName}/generateDefaultDeviceGroups + /// + /// + /// Operation Id + /// Products_GenerateDefaultDeviceGroups + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GenerateDefaultDeviceGroups(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _productRestClient.CreateGenerateDefaultDeviceGroupsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _productRestClient.CreateGenerateDefaultDeviceGroupsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return PageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DeviceGroupResource(Client, DeviceGroupData.DeserializeDeviceGroupData(e)), _productClientDiagnostics, Pipeline, "ProductResource.GenerateDefaultDeviceGroups", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProviderConstants.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/ProviderConstants.cs new file mode 100644 index 0000000000000..ac4dc170b17ea --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/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.Sphere +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CatalogsRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CatalogsRestOperations.cs new file mode 100644 index 0000000000000..0f14a3b36b3ed --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CatalogsRestOperations.cs @@ -0,0 +1,1477 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class CatalogsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CatalogsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public CatalogsRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Catalog resources by subscription ID. + /// The ID of the target subscription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Catalog resources by subscription ID. + /// The ID of the target subscription. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + 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.AzureSphere/catalogs", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Catalog resources by resource group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Catalog resources by resource group. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CatalogData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogData.DeserializeCatalogData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CatalogData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CatalogData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogData.DeserializeCatalogData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CatalogData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, CatalogData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CatalogData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, 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 Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CatalogData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, CatalogPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CatalogPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CatalogData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogData.DeserializeCatalogData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CatalogPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CatalogData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogData.DeserializeCatalogData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// 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 catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCountDevicesRequest(string subscriptionId, string resourceGroupName, string catalogName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/countDevices", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Counts devices in catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> CountDevicesAsync(string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Counts devices in catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CountDevices(string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentsRequest(string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/listDeployments", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists deployments for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeploymentsAsync(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeploymentsRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists deployments for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeployments(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeploymentsRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceGroupsRequest(string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/listDeviceGroups", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// List the device groups for the catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeviceGroupsAsync(string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateListDeviceGroupsRequest(subscriptionId, resourceGroupName, catalogName, content, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the device groups for the catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeviceGroups(string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateListDeviceGroupsRequest(subscriptionId, resourceGroupName, catalogName, content, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceInsightsRequest(string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/listDeviceInsights", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists device insights for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeviceInsightsAsync(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeviceInsightsRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PagedDeviceInsight value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PagedDeviceInsight.DeserializePagedDeviceInsight(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists device insights for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeviceInsights(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeviceInsightsRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PagedDeviceInsight value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PagedDeviceInsight.DeserializePagedDeviceInsight(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDevicesRequest(string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/listDevices", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists devices for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDevicesAsync(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDevicesRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists devices for catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDevices(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDevicesRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Catalog resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Catalog resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CatalogListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + 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 Catalog resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> 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: + { + CatalogListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Catalog resources by resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response 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: + { + CatalogListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CatalogListResult.DeserializeCatalogListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeploymentsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists deployments for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeploymentsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeploymentsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists deployments for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeploymentsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeploymentsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceGroupsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter, int? top, int? skip, int? maxpagesize) + { + 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 the device groups for the catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeviceGroupsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateListDeviceGroupsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, content, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the device groups for the catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// List device groups for catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeviceGroupsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, ListDeviceGroupsContent content, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateListDeviceGroupsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, content, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDeviceInsightsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists device insights for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDeviceInsightsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeviceInsightsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PagedDeviceInsight value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = PagedDeviceInsight.DeserializePagedDeviceInsight(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists device insights for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDeviceInsightsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDeviceInsightsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PagedDeviceInsight value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = PagedDeviceInsight.DeserializePagedDeviceInsight(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListDevicesNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists devices for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListDevicesNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDevicesNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists devices for catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListDevicesNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListDevicesNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CertificatesRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CertificatesRestOperations.cs new file mode 100644 index 0000000000000..3b65951993f9d --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/CertificatesRestOperations.cs @@ -0,0 +1,493 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class CertificatesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of CertificatesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public CertificatesRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByCatalogRequest(string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/certificates", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Certificate resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogAsync(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateListResult.DeserializeCertificateListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Certificate resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalog(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateListResult.DeserializeCertificateListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/certificates/", false); + uri.AppendPath(serialNumber, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Certificate. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// 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 catalogName, string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, serialNumber); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateData.DeserializeCertificateData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CertificateData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Certificate. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// 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 catalogName, string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, serialNumber); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateData.DeserializeCertificateData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((CertificateData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateRetrieveCertChainRequest(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/certificates/", false); + uri.AppendPath(serialNumber, true); + uri.AppendPath("/retrieveCertChain", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Retrieves cert chain. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> RetrieveCertChainAsync(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var message = CreateRetrieveCertChainRequest(subscriptionId, resourceGroupName, catalogName, serialNumber); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateChainResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateChainResponse.DeserializeCertificateChainResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Retrieves cert chain. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response RetrieveCertChain(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + + using var message = CreateRetrieveCertChainRequest(subscriptionId, resourceGroupName, catalogName, serialNumber); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateChainResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateChainResponse.DeserializeCertificateChainResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateRetrieveProofOfPossessionNonceRequest(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber, ProofOfPossessionNonceContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/certificates/", false); + uri.AppendPath(serialNumber, true); + uri.AppendPath("/retrieveProofOfPossessionNonce", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Gets the proof of possession nonce. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// Proof of possession nonce request body. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> RetrieveProofOfPossessionNonceAsync(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber, ProofOfPossessionNonceContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateRetrieveProofOfPossessionNonceRequest(subscriptionId, resourceGroupName, catalogName, serialNumber, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProofOfPossessionNonceResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ProofOfPossessionNonceResponse.DeserializeProofOfPossessionNonceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the proof of possession nonce. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Serial number of the certificate. Use '.default' to get current active certificate. + /// Proof of possession nonce request body. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response RetrieveProofOfPossessionNonce(string subscriptionId, string resourceGroupName, string catalogName, string serialNumber, ProofOfPossessionNonceContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(serialNumber, nameof(serialNumber)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateRetrieveProofOfPossessionNonceRequest(subscriptionId, resourceGroupName, catalogName, serialNumber, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProofOfPossessionNonceResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ProofOfPossessionNonceResponse.DeserializeProofOfPossessionNonceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByCatalogNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + 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 Certificate resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CertificateListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CertificateListResult.DeserializeCertificateListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Certificate resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalogNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CertificateListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CertificateListResult.DeserializeCertificateListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeploymentsRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeploymentsRestOperations.cs new file mode 100644 index 0000000000000..7fca60bca2737 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeploymentsRestOperations.cs @@ -0,0 +1,533 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class DeploymentsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DeploymentsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public DeploymentsRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByDeviceGroupRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter, int? top, int? skip, int? maxpagesize) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/deployments", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> ListByDeviceGroupAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ListByDeviceGroup(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deploymentName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentData.DeserializeDeploymentData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeploymentData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentData.DeserializeDeploymentData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeploymentData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deploymentName, DeploymentData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, 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 Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, DeploymentData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deploymentName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Deployment. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Deployment name. Use .default for deployment creation and to get the current deployment for the associated device group. + /// 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 catalogName, string productName, string deviceGroupName, string deploymentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deploymentName, nameof(deploymentName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByDeviceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter, int? top, int? skip, int? maxpagesize) + { + 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 Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> ListByDeviceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Deployment resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ListByDeviceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeploymentListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeviceGroupsRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeviceGroupsRestOperations.cs new file mode 100644 index 0000000000000..fbab378e617dd --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DeviceGroupsRestOperations.cs @@ -0,0 +1,775 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class DeviceGroupsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DeviceGroupsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public DeviceGroupsRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByProductRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter, int? top, int? skip, int? maxpagesize) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByProductAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateListByProductRequest(subscriptionId, resourceGroupName, catalogName, productName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByProduct(string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateListByProductRequest(subscriptionId, resourceGroupName, catalogName, productName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupData.DeserializeDeviceGroupData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeviceGroupData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupData.DeserializeDeviceGroupData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeviceGroupData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, DeviceGroupData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, DeviceGroupData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, 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 DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, DeviceGroupData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, DeviceGroupPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, DeviceGroupPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// 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 catalogName, string productName, string deviceGroupName, DeviceGroupPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateClaimDevicesRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, ClaimDevicesContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/claimDevices", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when bulk claiming devices to a catalog only. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Bulk claim devices request body. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task ClaimDevicesAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, ClaimDevicesContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateClaimDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Bulk claims the devices. Use '.unassigned' or '.default' for the device group and product names when bulk claiming devices to a catalog only. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Bulk claim devices request body. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ClaimDevices(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, ClaimDevicesContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateClaimDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCountDevicesRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/countDevices", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Counts devices in device group. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> CountDevicesAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Counts devices in device group. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response CountDevices(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByProductNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter, int? top, int? skip, int? maxpagesize) + { + 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 DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByProductNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateListByProductNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List DeviceGroup resources by Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByProductNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateListByProductNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DevicesRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DevicesRestOperations.cs new file mode 100644 index 0000000000000..cb9562cfa5c5d --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/DevicesRestOperations.cs @@ -0,0 +1,694 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class DevicesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of DevicesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public DevicesRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByDeviceGroupRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> ListByDeviceGroupAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ListByDeviceGroup(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices/", false); + uri.AppendPath(deviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceData.DeserializeDeviceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeviceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Device. Use '.unassigned' or '.default' for the device group and product names when a device does not belong to a device group and product. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceData.DeserializeDeviceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DeviceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, DeviceData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices/", false); + uri.AppendPath(deviceName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a Device. Use '.unassigned' or '.default' for the device group and product names to claim a device to the catalog only. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// 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 catalogName, string productName, string deviceGroupName, string deviceName, DeviceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, 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 Device. Use '.unassigned' or '.default' for the device group and product names to claim a device to the catalog only. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// 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 catalogName, string productName, string deviceGroupName, string deviceName, DeviceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices/", false); + uri.AppendPath(deviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Device. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Device. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, DevicePatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices/", false); + uri.AppendPath(deviceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device to the catalog level. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// 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 catalogName, string productName, string deviceGroupName, string deviceName, DevicePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Device. Use '.unassigned' or '.default' for the device group and product names to move a device to the catalog level. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// 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 catalogName, string productName, string deviceGroupName, string deviceName, DevicePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGenerateCapabilityImageRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, GenerateCapabilityImageContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/deviceGroups/", false); + uri.AppendPath(deviceGroupName, true); + uri.AppendPath("/devices/", false); + uri.AppendPath(deviceName, true); + uri.AppendPath("/generateCapabilityImage", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Generates the capability image for the device. Use '.unassigned' or '.default' for the device group and product names to generate the image for a device that does not belong to a specific device group and product. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// Generate capability image request body. + /// The cancellation token to use. + /// , , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public async Task GenerateCapabilityImageAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, GenerateCapabilityImageContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGenerateCapabilityImageRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Generates the capability image for the device. Use '.unassigned' or '.default' for the device group and product names to generate the image for a device that does not belong to a specific device group and product. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// Device name. + /// Generate capability image request body. + /// The cancellation token to use. + /// , , , , , or is null. + /// , , , , or is an empty string, and was expected to be non-empty. + public Response GenerateCapabilityImage(string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, string deviceName, GenerateCapabilityImageContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + Argument.AssertNotNullOrEmpty(deviceName, nameof(deviceName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGenerateCapabilityImageRequest(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByDeviceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName) + { + 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 Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> ListByDeviceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Device resources by DeviceGroup. '.default' and '.unassigned' are system defined values and cannot be used for product or device group name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// Name of device group. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ListByDeviceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, string deviceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNullOrEmpty(deviceGroupName, nameof(deviceGroupName)); + + using var message = CreateListByDeviceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceListResult.DeserializeDeviceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ImagesRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ImagesRestOperations.cs new file mode 100644 index 0000000000000..23c913288ce31 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ImagesRestOperations.cs @@ -0,0 +1,477 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class ImagesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ImagesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ImagesRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByCatalogRequest(string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/images", false); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + if (skip != null) + { + uri.AppendQuery("$skip", skip.Value, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("$maxpagesize", maxpagesize.Value, true); + } + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Image resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogAsync(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ImageListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ImageListResult.DeserializeImageListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Image resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalog(string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ImageListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ImageListResult.DeserializeImageListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string imageName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/images/", false); + uri.AppendPath(imageName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, imageName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ImageData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ImageData.DeserializeImageData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ImageData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, imageName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ImageData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ImageData.DeserializeImageData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ImageData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string imageName, ImageData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/images/", false); + uri.AppendPath(imageName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, imageName, 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 Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, ImageData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, imageName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName, string imageName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/images/", false); + uri.AppendPath(imageName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, imageName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Image. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Image name. Use .default for image creation. + /// 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 catalogName, string imageName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(imageName, nameof(imageName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, imageName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByCatalogNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter, int? top, int? skip, int? maxpagesize) + { + 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 Image resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ImageListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ImageListResult.DeserializeImageListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Image resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Filter the result list using the given expression. + /// The number of result items to return. + /// The number of result items to skip. + /// The maximum number of result items per page. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalogNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string filter = null, int? top = null, int? skip = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, filter, top, skip, maxpagesize); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ImageListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ImageListResult.DeserializeImageListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ProductsRestOperations.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ProductsRestOperations.cs new file mode 100644 index 0000000000000..32eb899d2dabb --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/Generated/RestOperations/ProductsRestOperations.cs @@ -0,0 +1,779 @@ +// 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; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Sphere.Models; + +namespace Azure.ResourceManager.Sphere +{ + internal partial class ProductsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ProductsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public ProductsRestOperations(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 ?? "2022-09-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal HttpMessage CreateListByCatalogRequest(string subscriptionId, string resourceGroupName, string catalogName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Product resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogAsync(string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ProductListResult.DeserializeProductListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Product resources by Catalog. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalog(string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogRequest(subscriptionId, resourceGroupName, catalogName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ProductListResult.DeserializeProductListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ProductData.DeserializeProductData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ProductData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, catalogName, productName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ProductData.DeserializeProductData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ProductData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, ProductData 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, 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); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, ProductData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, 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 Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, ProductData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + 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.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name'. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name'. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, catalogName, productName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName, ProductPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, ProductPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// 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 catalogName, string productName, ProductPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, catalogName, productName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCountDevicesRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/countDevices", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Counts devices in product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CountDevicesAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Counts devices in product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CountDevices(string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateCountDevicesRequest(subscriptionId, resourceGroupName, catalogName, productName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CountDeviceResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CountDeviceResponse.DeserializeCountDeviceResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGenerateDefaultDeviceGroupsRequest(string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.AzureSphere/catalogs/", false); + uri.AppendPath(catalogName, true); + uri.AppendPath("/products/", false); + uri.AppendPath(productName, true); + uri.AppendPath("/generateDefaultDeviceGroups", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GenerateDefaultDeviceGroupsAsync(string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGenerateDefaultDeviceGroupsRequest(subscriptionId, resourceGroupName, catalogName, productName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response GenerateDefaultDeviceGroups(string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGenerateDefaultDeviceGroupsRequest(subscriptionId, resourceGroupName, catalogName, productName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByCatalogNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName) + { + 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 Product resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByCatalogNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ProductListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ProductListResult.DeserializeProductListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Product resources by Catalog. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByCatalogNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + + using var message = CreateListByCatalogNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ProductListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ProductListResult.DeserializeProductListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGenerateDefaultDeviceGroupsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName) + { + 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; + } + + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GenerateDefaultDeviceGroupsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGenerateDefaultDeviceGroupsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Generates default device groups for the product. '.default' and '.unassigned' are system defined values and cannot be used for product name. + /// The URL to the next page of results. + /// The ID of the target subscription. + /// The name of the resource group. The name is case insensitive. + /// Name of catalog. + /// Name of product. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response GenerateDefaultDeviceGroupsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string catalogName, string productName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(catalogName, nameof(catalogName)); + Argument.AssertNotNullOrEmpty(productName, nameof(productName)); + + using var message = CreateGenerateDefaultDeviceGroupsNextPageRequest(nextLink, subscriptionId, resourceGroupName, catalogName, productName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeviceGroupListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeviceGroupListResult.DeserializeDeviceGroupListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/Properties/AssemblyInfo.cs b/sdk/sphere/Azure.ResourceManager.Sphere/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..eaeca44142fc8 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/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("sphere")] + +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] +[assembly: InternalsVisibleTo("Azure.ResourceManager.Sphere.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/src/autorest.md b/sdk/sphere/Azure.ResourceManager.Sphere/src/autorest.md new file mode 100644 index 0000000000000..4d826c1fdceb5 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/src/autorest.md @@ -0,0 +1,49 @@ +# Generated code configuration + +Run `dotnet build /t:GenerateCode` to generate code. + +``` yaml +azure-arm: true +csharp: true +library-name: sphere +namespace: Azure.ResourceManager.sphere +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/sphere/resource-manager/readme.md +output-folder: $(this-folder)/Generated +clear-output-folder: true +skip-csproj: true +modelerfour: + flatten-payloads: false + + + +format-by-name-rules: + 'tenantId': 'uuid' + 'ETag': 'etag' + 'location': 'azure-location' + '*Uri': 'Uri' + '*Uris': 'Uri' + +rename-rules: + CPU: Cpu + CPUs: Cpus + Os: OS + Ip: IP + Ips: IPs|ips + ID: Id + IDs: Ids + VM: Vm + VMs: Vms + Vmos: VmOS + VMScaleSet: VmScaleSet + DNS: Dns + VPN: Vpn + NAT: Nat + WAN: Wan + Ipv4: IPv4|ipv4 + Ipv6: IPv6|ipv6 + Ipsec: IPsec|ipsec + SSO: Sso + URI: Uri + Etag: ETag|etag + +``` diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/tests/Azure.ResourceManager.Sphere.Tests.csproj b/sdk/sphere/Azure.ResourceManager.Sphere/tests/Azure.ResourceManager.Sphere.Tests.csproj new file mode 100644 index 0000000000000..6628cbec1dfc2 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/tests/Azure.ResourceManager.Sphere.Tests.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestBase.cs b/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestBase.cs new file mode 100644 index 0000000000000..a4449b3d7b2a0 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestBase.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Sphere.Tests +{ + public class sphereManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected sphereManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected sphereManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + 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; + } + } +} diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestEnvironment.cs b/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestEnvironment.cs new file mode 100644 index 0000000000000..452a11f5f5371 --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/tests/sphereManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Sphere.Tests +{ + public class sphereManagementTestEnvironment : TestEnvironment + { + } +} \ No newline at end of file diff --git a/sdk/sphere/ci.mgmt.yml b/sdk/sphere/ci.mgmt.yml new file mode 100644 index 0000000000000..01d6456b21129 --- /dev/null +++ b/sdk/sphere/ci.mgmt.yml @@ -0,0 +1,24 @@ +# 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/sphere/ci.mgmt.yml + - sdk/sphere/Azure.ResourceManager.Sphere/ + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: sphere + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Sphere + safeName: AzureResourceManagerSphere