diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Azure.ResourceManager.Notificationhubs.sln b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Azure.ResourceManager.Notificationhubs.sln new file mode 100644 index 000000000000..3eb7376a4155 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Azure.ResourceManager.Notificationhubs.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.Notificationhubs.Samples", "samples\Azure.ResourceManager.Notificationhubs.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Notificationhubs", "src\Azure.ResourceManager.Notificationhubs.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Notificationhubs.Tests", "tests\Azure.ResourceManager.Notificationhubs.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/CHANGELOG.md b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Directory.Build.props b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/README.md b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/README.md new file mode 100644 index 000000000000..cf5869aa2ce7 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure Notificationhubs 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 Notificationhubs management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Notificationhubs --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/assets.json b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/assets.json new file mode 100644 index 000000000000..ea46a87ee6ad --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/notificationhubs/Azure.ResourceManager.Notificationhubs", + "Tag": "" +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Azure.ResourceManager.Notificationhubs.Samples.csproj b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Azure.ResourceManager.Notificationhubs.Samples.csproj new file mode 100644 index 000000000000..57f6e86ade53 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Azure.ResourceManager.Notificationhubs.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 000000000000..4f3ef8f5f269 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Notificationhubs.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Notificationhubs.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOperations_OperationsList() + { + // Generated from example definition: 2023-10-01-preview/NHOperationsList.json + // this example is just showing the usage of "Operations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation and iterate over the result + await foreach (Info item in tenantResource.GetOperationsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Azure.ResourceManager.Notificationhubs.csproj b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Azure.ResourceManager.Notificationhubs.csproj new file mode 100644 index 000000000000..b96ea7ffb777 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Azure.ResourceManager.Notificationhubs.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider Notificationhubs. + 1.0.0-beta.1 + azure;management;arm;resource manager;notificationhubs + Azure.ResourceManager.Notificationhubs + + diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/ArmNotificationhubsModelFactory.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/ArmNotificationhubsModelFactory.cs new file mode 100644 index 000000000000..c708b4b384f2 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/ArmNotificationhubsModelFactory.cs @@ -0,0 +1,631 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Model factory for models. + public static partial class ArmNotificationhubsModelFactory + { + /// Initializes a new instance of . + /// The name of the operation being performed on this particular object.". + /// he localized display information for this particular operation / action. + /// The intended executor of the operation.". + /// Additional descriptions for the operation. + /// A new instance for mocking. + public static Info Info(string name = null, OperationDisplay display = null, bool? isDataAction = null, ServiceSpecification operationServiceSpecification = null) + { + return new Info(name, display, isDataAction, operationServiceSpecification != null ? new OperationProperties(operationServiceSpecification, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// A new instance for mocking. + public static OperationDisplay OperationDisplay(string provider = null, string resource = null, string operation = null, string description = null) + { + return new OperationDisplay(provider, resource, operation, description, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Log specifications. + /// Metric specification. + /// A new instance for mocking. + public static ServiceSpecification ServiceSpecification(IEnumerable logSpecifications = null, IEnumerable metricSpecifications = null) + { + logSpecifications ??= new List(); + metricSpecifications ??= new List(); + + return new ServiceSpecification(logSpecifications?.ToList(), metricSpecifications?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the log category. + /// Display name of the log category. + /// Duration of data written to a single blob. + /// Category group for the log specification. + /// A new instance for mocking. + public static LogSpecification LogSpecification(string name = null, string displayName = null, string blobDuration = null, IEnumerable categoryGroups = null) + { + categoryGroups ??= new List(); + + return new LogSpecification(name, displayName, blobDuration, categoryGroups?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Metric name / id. + /// User-visible metric name. + /// Description of the metric. + /// Metric unit. + /// Type of the aggregation (Average, Minimum, Maximum, Total or Count). + /// List of availabilities. + /// List of supported time grain types. + /// The matching regex pattern to be applied to the field pointed by the "metricsFilterPathSelector" flag in the ARM manifest. + /// Optional property. If set to true, then zero will be returned for time duration where no metric is emitted / published. + /// A new instance for mocking. + public static MetricSpecification MetricSpecification(string name = null, string displayName = null, string displayDescription = null, string unit = null, string aggregationType = null, IEnumerable availabilities = null, IEnumerable supportedTimeGrainTypes = null, string metricFilterPattern = null, bool? fillGapWithZero = null) + { + availabilities ??= new List(); + supportedTimeGrainTypes ??= new List(); + + return new MetricSpecification( + name, + displayName, + displayDescription, + unit, + aggregationType, + availabilities?.ToList(), + supportedTimeGrainTypes?.ToList(), + metricFilterPattern, + fillGapWithZero, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Time grain of the availability. + /// Duration of the availability blob. + /// A new instance for mocking. + public static Availability Availability(string timeGrain = null, string blobDuration = null) + { + return new Availability(timeGrain, blobDuration, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Gets or sets the RegistrationTtl of the created NotificationHub. + /// Gets or sets the AuthorizationRules of the created NotificationHub. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// + /// The Sku description for a namespace. + /// A new instance for mocking. + public static NotificationHubResourceData NotificationHubResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, string registrationTtl = null, IEnumerable authorizationRules = null, ApnsCredential apnsCredential = null, WnsCredential wnsCredential = null, GcmCredential gcmCredential = null, MpnsCredential mpnsCredential = null, AdmCredential admCredential = null, BaiduCredential baiduCredential = null, BrowserCredential browserCredential = null, XiaomiCredential xiaomiCredential = null, FcmV1Credential fcmV1Credential = null, long? dailyMaxActiveDevices = null, NotificationhubsSku sku = null) + { + tags ??= new Dictionary(); + authorizationRules ??= new List(); + + return new NotificationHubResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + registrationTtl, + authorizationRules?.ToList(), + apnsCredential, + wnsCredential, + gcmCredential, + mpnsCredential, + admCredential, + baiduCredential, + browserCredential, + xiaomiCredential, + fcmV1Credential, + dailyMaxActiveDevices, + sku, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets the rights associated with the rule. + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// Gets a string that describes the authorization rule. + /// Gets the last modified time for this rule. + /// Gets the created time for this rule. + /// Gets a string that describes the claim type. + /// Gets a string that describes the claim value. + /// Gets the revision number for the rule. + /// A new instance for mocking. + public static SharedAccessAuthorizationRuleProperties SharedAccessAuthorizationRuleProperties(IEnumerable rights = null, string primaryKey = null, string secondaryKey = null, string keyName = null, DateTimeOffset? modifiedOn = null, DateTimeOffset? createdOn = null, string claimType = null, string claimValue = null, int? revision = null) + { + rights ??= new List(); + + return new SharedAccessAuthorizationRuleProperties( + rights?.ToList(), + primaryKey, + secondaryKey, + keyName, + modifiedOn, + createdOn, + claimType, + claimValue, + revision, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets the NotificationHub name. + /// Gets or sets the RegistrationTtl of the created NotificationHub. + /// Gets or sets the AuthorizationRules of the created NotificationHub. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// + /// The Sku description for a namespace. + /// Dictionary of <string>. + /// A new instance for mocking. + public static NotificationHubResourcePatch NotificationHubResourcePatch(string name = null, string registrationTtl = null, IEnumerable authorizationRules = null, ApnsCredential apnsCredential = null, WnsCredential wnsCredential = null, GcmCredential gcmCredential = null, MpnsCredential mpnsCredential = null, AdmCredential admCredential = null, BaiduCredential baiduCredential = null, BrowserCredential browserCredential = null, XiaomiCredential xiaomiCredential = null, FcmV1Credential fcmV1Credential = null, long? dailyMaxActiveDevices = null, NotificationhubsSku sku = null, IDictionary tags = null) + { + authorizationRules ??= new List(); + tags ??= new Dictionary(); + + return new NotificationHubResourcePatch( + name, + registrationTtl, + authorizationRules?.ToList(), + apnsCredential, + wnsCredential, + gcmCredential, + mpnsCredential, + admCredential, + baiduCredential, + browserCredential, + xiaomiCredential, + fcmV1Credential, + dailyMaxActiveDevices, + sku, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Gets or sets successful send. + /// Gets or sets send failure. + /// Gets or sets actual failure description. + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// A new instance for mocking. + public static DebugSendResponseResult DebugSendResponseResult(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, long? success = null, long? failure = null, IEnumerable results = null, string location = null, IReadOnlyDictionary tags = null) + { + results ??= new List(); + tags ??= new Dictionary(); + + return new DebugSendResponseResult( + id, + name, + resourceType, + systemData, + success, + failure, + results?.ToList(), + location, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// PNS type. + /// PNS handle. + /// Registration id. + /// Notification outcome. + /// A new instance for mocking. + public static RegistrationResult RegistrationResult(string applicationPlatform = null, string pnsHandle = null, string registrationId = null, string outcome = null) + { + return new RegistrationResult(applicationPlatform, pnsHandle, registrationId, outcome, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// A new instance for mocking. + public static PnsCredentialsResource PnsCredentialsResource(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, AdmCredential admCredential = null, ApnsCredential apnsCredential = null, BaiduCredential baiduCredential = null, BrowserCredential browserCredential = null, GcmCredential gcmCredential = null, MpnsCredential mpnsCredential = null, WnsCredential wnsCredential = null, XiaomiCredential xiaomiCredential = null, FcmV1Credential fcmV1Credential = null, string location = null, IReadOnlyDictionary tags = null) + { + tags ??= new Dictionary(); + + return new PnsCredentialsResource( + id, + name, + resourceType, + systemData, + admCredential, + apnsCredential, + baiduCredential, + browserCredential, + gcmCredential, + mpnsCredential, + wnsCredential, + xiaomiCredential, + fcmV1Credential, + location, + tags, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The Sku description for a namespace. + /// Defines values for OperationProvisioningState. + /// Namespace status. + /// Gets or sets whether or not the namespace is currently enabled. + /// Gets or sets whether or not the namespace is set as Critical. + /// Namespace subscription id. + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + /// Azure Insights Metrics id. + /// Time when the namespace was created. + /// Time when the namespace was updated. + /// Defines values for NamespaceType. + /// Allowed replication region. + /// Namespace SKU name. + /// A collection of network authorization rules. + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + /// Private Endpoint Connections for namespace. + /// Gets or sets scaleUnit where the namespace gets created. + /// Deprecated. + /// Type of public network access. + /// A new instance for mocking. + public static NamespaceResourceData NamespaceResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, NotificationhubsSku sku = null, OperationProvisioningState? provisioningState = null, NamespaceStatus? status = null, bool? enabled = null, bool? critical = null, string subscriptionId = null, string region = null, string metricId = null, DateTimeOffset? createdOn = null, DateTimeOffset? updatedOn = null, NamespaceType? namespaceType = null, ReplicationRegion? replicationRegion = null, ZoneRedundancyPreference? zoneRedundancy = null, NetworkAcls networkAcls = null, PnsCredentials pnsCredentials = null, string serviceBusEndpoint = null, IEnumerable privateEndpointConnections = null, string scaleUnit = null, string dataCenter = null, PublicNetworkAccess? publicNetworkAccess = null) + { + tags ??= new Dictionary(); + privateEndpointConnections ??= new List(); + + return new NamespaceResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + sku, + provisioningState, + status, + enabled, + critical, + subscriptionId, + region, + metricId, + createdOn, + updatedOn, + namespaceType, + replicationRegion, + zoneRedundancy, + networkAcls, + pnsCredentials, + serviceBusEndpoint, + privateEndpointConnections?.ToList(), + scaleUnit, + dataCenter, + publicNetworkAccess, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Name of the Notification Hubs namespace. This is immutable property, set automatically + /// by the service when the namespace is created. + /// + /// Defines values for OperationProvisioningState. + /// Namespace status. + /// Gets or sets whether or not the namespace is currently enabled. + /// Gets or sets whether or not the namespace is set as Critical. + /// Namespace subscription id. + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + /// Azure Insights Metrics id. + /// Time when the namespace was created. + /// Time when the namespace was updated. + /// Defines values for NamespaceType. + /// Allowed replication region. + /// Namespace SKU name. + /// A collection of network authorization rules. + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + /// Private Endpoint Connections for namespace. + /// Gets or sets scaleUnit where the namespace gets created. + /// Deprecated. + /// Type of public network access. + /// A new instance for mocking. + public static NamespaceProperties NamespaceProperties(string name = null, OperationProvisioningState? provisioningState = null, NamespaceStatus? status = null, bool? enabled = null, bool? critical = null, string subscriptionId = null, string region = null, string metricId = null, DateTimeOffset? createdOn = null, DateTimeOffset? updatedOn = null, NamespaceType? namespaceType = null, ReplicationRegion? replicationRegion = null, ZoneRedundancyPreference? zoneRedundancy = null, NetworkAcls networkAcls = null, PnsCredentials pnsCredentials = null, string serviceBusEndpoint = null, IEnumerable privateEndpointConnections = null, string scaleUnit = null, string dataCenter = null, PublicNetworkAccess? publicNetworkAccess = null) + { + privateEndpointConnections ??= new List(); + + return new NamespaceProperties( + name, + provisioningState, + status, + enabled, + critical, + subscriptionId, + region, + metricId, + createdOn, + updatedOn, + namespaceType, + replicationRegion, + zoneRedundancy, + networkAcls, + pnsCredentials, + serviceBusEndpoint, + privateEndpointConnections?.ToList(), + scaleUnit, + dataCenter, + publicNetworkAccess, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Private Endpoint Connection properties. + /// A new instance for mocking. + public static PrivateEndpointConnectionResourceData PrivateEndpointConnectionResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, PrivateEndpointConnectionProperties properties = null) + { + return new PrivateEndpointConnectionResourceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// State of Private Endpoint Connection. + /// Represents a Private Endpoint that is connected to Notification Hubs namespace using Private Endpoint Connection. + /// List of group ids. For Notification Hubs, it always contains a single "namespace" element. + /// State of the Private Link Service connection. + /// A new instance for mocking. + public static PrivateEndpointConnectionProperties PrivateEndpointConnectionProperties(NotificationhubsPrivateEndpointConnectionProvisioningState? provisioningState = null, ResourceIdentifier privateEndpointId = null, IEnumerable groupIds = null, RemotePrivateLinkServiceConnectionState privateLinkServiceConnectionState = null) + { + groupIds ??= new List(); + + return new PrivateEndpointConnectionProperties(provisioningState, privateEndpointId != null ? ResourceManagerModelFactory.SubResource(privateEndpointId) : null, groupIds?.ToList(), privateLinkServiceConnectionState, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// State of Private Link Connection. + /// Human-friendly description. + /// Human-friendly description of required actions. + /// A new instance for mocking. + public static RemotePrivateLinkServiceConnectionState RemotePrivateLinkServiceConnectionState(PrivateLinkConnectionStatus? status = null, string description = null, string actionsRequired = null) + { + return new RemotePrivateLinkServiceConnectionState(status, description, actionsRequired, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Not used and deprecated since API version 2023-01-01-preview. + /// The Sku description for a namespace. + /// A new instance for mocking. + public static CheckAvailabilityContent CheckAvailabilityContent(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, bool? isAvailiable = null, NotificationhubsSku sku = null) + { + tags ??= new Dictionary(); + + return new CheckAvailabilityContent( + id, + name, + resourceType, + systemData, + tags, + location, + isAvailiable, + sku, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// + /// Gets or sets true if the name is available and can be used to + /// create new Namespace/NotificationHub. Otherwise false. + /// + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// The Sku description for a namespace. + /// A new instance for mocking. + public static CheckAvailabilityResult CheckAvailabilityResult(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, bool? isAvailiable = null, string location = null, IReadOnlyDictionary tags = null, NotificationhubsSku sku = null) + { + tags ??= new Dictionary(); + + return new CheckAvailabilityResult( + id, + name, + resourceType, + systemData, + isAvailiable, + location, + tags, + sku, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Gets or sets the rights associated with the rule. + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// Gets a string that describes the authorization rule. + /// Gets the last modified time for this rule. + /// Gets the created time for this rule. + /// Gets a string that describes the claim type. + /// Gets a string that describes the claim value. + /// Gets the revision number for the rule. + /// A new instance for mocking. + public static SharedAccessAuthorizationRuleResourceData SharedAccessAuthorizationRuleResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, IEnumerable rights = null, string primaryKey = null, string secondaryKey = null, string keyName = null, DateTimeOffset? modifiedOn = null, DateTimeOffset? createdOn = null, string claimType = null, string claimValue = null, int? revision = null) + { + tags ??= new Dictionary(); + rights ??= new List(); + + return new SharedAccessAuthorizationRuleResourceData( + id, + name, + resourceType, + systemData, + tags, + location, + rights?.ToList(), + primaryKey, + secondaryKey, + keyName, + modifiedOn, + createdOn, + claimType, + claimValue, + revision, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets primaryConnectionString of the AuthorizationRule. + /// + /// Gets or sets secondaryConnectionString of the created + /// AuthorizationRule + /// + /// Gets or sets primaryKey of the created AuthorizationRule. + /// Gets or sets secondaryKey of the created AuthorizationRule. + /// Gets or sets keyName of the created AuthorizationRule. + /// A new instance for mocking. + public static ResourceListKeys ResourceListKeys(string primaryConnectionString = null, string secondaryConnectionString = null, string primaryKey = null, string secondaryKey = null, string keyName = null) + { + return new ResourceListKeys( + primaryConnectionString, + secondaryConnectionString, + primaryKey, + secondaryKey, + keyName, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Represents properties of Private Link Resource. + /// A new instance for mocking. + public static NotificationhubsPrivateLinkResourceDataData NotificationhubsPrivateLinkResourceDataData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, NotificationhubsPrivateLinkResourceProperties properties = null) + { + return new NotificationhubsPrivateLinkResourceDataData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// A Group Id for Private Link. For Notification Hubs, it is always set to "namespace". + /// Required members. For Notification Hubs, it's always a collection with a single "namespace" item. + /// Required DNS zone names. For Notification Hubs, it contains two CNames for Service Bus and Notification Hubs zones. + /// A new instance for mocking. + public static NotificationhubsPrivateLinkResourceProperties NotificationhubsPrivateLinkResourceProperties(string groupId = null, IEnumerable requiredMembers = null, IEnumerable requiredZoneNames = null) + { + requiredMembers ??= new List(); + requiredZoneNames ??= new List(); + + return new NotificationhubsPrivateLinkResourceProperties(groupId, requiredMembers?.ToList(), requiredZoneNames?.ToList(), serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsArmClient.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsArmClient.cs new file mode 100644 index 000000000000..8fc7ed7b5ab3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsArmClient.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableNotificationhubsArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableNotificationhubsArmClient() + { + } + + /// 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 MockableNotificationhubsArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableNotificationhubsArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NotificationHubResource GetNotificationHubResource(ResourceIdentifier id) + { + NotificationHubResource.ValidateResourceId(id); + return new NotificationHubResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NamespaceResource GetNamespaceResource(ResourceIdentifier id) + { + NamespaceResource.ValidateResourceId(id); + return new NamespaceResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NamespaceNotificationHubAuthorizationRuleResource GetNamespaceNotificationHubAuthorizationRuleResource(ResourceIdentifier id) + { + NamespaceNotificationHubAuthorizationRuleResource.ValidateResourceId(id); + return new NamespaceNotificationHubAuthorizationRuleResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NamespaceAuthorizationRuleResource GetNamespaceAuthorizationRuleResource(ResourceIdentifier id) + { + NamespaceAuthorizationRuleResource.ValidateResourceId(id); + return new NamespaceAuthorizationRuleResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual PrivateEndpointConnectionResource GetPrivateEndpointConnectionResource(ResourceIdentifier id) + { + PrivateEndpointConnectionResource.ValidateResourceId(id); + return new PrivateEndpointConnectionResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual NotificationhubsPrivateLinkResourceDataResource GetNotificationhubsPrivateLinkResourceDataResource(ResourceIdentifier id) + { + NotificationhubsPrivateLinkResourceDataResource.ValidateResourceId(id); + return new NotificationhubsPrivateLinkResourceDataResource(Client, id); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsResourceGroupResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsResourceGroupResource.cs new file mode 100644 index 000000000000..ed13a5d526f3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsResourceGroupResource.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableNotificationhubsResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableNotificationhubsResourceGroupResource() + { + } + + /// 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 MockableNotificationhubsResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of NamespaceResources in the ResourceGroupResource. + /// An object representing collection of NamespaceResources and their operations over a NamespaceResource. + public virtual NamespaceResourceCollection GetNamespaceResources() + { + return GetCachedClient(client => new NamespaceResourceCollection(client, Id)); + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNamespaceResourceAsync(string namespaceName, CancellationToken cancellationToken = default) + { + return await GetNamespaceResources().GetAsync(namespaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNamespaceResource(string namespaceName, CancellationToken cancellationToken = default) + { + return GetNamespaceResources().Get(namespaceName, cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsSubscriptionResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsSubscriptionResource.cs new file mode 100644 index 000000000000..1792f2f005db --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsSubscriptionResource.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableNotificationhubsSubscriptionResource : ArmResource + { + private ClientDiagnostics _namespaceResourceClientDiagnostics; + private NamespaceResourcesRestOperations _namespaceResourceRestClient; + private ClientDiagnostics _namespacesOperationGroupClientDiagnostics; + private NamespacesOperationGroupRestOperations _namespacesOperationGroupRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableNotificationhubsSubscriptionResource() + { + } + + /// 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 MockableNotificationhubsSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics NamespaceResourceClientDiagnostics => _namespaceResourceClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NamespaceResource.ResourceType.Namespace, Diagnostics); + private NamespaceResourcesRestOperations NamespaceResourceRestClient => _namespaceResourceRestClient ??= new NamespaceResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(NamespaceResource.ResourceType)); + private ClientDiagnostics NamespacesOperationGroupClientDiagnostics => _namespacesOperationGroupClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private NamespacesOperationGroupRestOperations NamespacesOperationGroupRestClient => _namespacesOperationGroupRestClient ??= new NamespacesOperationGroupRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Lists all the available namespaces within the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_ListAll + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetNamespaceResourcesAsync(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => NamespaceResourceRestClient.CreateListAllRequest(Id.SubscriptionId, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => NamespaceResourceRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, skipToken, top); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NamespaceResource(Client, NamespaceResourceData.DeserializeNamespaceResourceData(e)), NamespaceResourceClientDiagnostics, Pipeline, "MockableNotificationhubsSubscriptionResource.GetNamespaceResources", "value", "nextLink", cancellationToken); + } + + /// + /// Lists all the available namespaces within the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_ListAll + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetNamespaceResources(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => NamespaceResourceRestClient.CreateListAllRequest(Id.SubscriptionId, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => NamespaceResourceRestClient.CreateListAllNextPageRequest(nextLink, Id.SubscriptionId, skipToken, top); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NamespaceResource(Client, NamespaceResourceData.DeserializeNamespaceResourceData(e)), NamespaceResourceClientDiagnostics, Pipeline, "MockableNotificationhubsSubscriptionResource.GetNamespaceResources", "value", "nextLink", cancellationToken); + } + + /// + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability + /// + /// + /// Operation Id + /// NamespacesOperationGroup_CheckAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// The request body. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckAvailabilityNamespacesOperationGroupAsync(CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = NamespacesOperationGroupClientDiagnostics.CreateScope("MockableNotificationhubsSubscriptionResource.CheckAvailabilityNamespacesOperationGroup"); + scope.Start(); + try + { + var response = await NamespacesOperationGroupRestClient.CheckAvailabilityAsync(Id.SubscriptionId, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability + /// + /// + /// Operation Id + /// NamespacesOperationGroup_CheckAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// The request body. + /// The cancellation token to use. + /// is null. + public virtual Response CheckAvailabilityNamespacesOperationGroup(CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = NamespacesOperationGroupClientDiagnostics.CreateScope("MockableNotificationhubsSubscriptionResource.CheckAvailabilityNamespacesOperationGroup"); + scope.Start(); + try + { + var response = NamespacesOperationGroupRestClient.CheckAvailability(Id.SubscriptionId, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsTenantResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsTenantResource.cs new file mode 100644 index 000000000000..d93043403e78 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/MockableNotificationhubsTenantResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableNotificationhubsTenantResource : ArmResource + { + private ClientDiagnostics _operationsClientDiagnostics; + private OperationsRestOperations _operationsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableNotificationhubsTenantResource() + { + } + + /// 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 MockableNotificationhubsTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics OperationsClientDiagnostics => _operationsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private OperationsRestOperations OperationsRestClient => _operationsRestClient ??= new OperationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.NotificationHubs/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetOperationsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Info.DeserializeInfo(e), OperationsClientDiagnostics, Pipeline, "MockableNotificationhubsTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.NotificationHubs/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetOperations(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Info.DeserializeInfo(e), OperationsClientDiagnostics, Pipeline, "MockableNotificationhubsTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/NotificationhubsExtensions.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/NotificationhubsExtensions.cs new file mode 100644 index 000000000000..00e2eaa01a5e --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Extensions/NotificationhubsExtensions.cs @@ -0,0 +1,452 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.Notificationhubs.Mocking; +using Azure.ResourceManager.Notificationhubs.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// A class to add extension methods to Azure.ResourceManager.Notificationhubs. + public static partial class NotificationhubsExtensions + { + private static MockableNotificationhubsArmClient GetMockableNotificationhubsArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableNotificationhubsArmClient(client0)); + } + + private static MockableNotificationhubsResourceGroupResource GetMockableNotificationhubsResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableNotificationhubsResourceGroupResource(client, resource.Id)); + } + + private static MockableNotificationhubsSubscriptionResource GetMockableNotificationhubsSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableNotificationhubsSubscriptionResource(client, resource.Id)); + } + + private static MockableNotificationhubsTenantResource GetMockableNotificationhubsTenantResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableNotificationhubsTenantResource(client, resource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NotificationHubResource GetNotificationHubResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetNotificationHubResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NamespaceResource GetNamespaceResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetNamespaceResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NamespaceNotificationHubAuthorizationRuleResource GetNamespaceNotificationHubAuthorizationRuleResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetNamespaceNotificationHubAuthorizationRuleResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NamespaceAuthorizationRuleResource GetNamespaceAuthorizationRuleResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetNamespaceAuthorizationRuleResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static PrivateEndpointConnectionResource GetPrivateEndpointConnectionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetPrivateEndpointConnectionResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static NotificationhubsPrivateLinkResourceDataResource GetNotificationhubsPrivateLinkResourceDataResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableNotificationhubsArmClient(client).GetNotificationhubsPrivateLinkResourceDataResource(id); + } + + /// + /// Gets a collection of NamespaceResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of NamespaceResources and their operations over a NamespaceResource. + public static NamespaceResourceCollection GetNamespaceResources(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableNotificationhubsResourceGroupResource(resourceGroupResource).GetNamespaceResources(); + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Namespace name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetNamespaceResourceAsync(this ResourceGroupResource resourceGroupResource, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableNotificationhubsResourceGroupResource(resourceGroupResource).GetNamespaceResourceAsync(namespaceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Namespace name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetNamespaceResource(this ResourceGroupResource resourceGroupResource, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableNotificationhubsResourceGroupResource(resourceGroupResource).GetNamespaceResource(namespaceName, cancellationToken); + } + + /// + /// Lists all the available namespaces within the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_ListAll + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetNamespaceResourcesAsync(this SubscriptionResource subscriptionResource, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNotificationhubsSubscriptionResource(subscriptionResource).GetNamespaceResourcesAsync(skipToken, top, cancellationToken); + } + + /// + /// Lists all the available namespaces within the subscription. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_ListAll + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetNamespaceResources(this SubscriptionResource subscriptionResource, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNotificationhubsSubscriptionResource(subscriptionResource).GetNamespaceResources(skipToken, top, cancellationToken); + } + + /// + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability + /// + /// + /// Operation Id + /// NamespacesOperationGroup_CheckAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The request body. + /// The cancellation token to use. + /// or is null. + public static async Task> CheckAvailabilityNamespacesOperationGroupAsync(this SubscriptionResource subscriptionResource, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableNotificationhubsSubscriptionResource(subscriptionResource).CheckAvailabilityNamespacesOperationGroupAsync(content, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability + /// + /// + /// Operation Id + /// NamespacesOperationGroup_CheckAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The request body. + /// The cancellation token to use. + /// or is null. + public static Response CheckAvailabilityNamespacesOperationGroup(this SubscriptionResource subscriptionResource, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableNotificationhubsSubscriptionResource(subscriptionResource).CheckAvailabilityNamespacesOperationGroup(content, cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.NotificationHubs/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetOperationsAsync(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableNotificationhubsTenantResource(tenantResource).GetOperationsAsync(cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.NotificationHubs/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetOperations(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableNotificationhubsTenantResource(tenantResource).GetOperations(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Argument.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..0f7af22eb3d6 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..23d862f95d36 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingList.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..a7f1b1c60435 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..f15e9d5acf6f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,407 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static bool IsSentinelValue(BinaryData value) + { + ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan valueSpan = value.ToMemory().Span; + return sentinelSpan.SequenceEqual(valueSpan); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Optional.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..3c8c82342fb7 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..85f3416a98fe --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NamespaceResourceOperationSource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NamespaceResourceOperationSource.cs new file mode 100644 index 000000000000..f15529fc1aa8 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NamespaceResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal class NamespaceResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal NamespaceResourceOperationSource(ArmClient client) + { + _client = client; + } + + NamespaceResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default); + return new NamespaceResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default); + return await Task.FromResult(new NamespaceResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperation.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperation.cs new file mode 100644 index 000000000000..a0c17476d11d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperation.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ +#pragma warning disable SA1649 // File name should match first type name + internal class NotificationhubsArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of NotificationhubsArmOperation for mocking. + protected NotificationhubsArmOperation() + { + } + + internal NotificationhubsArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal NotificationhubsArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "NotificationhubsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperationOfT.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperationOfT.cs new file mode 100644 index 000000000000..fbe7cc5e7737 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/NotificationhubsArmOperationOfT.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ +#pragma warning disable SA1649 // File name should match first type name + internal class NotificationhubsArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of NotificationhubsArmOperation for mocking. + protected NotificationhubsArmOperation() + { + } + + internal NotificationhubsArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal NotificationhubsArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "NotificationhubsArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/PrivateEndpointConnectionResourceOperationSource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/PrivateEndpointConnectionResourceOperationSource.cs new file mode 100644 index 000000000000..ff6d9cfc9333 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/LongRunningOperation/PrivateEndpointConnectionResourceOperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal class PrivateEndpointConnectionResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal PrivateEndpointConnectionResourceOperationSource(ArmClient client) + { + _client = client; + } + + PrivateEndpointConnectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default); + return new PrivateEndpointConnectionResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerNotificationhubsContext.Default); + return await Task.FromResult(new PrivateEndpointConnectionResource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AccessRight.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AccessRight.cs new file mode 100644 index 000000000000..02e5a203ea28 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AccessRight.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Defines values for AccessRights. + public readonly partial struct AccessRight : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AccessRight(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ManageValue = "Manage"; + private const string SendValue = "Send"; + private const string ListenValue = "Listen"; + + /// Manage. + public static AccessRight Manage { get; } = new AccessRight(ManageValue); + /// Send. + public static AccessRight Send { get; } = new AccessRight(SendValue); + /// Listen. + public static AccessRight Listen { get; } = new AccessRight(ListenValue); + /// Determines if two values are the same. + public static bool operator ==(AccessRight left, AccessRight right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AccessRight left, AccessRight right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AccessRight(string value) => new AccessRight(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AccessRight other && Equals(other); + /// + public bool Equals(AccessRight other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.Serialization.cs new file mode 100644 index 000000000000..e1d012534197 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class AdmCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AdmCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId); + writer.WritePropertyName("clientSecret"u8); + writer.WriteStringValue(ClientSecret); + writer.WritePropertyName("authTokenUrl"u8); + writer.WriteStringValue(AuthTokenUri); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AdmCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AdmCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAdmCredential(document.RootElement, options); + } + + internal static AdmCredential DeserializeAdmCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string clientId = default; + string clientSecret = default; + string authTokenUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("clientId"u8)) + { + clientId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("clientSecret"u8)) + { + clientSecret = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("authTokenUrl"u8)) + { + authTokenUrl = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AdmCredential(clientId, clientSecret, authTokenUrl, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(AdmCredential)} does not support writing '{options.Format}' format."); + } + } + + AdmCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAdmCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AdmCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.cs new file mode 100644 index 000000000000..11dff62eaabe --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AdmCredential.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub AdmCredential. + public partial class AdmCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets the client identifier. + /// Gets or sets the credential secret access key. + /// Gets or sets the URL of the authorization token. + /// , or is null. + public AdmCredential(string clientId, string clientSecret, string authTokenUri) + { + Argument.AssertNotNull(clientId, nameof(clientId)); + Argument.AssertNotNull(clientSecret, nameof(clientSecret)); + Argument.AssertNotNull(authTokenUri, nameof(authTokenUri)); + + ClientId = clientId; + ClientSecret = clientSecret; + AuthTokenUri = authTokenUri; + } + + /// Initializes a new instance of . + /// Gets or sets the client identifier. + /// Gets or sets the credential secret access key. + /// Gets or sets the URL of the authorization token. + /// Keeps track of any properties unknown to the library. + internal AdmCredential(string clientId, string clientSecret, string authTokenUri, IDictionary serializedAdditionalRawData) + { + ClientId = clientId; + ClientSecret = clientSecret; + AuthTokenUri = authTokenUri; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AdmCredential() + { + } + + /// Gets or sets the client identifier. + public string ClientId { get; set; } + /// Gets or sets the credential secret access key. + public string ClientSecret { get; set; } + /// Gets or sets the URL of the authorization token. + public string AuthTokenUri { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.Serialization.cs new file mode 100644 index 000000000000..7c60072066b5 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.Serialization.cs @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class ApnsCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApnsCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(ApnsCertificate)) + { + writer.WritePropertyName("apnsCertificate"u8); + writer.WriteStringValue(ApnsCertificate); + } + if (Optional.IsDefined(CertificateKey)) + { + writer.WritePropertyName("certificateKey"u8); + writer.WriteStringValue(CertificateKey); + } + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint); + if (Optional.IsDefined(Thumbprint)) + { + writer.WritePropertyName("thumbprint"u8); + writer.WriteStringValue(Thumbprint); + } + if (Optional.IsDefined(KeyId)) + { + writer.WritePropertyName("keyId"u8); + writer.WriteStringValue(KeyId); + } + if (Optional.IsDefined(AppName)) + { + writer.WritePropertyName("appName"u8); + writer.WriteStringValue(AppName); + } + if (Optional.IsDefined(AppId)) + { + writer.WritePropertyName("appId"u8); + writer.WriteStringValue(AppId); + } + if (Optional.IsDefined(Token)) + { + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ApnsCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApnsCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApnsCredential(document.RootElement, options); + } + + internal static ApnsCredential DeserializeApnsCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string apnsCertificate = default; + string certificateKey = default; + string endpoint = default; + string thumbprint = default; + string keyId = default; + string appName = default; + string appId = default; + string token = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("apnsCertificate"u8)) + { + apnsCertificate = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("certificateKey"u8)) + { + certificateKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("endpoint"u8)) + { + endpoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("thumbprint"u8)) + { + thumbprint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("keyId"u8)) + { + keyId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("appName"u8)) + { + appName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("appId"u8)) + { + appId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("token"u8)) + { + token = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApnsCredential( + apnsCertificate, + certificateKey, + endpoint, + thumbprint, + keyId, + appName, + appId, + token, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(ApnsCredential)} does not support writing '{options.Format}' format."); + } + } + + ApnsCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApnsCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApnsCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.cs new file mode 100644 index 000000000000..82e3e08bd733 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ApnsCredential.cs @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub ApnsCredential. + public partial class ApnsCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets the endpoint of this credential. + /// is null. + public ApnsCredential(string endpoint) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + + Endpoint = endpoint; + } + + /// Initializes a new instance of . + /// Gets or sets the APNS certificate. + /// Gets or sets the certificate key. + /// Gets or sets the endpoint of this credential. + /// Gets or sets the APNS certificate Thumbprint. + /// + /// Gets or sets a 10-character key identifier (kid) key, obtained from + /// your developer account + /// + /// Gets or sets the name of the application. + /// + /// Gets or sets the issuer (iss) registered claim key, whose value is + /// your 10-character Team ID, obtained from your developer account + /// + /// + /// Gets or sets provider Authentication Token, obtained through your + /// developer account + /// + /// Keeps track of any properties unknown to the library. + internal ApnsCredential(string apnsCertificate, string certificateKey, string endpoint, string thumbprint, string keyId, string appName, string appId, string token, IDictionary serializedAdditionalRawData) + { + ApnsCertificate = apnsCertificate; + CertificateKey = certificateKey; + Endpoint = endpoint; + Thumbprint = thumbprint; + KeyId = keyId; + AppName = appName; + AppId = appId; + Token = token; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ApnsCredential() + { + } + + /// Gets or sets the APNS certificate. + public string ApnsCertificate { get; set; } + /// Gets or sets the certificate key. + public string CertificateKey { get; set; } + /// Gets or sets the endpoint of this credential. + public string Endpoint { get; set; } + /// Gets or sets the APNS certificate Thumbprint. + public string Thumbprint { get; set; } + /// + /// Gets or sets a 10-character key identifier (kid) key, obtained from + /// your developer account + /// + public string KeyId { get; set; } + /// Gets or sets the name of the application. + public string AppName { get; set; } + /// + /// Gets or sets the issuer (iss) registered claim key, whose value is + /// your 10-character Team ID, obtained from your developer account + /// + public string AppId { get; set; } + /// + /// Gets or sets provider Authentication Token, obtained through your + /// developer account + /// + public string Token { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.Serialization.cs new file mode 100644 index 000000000000..7e96f8609e29 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.Serialization.cs @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class Availability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Availability)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TimeGrain)) + { + writer.WritePropertyName("timeGrain"u8); + writer.WriteStringValue(TimeGrain); + } + if (options.Format != "W" && Optional.IsDefined(BlobDuration)) + { + writer.WritePropertyName("blobDuration"u8); + writer.WriteStringValue(BlobDuration); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Availability IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Availability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAvailability(document.RootElement, options); + } + + internal static Availability DeserializeAvailability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string timeGrain = default; + string blobDuration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeGrain"u8)) + { + timeGrain = property.Value.GetString(); + continue; + } + if (property.NameEquals("blobDuration"u8)) + { + blobDuration = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Availability(timeGrain, blobDuration, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(Availability)} does not support writing '{options.Format}' format."); + } + } + + Availability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAvailability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Availability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.cs new file mode 100644 index 000000000000..9ba38cab395a --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Availability.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Represents metric availability (part of RP operation descriptions). + public partial class Availability + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal Availability() + { + } + + /// Initializes a new instance of . + /// Time grain of the availability. + /// Duration of the availability blob. + /// Keeps track of any properties unknown to the library. + internal Availability(string timeGrain, string blobDuration, IDictionary serializedAdditionalRawData) + { + TimeGrain = timeGrain; + BlobDuration = blobDuration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Time grain of the availability. + public string TimeGrain { get; } + /// Duration of the availability blob. + public string BlobDuration { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AzureResourceManagerNotificationhubsContext.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AzureResourceManagerNotificationhubsContext.cs new file mode 100644 index 000000000000..b0033b8be1d3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/AzureResourceManagerNotificationhubsContext.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// + public partial class AzureResourceManagerNotificationhubsContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.Serialization.cs new file mode 100644 index 000000000000..1a2f59a6b737 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class BaiduCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaiduCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("baiduApiKey"u8); + writer.WriteStringValue(BaiduApiKey); + writer.WritePropertyName("baiduEndPoint"u8); + writer.WriteStringValue(BaiduEndPoint); + writer.WritePropertyName("baiduSecretKey"u8); + writer.WriteStringValue(BaiduSecretKey); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + BaiduCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaiduCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaiduCredential(document.RootElement, options); + } + + internal static BaiduCredential DeserializeBaiduCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string baiduApiKey = default; + string baiduEndPoint = default; + string baiduSecretKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("baiduApiKey"u8)) + { + baiduApiKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("baiduEndPoint"u8)) + { + baiduEndPoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("baiduSecretKey"u8)) + { + baiduSecretKey = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BaiduCredential(baiduApiKey, baiduEndPoint, baiduSecretKey, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(BaiduCredential)} does not support writing '{options.Format}' format."); + } + } + + BaiduCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBaiduCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaiduCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.cs new file mode 100644 index 000000000000..6b93b93d4c0f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BaiduCredential.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub BaiduCredential. + public partial class BaiduCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets baidu Api Key. + /// Gets or sets baidu Endpoint. + /// Gets or sets baidu Secret Key. + /// , or is null. + public BaiduCredential(string baiduApiKey, string baiduEndPoint, string baiduSecretKey) + { + Argument.AssertNotNull(baiduApiKey, nameof(baiduApiKey)); + Argument.AssertNotNull(baiduEndPoint, nameof(baiduEndPoint)); + Argument.AssertNotNull(baiduSecretKey, nameof(baiduSecretKey)); + + BaiduApiKey = baiduApiKey; + BaiduEndPoint = baiduEndPoint; + BaiduSecretKey = baiduSecretKey; + } + + /// Initializes a new instance of . + /// Gets or sets baidu Api Key. + /// Gets or sets baidu Endpoint. + /// Gets or sets baidu Secret Key. + /// Keeps track of any properties unknown to the library. + internal BaiduCredential(string baiduApiKey, string baiduEndPoint, string baiduSecretKey, IDictionary serializedAdditionalRawData) + { + BaiduApiKey = baiduApiKey; + BaiduEndPoint = baiduEndPoint; + BaiduSecretKey = baiduSecretKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BaiduCredential() + { + } + + /// Gets or sets baidu Api Key. + public string BaiduApiKey { get; set; } + /// Gets or sets baidu Endpoint. + public string BaiduEndPoint { get; set; } + /// Gets or sets baidu Secret Key. + public string BaiduSecretKey { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.Serialization.cs new file mode 100644 index 000000000000..62ec2abf115c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class BrowserCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("subject"u8); + writer.WriteStringValue(Subject); + writer.WritePropertyName("vapidPrivateKey"u8); + writer.WriteStringValue(VapidPrivateKey); + writer.WritePropertyName("vapidPublicKey"u8); + writer.WriteStringValue(VapidPublicKey); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + BrowserCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserCredential(document.RootElement, options); + } + + internal static BrowserCredential DeserializeBrowserCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string subject = default; + string vapidPrivateKey = default; + string vapidPublicKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("subject"u8)) + { + subject = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("vapidPrivateKey"u8)) + { + vapidPrivateKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("vapidPublicKey"u8)) + { + vapidPublicKey = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BrowserCredential(subject, vapidPrivateKey, vapidPublicKey, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserCredential)} does not support writing '{options.Format}' format."); + } + } + + BrowserCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBrowserCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.cs new file mode 100644 index 000000000000..550e492a6112 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/BrowserCredential.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub BrowserCredential. + public partial class BrowserCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets web push subject. + /// Gets or sets VAPID private key. + /// Gets or sets VAPID public key. + /// , or is null. + public BrowserCredential(string subject, string vapidPrivateKey, string vapidPublicKey) + { + Argument.AssertNotNull(subject, nameof(subject)); + Argument.AssertNotNull(vapidPrivateKey, nameof(vapidPrivateKey)); + Argument.AssertNotNull(vapidPublicKey, nameof(vapidPublicKey)); + + Subject = subject; + VapidPrivateKey = vapidPrivateKey; + VapidPublicKey = vapidPublicKey; + } + + /// Initializes a new instance of . + /// Gets or sets web push subject. + /// Gets or sets VAPID private key. + /// Gets or sets VAPID public key. + /// Keeps track of any properties unknown to the library. + internal BrowserCredential(string subject, string vapidPrivateKey, string vapidPublicKey, IDictionary serializedAdditionalRawData) + { + Subject = subject; + VapidPrivateKey = vapidPrivateKey; + VapidPublicKey = vapidPublicKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal BrowserCredential() + { + } + + /// Gets or sets web push subject. + public string Subject { get; set; } + /// Gets or sets VAPID private key. + public string VapidPrivateKey { get; set; } + /// Gets or sets VAPID public key. + public string VapidPublicKey { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.Serialization.cs new file mode 100644 index 000000000000..264d11de2e37 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class CheckAvailabilityContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAvailabilityContent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(IsAvailiable)) + { + writer.WritePropertyName("isAvailiable"u8); + writer.WriteBooleanValue(IsAvailiable.Value); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + } + + CheckAvailabilityContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAvailabilityContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckAvailabilityContent(document.RootElement, options); + } + + internal static CheckAvailabilityContent DeserializeCheckAvailabilityContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? isAvailiable = default; + NotificationhubsSku sku = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isAvailiable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isAvailiable = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (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 (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CheckAvailabilityContent( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + isAvailiable, + sku, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(CheckAvailabilityContent)} does not support writing '{options.Format}' format."); + } + } + + CheckAvailabilityContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCheckAvailabilityContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckAvailabilityContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.cs new file mode 100644 index 000000000000..32f033329c46 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityContent.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// + /// Parameters supplied to the Check Name Availability for Namespace and + /// NotificationHubs. + /// + public partial class CheckAvailabilityContent : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public CheckAvailabilityContent(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Not used and deprecated since API version 2023-01-01-preview. + /// The Sku description for a namespace. + /// Keeps track of any properties unknown to the library. + internal CheckAvailabilityContent(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, bool? isAvailiable, NotificationhubsSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + IsAvailiable = isAvailiable; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CheckAvailabilityContent() + { + } + + /// Not used and deprecated since API version 2023-01-01-preview. + public bool? IsAvailiable { get; set; } + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.Serialization.cs new file mode 100644 index 000000000000..cd9c2dcfeaa2 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.Serialization.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class CheckAvailabilityResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAvailabilityResult)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(IsAvailiable)) + { + writer.WritePropertyName("isAvailiable"u8); + writer.WriteBooleanValue(IsAvailiable.Value); + } + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + } + + CheckAvailabilityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CheckAvailabilityResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCheckAvailabilityResult(document.RootElement, options); + } + + internal static CheckAvailabilityResult DeserializeCheckAvailabilityResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? isAvailiable = default; + string location = default; + IReadOnlyDictionary tags = default; + NotificationhubsSku sku = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("isAvailiable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isAvailiable = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("location"u8)) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CheckAvailabilityResult( + id, + name, + type, + systemData, + isAvailiable, + location, + tags ?? new ChangeTrackingDictionary(), + sku, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(CheckAvailabilityResult)} does not support writing '{options.Format}' format."); + } + } + + CheckAvailabilityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCheckAvailabilityResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CheckAvailabilityResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.cs new file mode 100644 index 000000000000..2aff68f60265 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/CheckAvailabilityResult.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a CheckAvailability resource. + public partial class CheckAvailabilityResult : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CheckAvailabilityResult() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// + /// Gets or sets true if the name is available and can be used to + /// create new Namespace/NotificationHub. Otherwise false. + /// + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// The Sku description for a namespace. + /// Keeps track of any properties unknown to the library. + internal CheckAvailabilityResult(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, bool? isAvailiable, string location, IReadOnlyDictionary tags, NotificationhubsSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + IsAvailiable = isAvailiable; + Location = location; + Tags = tags; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Gets or sets true if the name is available and can be used to + /// create new Namespace/NotificationHub. Otherwise false. + /// + public bool? IsAvailiable { get; } + /// Deprecated - only for compatibility. + public string Location { get; } + /// Deprecated - only for compatibility. + public IReadOnlyDictionary Tags { get; } + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.Serialization.cs new file mode 100644 index 000000000000..7fa9ae08affe --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.Serialization.cs @@ -0,0 +1,250 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class DebugSendResponseResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DebugSendResponseResult)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + } + 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("properties"u8); + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Success)) + { + writer.WritePropertyName("success"u8); + writer.WriteNumberValue(Success.Value); + } + if (options.Format != "W" && Optional.IsDefined(Failure)) + { + writer.WritePropertyName("failure"u8); + writer.WriteNumberValue(Failure.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + + DebugSendResponseResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DebugSendResponseResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDebugSendResponseResult(document.RootElement, options); + } + + internal static DebugSendResponseResult DeserializeDebugSendResponseResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string location = default; + IReadOnlyDictionary tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + long? success = default; + long? failure = default; + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (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("success"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + success = property0.Value.GetInt64(); + continue; + } + if (property0.NameEquals("failure"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + failure = property0.Value.GetInt64(); + continue; + } + if (property0.NameEquals("results"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(RegistrationResult.DeserializeRegistrationResult(item, options)); + } + results = array; + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DebugSendResponseResult( + id, + name, + type, + systemData, + success, + failure, + results ?? new ChangeTrackingList(), + location, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(DebugSendResponseResult)} does not support writing '{options.Format}' format."); + } + } + + DebugSendResponseResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDebugSendResponseResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DebugSendResponseResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.cs new file mode 100644 index 000000000000..c49141f66c18 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/DebugSendResponseResult.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub Resource. + public partial class DebugSendResponseResult : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal DebugSendResponseResult() + { + Results = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Gets or sets successful send. + /// Gets or sets send failure. + /// Gets or sets actual failure description. + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// Keeps track of any properties unknown to the library. + internal DebugSendResponseResult(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, long? success, long? failure, IReadOnlyList results, string location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Success = success; + Failure = failure; + Results = results; + Location = location; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets successful send. + public long? Success { get; } + /// Gets or sets send failure. + public long? Failure { get; } + /// Gets or sets actual failure description. + public IReadOnlyList Results { get; } + /// Deprecated - only for compatibility. + public string Location { get; } + /// Deprecated - only for compatibility. + public IReadOnlyDictionary Tags { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.Serialization.cs new file mode 100644 index 000000000000..c4e4afbbb303 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class FcmV1Credential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FcmV1Credential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("clientEmail"u8); + writer.WriteStringValue(ClientEmail); + writer.WritePropertyName("privateKey"u8); + writer.WriteStringValue(PrivateKey); + writer.WritePropertyName("projectId"u8); + writer.WriteStringValue(ProjectId); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FcmV1Credential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FcmV1Credential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFcmV1Credential(document.RootElement, options); + } + + internal static FcmV1Credential DeserializeFcmV1Credential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string clientEmail = default; + string privateKey = default; + string projectId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("clientEmail"u8)) + { + clientEmail = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("privateKey"u8)) + { + privateKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("projectId"u8)) + { + projectId = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FcmV1Credential(clientEmail, privateKey, projectId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(FcmV1Credential)} does not support writing '{options.Format}' format."); + } + } + + FcmV1Credential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFcmV1Credential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FcmV1Credential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.cs new file mode 100644 index 000000000000..4246d19599d2 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/FcmV1Credential.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub FcmV1Credential. + public partial class FcmV1Credential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets client email. + /// Gets or sets private key. + /// Gets or sets project id. + /// , or is null. + public FcmV1Credential(string clientEmail, string privateKey, string projectId) + { + Argument.AssertNotNull(clientEmail, nameof(clientEmail)); + Argument.AssertNotNull(privateKey, nameof(privateKey)); + Argument.AssertNotNull(projectId, nameof(projectId)); + + ClientEmail = clientEmail; + PrivateKey = privateKey; + ProjectId = projectId; + } + + /// Initializes a new instance of . + /// Gets or sets client email. + /// Gets or sets private key. + /// Gets or sets project id. + /// Keeps track of any properties unknown to the library. + internal FcmV1Credential(string clientEmail, string privateKey, string projectId, IDictionary serializedAdditionalRawData) + { + ClientEmail = clientEmail; + PrivateKey = privateKey; + ProjectId = projectId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FcmV1Credential() + { + } + + /// Gets or sets client email. + public string ClientEmail { get; set; } + /// Gets or sets private key. + public string PrivateKey { get; set; } + /// Gets or sets project id. + public string ProjectId { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.Serialization.cs new file mode 100644 index 000000000000..c893e22f725c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class GcmCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GcmCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(GcmEndpoint)) + { + writer.WritePropertyName("gcmEndpoint"u8); + writer.WriteStringValue(GcmEndpoint); + } + writer.WritePropertyName("googleApiKey"u8); + writer.WriteStringValue(GoogleApiKey); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GcmCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GcmCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGcmCredential(document.RootElement, options); + } + + internal static GcmCredential DeserializeGcmCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string gcmEndpoint = default; + string googleApiKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("gcmEndpoint"u8)) + { + gcmEndpoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("googleApiKey"u8)) + { + googleApiKey = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GcmCredential(gcmEndpoint, googleApiKey, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(GcmCredential)} does not support writing '{options.Format}' format."); + } + } + + GcmCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGcmCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GcmCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.cs new file mode 100644 index 000000000000..6313addf5916 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/GcmCredential.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub GcmCredential. + public partial class GcmCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets the Google API key. + /// is null. + public GcmCredential(string googleApiKey) + { + Argument.AssertNotNull(googleApiKey, nameof(googleApiKey)); + + GoogleApiKey = googleApiKey; + } + + /// Initializes a new instance of . + /// Gets or sets the GCM endpoint. + /// Gets or sets the Google API key. + /// Keeps track of any properties unknown to the library. + internal GcmCredential(string gcmEndpoint, string googleApiKey, IDictionary serializedAdditionalRawData) + { + GcmEndpoint = gcmEndpoint; + GoogleApiKey = googleApiKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GcmCredential() + { + } + + /// Gets or sets the GCM endpoint. + public string GcmEndpoint { get; set; } + /// Gets or sets the Google API key. + public string GoogleApiKey { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.Serialization.cs new file mode 100644 index 000000000000..411963cd7090 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class IPRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IPRule)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("ipMask"u8); + writer.WriteStringValue(IPMask); + writer.WritePropertyName("rights"u8); + writer.WriteStartArray(); + foreach (var item in Rights) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + IPRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(IPRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeIPRule(document.RootElement, options); + } + + internal static IPRule DeserializeIPRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ipMask = default; + IList rights = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipMask"u8)) + { + ipMask = property.Value.GetString(); + continue; + } + if (property.NameEquals("rights"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AccessRight(item.GetString())); + } + rights = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new IPRule(ipMask, rights, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(IPRule)} does not support writing '{options.Format}' format."); + } + } + + IPRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeIPRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(IPRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.cs new file mode 100644 index 000000000000..ce3166a2d018 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/IPRule.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// A network authorization rule that filters traffic based on IP address. + public partial class IPRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// IP mask. + /// List of access rights. + /// or is null. + public IPRule(string ipMask, IEnumerable rights) + { + Argument.AssertNotNull(ipMask, nameof(ipMask)); + Argument.AssertNotNull(rights, nameof(rights)); + + IPMask = ipMask; + Rights = rights.ToList(); + } + + /// Initializes a new instance of . + /// IP mask. + /// List of access rights. + /// Keeps track of any properties unknown to the library. + internal IPRule(string ipMask, IList rights, IDictionary serializedAdditionalRawData) + { + IPMask = ipMask; + Rights = rights; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal IPRule() + { + } + + /// IP mask. + public string IPMask { get; set; } + /// List of access rights. + public IList Rights { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.Serialization.cs new file mode 100644 index 000000000000..bed78de3ab16 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class Info : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Info)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Display)) + { + writer.WritePropertyName("display"u8); + writer.WriteObjectValue(Display, options); + } + if (options.Format != "W" && Optional.IsDefined(IsDataAction)) + { + writer.WritePropertyName("isDataAction"u8); + writer.WriteBooleanValue(IsDataAction.Value); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Info IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Info)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInfo(document.RootElement, options); + } + + internal static Info DeserializeInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + OperationDisplay display = default; + bool? isDataAction = default; + OperationProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("display"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + display = OperationDisplay.DeserializeOperationDisplay(property.Value, options); + continue; + } + if (property.NameEquals("isDataAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isDataAction = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = OperationProperties.DeserializeOperationProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Info(name, display, isDataAction, properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(Info)} does not support writing '{options.Format}' format."); + } + } + + Info IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Info)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.cs new file mode 100644 index 000000000000..88a74609030d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/Info.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Result of the request to list SQL operations. + public partial class Info + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal Info() + { + } + + /// Initializes a new instance of . + /// The name of the operation being performed on this particular object.". + /// he localized display information for this particular operation / action. + /// The intended executor of the operation.". + /// Additional descriptions for the operation. + /// Keeps track of any properties unknown to the library. + internal Info(string name, OperationDisplay display, bool? isDataAction, OperationProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Display = display; + IsDataAction = isDataAction; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the operation being performed on this particular object.". + public string Name { get; } + /// he localized display information for this particular operation / action. + public OperationDisplay Display { get; } + /// The intended executor of the operation.". + public bool? IsDataAction { get; } + /// Additional descriptions for the operation. + internal OperationProperties Properties { get; } + /// Optional service specification used in Operations API. + public ServiceSpecification OperationServiceSpecification + { + get => Properties?.ServiceSpecification; + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.Serialization.cs new file mode 100644 index 000000000000..d31173daf12f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.Serialization.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class LogSpecification : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LogSpecification)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(BlobDuration)) + { + writer.WritePropertyName("blobDuration"u8); + writer.WriteStringValue(BlobDuration); + } + if (Optional.IsCollectionDefined(CategoryGroups)) + { + writer.WritePropertyName("categoryGroups"u8); + writer.WriteStartArray(); + foreach (var item in CategoryGroups) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LogSpecification IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LogSpecification)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLogSpecification(document.RootElement, options); + } + + internal static LogSpecification DeserializeLogSpecification(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string displayName = default; + string blobDuration = default; + IReadOnlyList categoryGroups = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("blobDuration"u8)) + { + blobDuration = property.Value.GetString(); + continue; + } + if (property.NameEquals("categoryGroups"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + categoryGroups = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LogSpecification(name, displayName, blobDuration, categoryGroups ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(LogSpecification)} does not support writing '{options.Format}' format."); + } + } + + LogSpecification IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLogSpecification(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LogSpecification)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.cs new file mode 100644 index 000000000000..649e96bb8131 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/LogSpecification.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// A single log category specification. + public partial class LogSpecification + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal LogSpecification() + { + CategoryGroups = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Name of the log category. + /// Display name of the log category. + /// Duration of data written to a single blob. + /// Category group for the log specification. + /// Keeps track of any properties unknown to the library. + internal LogSpecification(string name, string displayName, string blobDuration, IReadOnlyList categoryGroups, IDictionary serializedAdditionalRawData) + { + Name = name; + DisplayName = displayName; + BlobDuration = blobDuration; + CategoryGroups = categoryGroups; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Name of the log category. + public string Name { get; } + /// Display name of the log category. + public string DisplayName { get; } + /// Duration of data written to a single blob. + public string BlobDuration { get; } + /// Category group for the log specification. + public IReadOnlyList CategoryGroups { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.Serialization.cs new file mode 100644 index 000000000000..0ce5df9a2290 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.Serialization.cs @@ -0,0 +1,259 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class MetricSpecification : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricSpecification)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(DisplayDescription)) + { + writer.WritePropertyName("displayDescription"u8); + writer.WriteStringValue(DisplayDescription); + } + if (options.Format != "W" && Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit); + } + if (options.Format != "W" && Optional.IsDefined(AggregationType)) + { + writer.WritePropertyName("aggregationType"u8); + writer.WriteStringValue(AggregationType); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Availabilities)) + { + writer.WritePropertyName("availabilities"u8); + writer.WriteStartArray(); + foreach (var item in Availabilities) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(SupportedTimeGrainTypes)) + { + writer.WritePropertyName("supportedTimeGrainTypes"u8); + writer.WriteStartArray(); + foreach (var item in SupportedTimeGrainTypes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(MetricFilterPattern)) + { + writer.WritePropertyName("metricFilterPattern"u8); + writer.WriteStringValue(MetricFilterPattern); + } + if (options.Format != "W" && Optional.IsDefined(FillGapWithZero)) + { + writer.WritePropertyName("fillGapWithZero"u8); + writer.WriteBooleanValue(FillGapWithZero.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricSpecification IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricSpecification)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricSpecification(document.RootElement, options); + } + + internal static MetricSpecification DeserializeMetricSpecification(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string displayName = default; + string displayDescription = default; + string unit = default; + string aggregationType = default; + IReadOnlyList availabilities = default; + IReadOnlyList supportedTimeGrainTypes = default; + string metricFilterPattern = default; + bool? fillGapWithZero = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayDescription"u8)) + { + displayDescription = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("aggregationType"u8)) + { + aggregationType = property.Value.GetString(); + continue; + } + if (property.NameEquals("availabilities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Availability.DeserializeAvailability(item, options)); + } + availabilities = array; + continue; + } + if (property.NameEquals("supportedTimeGrainTypes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + supportedTimeGrainTypes = array; + continue; + } + if (property.NameEquals("metricFilterPattern"u8)) + { + metricFilterPattern = property.Value.GetString(); + continue; + } + if (property.NameEquals("fillGapWithZero"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fillGapWithZero = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricSpecification( + name, + displayName, + displayDescription, + unit, + aggregationType, + availabilities ?? new ChangeTrackingList(), + supportedTimeGrainTypes ?? new ChangeTrackingList(), + metricFilterPattern, + fillGapWithZero, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(MetricSpecification)} does not support writing '{options.Format}' format."); + } + } + + MetricSpecification IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMetricSpecification(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricSpecification)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.cs new file mode 100644 index 000000000000..66cbb2b71f00 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MetricSpecification.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// A metric specification. + public partial class MetricSpecification + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MetricSpecification() + { + Availabilities = new ChangeTrackingList(); + SupportedTimeGrainTypes = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Metric name / id. + /// User-visible metric name. + /// Description of the metric. + /// Metric unit. + /// Type of the aggregation (Average, Minimum, Maximum, Total or Count). + /// List of availabilities. + /// List of supported time grain types. + /// The matching regex pattern to be applied to the field pointed by the "metricsFilterPathSelector" flag in the ARM manifest. + /// Optional property. If set to true, then zero will be returned for time duration where no metric is emitted / published. + /// Keeps track of any properties unknown to the library. + internal MetricSpecification(string name, string displayName, string displayDescription, string unit, string aggregationType, IReadOnlyList availabilities, IReadOnlyList supportedTimeGrainTypes, string metricFilterPattern, bool? fillGapWithZero, IDictionary serializedAdditionalRawData) + { + Name = name; + DisplayName = displayName; + DisplayDescription = displayDescription; + Unit = unit; + AggregationType = aggregationType; + Availabilities = availabilities; + SupportedTimeGrainTypes = supportedTimeGrainTypes; + MetricFilterPattern = metricFilterPattern; + FillGapWithZero = fillGapWithZero; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Metric name / id. + public string Name { get; } + /// User-visible metric name. + public string DisplayName { get; } + /// Description of the metric. + public string DisplayDescription { get; } + /// Metric unit. + public string Unit { get; } + /// Type of the aggregation (Average, Minimum, Maximum, Total or Count). + public string AggregationType { get; } + /// List of availabilities. + public IReadOnlyList Availabilities { get; } + /// List of supported time grain types. + public IReadOnlyList SupportedTimeGrainTypes { get; } + /// The matching regex pattern to be applied to the field pointed by the "metricsFilterPathSelector" flag in the ARM manifest. + public string MetricFilterPattern { get; } + /// Optional property. If set to true, then zero will be returned for time duration where no metric is emitted / published. + public bool? FillGapWithZero { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.Serialization.cs new file mode 100644 index 000000000000..d8f52913f6fa --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class MpnsCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MpnsCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + writer.WritePropertyName("mpnsCertificate"u8); + writer.WriteStringValue(MpnsCertificate); + writer.WritePropertyName("certificateKey"u8); + writer.WriteStringValue(CertificateKey); + writer.WritePropertyName("thumbprint"u8); + writer.WriteStringValue(Thumbprint); + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MpnsCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MpnsCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMpnsCredential(document.RootElement, options); + } + + internal static MpnsCredential DeserializeMpnsCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string mpnsCertificate = default; + string certificateKey = default; + string thumbprint = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("mpnsCertificate"u8)) + { + mpnsCertificate = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("certificateKey"u8)) + { + certificateKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("thumbprint"u8)) + { + thumbprint = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MpnsCredential(mpnsCertificate, certificateKey, thumbprint, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(MpnsCredential)} does not support writing '{options.Format}' format."); + } + } + + MpnsCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMpnsCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MpnsCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.cs new file mode 100644 index 000000000000..8cd5a072b3b5 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/MpnsCredential.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub MpnsCredential. + public partial class MpnsCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets the MPNS certificate. + /// Gets or sets the certificate key for this credential. + /// Gets or sets the MPNS certificate Thumbprint. + /// , or is null. + public MpnsCredential(string mpnsCertificate, string certificateKey, string thumbprint) + { + Argument.AssertNotNull(mpnsCertificate, nameof(mpnsCertificate)); + Argument.AssertNotNull(certificateKey, nameof(certificateKey)); + Argument.AssertNotNull(thumbprint, nameof(thumbprint)); + + MpnsCertificate = mpnsCertificate; + CertificateKey = certificateKey; + Thumbprint = thumbprint; + } + + /// Initializes a new instance of . + /// Gets or sets the MPNS certificate. + /// Gets or sets the certificate key for this credential. + /// Gets or sets the MPNS certificate Thumbprint. + /// Keeps track of any properties unknown to the library. + internal MpnsCredential(string mpnsCertificate, string certificateKey, string thumbprint, IDictionary serializedAdditionalRawData) + { + MpnsCertificate = mpnsCertificate; + CertificateKey = certificateKey; + Thumbprint = thumbprint; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MpnsCredential() + { + } + + /// Gets or sets the MPNS certificate. + public string MpnsCertificate { get; set; } + /// Gets or sets the certificate key for this credential. + public string CertificateKey { get; set; } + /// Gets or sets the MPNS certificate Thumbprint. + public string Thumbprint { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.Serialization.cs new file mode 100644 index 000000000000..8bca772ba27d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class NamespaceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NamespaceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNamespaceListResult(document.RootElement, options); + } + + internal static NamespaceListResult DeserializeNamespaceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NamespaceResourceData.DeserializeNamespaceResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NamespaceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NamespaceListResult)} does not support writing '{options.Format}' format."); + } + } + + NamespaceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNamespaceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NamespaceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.cs new file mode 100644 index 000000000000..0212b5b207a3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Paged collection of NamespaceResource items. + internal partial class NamespaceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The NamespaceResource items on this page. + internal NamespaceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The NamespaceResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal NamespaceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NamespaceListResult() + { + } + + /// The NamespaceResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.Serialization.cs new file mode 100644 index 000000000000..ca46598fe68c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.Serialization.cs @@ -0,0 +1,421 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NamespaceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(Critical)) + { + writer.WritePropertyName("critical"u8); + writer.WriteBooleanValue(Critical.Value); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && Optional.IsDefined(Region)) + { + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + } + if (options.Format != "W" && Optional.IsDefined(MetricId)) + { + writer.WritePropertyName("metricId"u8); + writer.WriteStringValue(MetricId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedOn)) + { + writer.WritePropertyName("updatedAt"u8); + writer.WriteStringValue(UpdatedOn.Value, "O"); + } + if (Optional.IsDefined(NamespaceType)) + { + writer.WritePropertyName("namespaceType"u8); + writer.WriteStringValue(NamespaceType.Value.ToString()); + } + if (Optional.IsDefined(ReplicationRegion)) + { + writer.WritePropertyName("replicationRegion"u8); + writer.WriteStringValue(ReplicationRegion.Value.ToString()); + } + if (Optional.IsDefined(ZoneRedundancy)) + { + writer.WritePropertyName("zoneRedundancy"u8); + writer.WriteStringValue(ZoneRedundancy.Value.ToString()); + } + if (Optional.IsDefined(NetworkAcls)) + { + writer.WritePropertyName("networkAcls"u8); + writer.WriteObjectValue(NetworkAcls, options); + } + if (Optional.IsDefined(PnsCredentials)) + { + writer.WritePropertyName("pnsCredentials"u8); + writer.WriteObjectValue(PnsCredentials, options); + } + if (options.Format != "W" && Optional.IsDefined(ServiceBusEndpoint)) + { + writer.WritePropertyName("serviceBusEndpoint"u8); + writer.WriteStringValue(ServiceBusEndpoint); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (var item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ScaleUnit)) + { + writer.WritePropertyName("scaleUnit"u8); + writer.WriteStringValue(ScaleUnit); + } + if (Optional.IsDefined(DataCenter)) + { + writer.WritePropertyName("dataCenter"u8); + writer.WriteStringValue(DataCenter); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NamespaceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNamespaceProperties(document.RootElement, options); + } + + internal static NamespaceProperties DeserializeNamespaceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + OperationProvisioningState? provisioningState = default; + NamespaceStatus? status = default; + bool? enabled = default; + bool? critical = default; + string subscriptionId = default; + string region = default; + string metricId = default; + DateTimeOffset? createdAt = default; + DateTimeOffset? updatedAt = default; + NamespaceType? namespaceType = default; + ReplicationRegion? replicationRegion = default; + ZoneRedundancyPreference? zoneRedundancy = default; + NetworkAcls networkAcls = default; + PnsCredentials pnsCredentials = default; + string serviceBusEndpoint = default; + IReadOnlyList privateEndpointConnections = default; + string scaleUnit = default; + string dataCenter = default; + PublicNetworkAccess? publicNetworkAccess = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new OperationProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new NamespaceStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("critical"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + critical = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("region"u8)) + { + region = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricId"u8)) + { + metricId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("updatedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("namespaceType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + namespaceType = new NamespaceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("replicationRegion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + replicationRegion = new ReplicationRegion(property.Value.GetString()); + continue; + } + if (property.NameEquals("zoneRedundancy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + zoneRedundancy = new ZoneRedundancyPreference(property.Value.GetString()); + continue; + } + if (property.NameEquals("networkAcls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkAcls = NetworkAcls.DeserializeNetworkAcls(property.Value, options); + continue; + } + if (property.NameEquals("pnsCredentials"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pnsCredentials = PnsCredentials.DeserializePnsCredentials(property.Value, options); + continue; + } + if (property.NameEquals("serviceBusEndpoint"u8)) + { + serviceBusEndpoint = property.Value.GetString(); + continue; + } + if (property.NameEquals("privateEndpointConnections"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (property.NameEquals("scaleUnit"u8)) + { + scaleUnit = property.Value.GetString(); + continue; + } + if (property.NameEquals("dataCenter"u8)) + { + dataCenter = property.Value.GetString(); + continue; + } + if (property.NameEquals("publicNetworkAccess"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NamespaceProperties( + name, + provisioningState, + status, + enabled, + critical, + subscriptionId, + region, + metricId, + createdAt, + updatedAt, + namespaceType, + replicationRegion, + zoneRedundancy, + networkAcls, + pnsCredentials, + serviceBusEndpoint, + privateEndpointConnections ?? new ChangeTrackingList(), + scaleUnit, + dataCenter, + publicNetworkAccess, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NamespaceProperties)} does not support writing '{options.Format}' format."); + } + } + + NamespaceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNamespaceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NamespaceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.cs new file mode 100644 index 000000000000..c855742ec6af --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceProperties.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Represents namespace properties. + public partial class NamespaceProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public NamespaceProperties() + { + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Name of the Notification Hubs namespace. This is immutable property, set automatically + /// by the service when the namespace is created. + /// + /// Defines values for OperationProvisioningState. + /// Namespace status. + /// Gets or sets whether or not the namespace is currently enabled. + /// Gets or sets whether or not the namespace is set as Critical. + /// Namespace subscription id. + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + /// Azure Insights Metrics id. + /// Time when the namespace was created. + /// Time when the namespace was updated. + /// Defines values for NamespaceType. + /// Allowed replication region. + /// Namespace SKU name. + /// A collection of network authorization rules. + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + /// Private Endpoint Connections for namespace. + /// Gets or sets scaleUnit where the namespace gets created. + /// Deprecated. + /// Type of public network access. + /// Keeps track of any properties unknown to the library. + internal NamespaceProperties(string name, OperationProvisioningState? provisioningState, NamespaceStatus? status, bool? enabled, bool? critical, string subscriptionId, string region, string metricId, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, NamespaceType? namespaceType, ReplicationRegion? replicationRegion, ZoneRedundancyPreference? zoneRedundancy, NetworkAcls networkAcls, PnsCredentials pnsCredentials, string serviceBusEndpoint, IReadOnlyList privateEndpointConnections, string scaleUnit, string dataCenter, PublicNetworkAccess? publicNetworkAccess, IDictionary serializedAdditionalRawData) + { + Name = name; + ProvisioningState = provisioningState; + Status = status; + Enabled = enabled; + Critical = critical; + SubscriptionId = subscriptionId; + Region = region; + MetricId = metricId; + CreatedOn = createdOn; + UpdatedOn = updatedOn; + NamespaceType = namespaceType; + ReplicationRegion = replicationRegion; + ZoneRedundancy = zoneRedundancy; + NetworkAcls = networkAcls; + PnsCredentials = pnsCredentials; + ServiceBusEndpoint = serviceBusEndpoint; + PrivateEndpointConnections = privateEndpointConnections; + ScaleUnit = scaleUnit; + DataCenter = dataCenter; + PublicNetworkAccess = publicNetworkAccess; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Name of the Notification Hubs namespace. This is immutable property, set automatically + /// by the service when the namespace is created. + /// + public string Name { get; } + /// Defines values for OperationProvisioningState. + public OperationProvisioningState? ProvisioningState { get; set; } + /// Namespace status. + public NamespaceStatus? Status { get; set; } + /// Gets or sets whether or not the namespace is currently enabled. + public bool? Enabled { get; } + /// Gets or sets whether or not the namespace is set as Critical. + public bool? Critical { get; } + /// Namespace subscription id. + public string SubscriptionId { get; } + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + public string Region { get; } + /// Azure Insights Metrics id. + public string MetricId { get; } + /// Time when the namespace was created. + public DateTimeOffset? CreatedOn { get; } + /// Time when the namespace was updated. + public DateTimeOffset? UpdatedOn { get; } + /// Defines values for NamespaceType. + public NamespaceType? NamespaceType { get; set; } + /// Allowed replication region. + public ReplicationRegion? ReplicationRegion { get; set; } + /// Namespace SKU name. + public ZoneRedundancyPreference? ZoneRedundancy { get; set; } + /// A collection of network authorization rules. + public NetworkAcls NetworkAcls { get; set; } + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + public PnsCredentials PnsCredentials { get; set; } + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + public string ServiceBusEndpoint { get; } + /// Private Endpoint Connections for namespace. + public IReadOnlyList PrivateEndpointConnections { get; } + /// Gets or sets scaleUnit where the namespace gets created. + public string ScaleUnit { get; set; } + /// Deprecated. + public string DataCenter { get; set; } + /// Type of public network access. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.Serialization.cs new file mode 100644 index 000000000000..b459f6a40bd5 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NamespaceResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NamespaceResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNamespaceResourcePatch(document.RootElement, options); + } + + internal static NamespaceResourcePatch DeserializeNamespaceResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsSku sku = default; + NamespaceProperties properties = default; + IDictionary tags = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NamespaceProperties.DeserializeNamespaceProperties(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NamespaceResourcePatch(sku, properties, tags ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NamespaceResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + NamespaceResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNamespaceResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NamespaceResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.cs new file mode 100644 index 000000000000..f94ab1f6345d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceResourcePatch.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Patch parameter for NamespaceResource. + public partial class NamespaceResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public NamespaceResourcePatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The Sku description for a namespace. + /// Represents namespace properties. + /// Dictionary of <string>. + /// Keeps track of any properties unknown to the library. + internal NamespaceResourcePatch(NotificationhubsSku sku, NamespaceProperties properties, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Sku = sku; + Properties = properties; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; set; } + /// Represents namespace properties. + public NamespaceProperties Properties { get; set; } + /// Dictionary of <string>. + public IDictionary Tags { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceStatus.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceStatus.cs new file mode 100644 index 000000000000..a7481703955b --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceStatus.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.Notificationhubs.Models +{ + /// Namespace status. + public readonly partial struct NamespaceStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NamespaceStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CreatedValue = "Created"; + private const string CreatingValue = "Creating"; + private const string SuspendedValue = "Suspended"; + private const string DeletingValue = "Deleting"; + + /// Created. + public static NamespaceStatus Created { get; } = new NamespaceStatus(CreatedValue); + /// Creating. + public static NamespaceStatus Creating { get; } = new NamespaceStatus(CreatingValue); + /// Suspended. + public static NamespaceStatus Suspended { get; } = new NamespaceStatus(SuspendedValue); + /// Deleting. + public static NamespaceStatus Deleting { get; } = new NamespaceStatus(DeletingValue); + /// Determines if two values are the same. + public static bool operator ==(NamespaceStatus left, NamespaceStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NamespaceStatus left, NamespaceStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NamespaceStatus(string value) => new NamespaceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NamespaceStatus other && Equals(other); + /// + public bool Equals(NamespaceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceType.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceType.cs new file mode 100644 index 000000000000..b14d4de464ed --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NamespaceType.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.Notificationhubs.Models +{ + /// Defines values for NamespaceType. + public readonly partial struct NamespaceType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NamespaceType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MessagingValue = "Messaging"; + private const string NotificationHubValue = "NotificationHub"; + + /// Messaging. + public static NamespaceType Messaging { get; } = new NamespaceType(MessagingValue); + /// NotificationHub. + public static NamespaceType NotificationHub { get; } = new NamespaceType(NotificationHubValue); + /// Determines if two values are the same. + public static bool operator ==(NamespaceType left, NamespaceType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NamespaceType left, NamespaceType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NamespaceType(string value) => new NamespaceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NamespaceType other && Equals(other); + /// + public bool Equals(NamespaceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.Serialization.cs new file mode 100644 index 000000000000..fff1f5d37971 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NetworkAcls : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkAcls)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(IPRules)) + { + writer.WritePropertyName("ipRules"u8); + writer.WriteStartArray(); + foreach (var item in IPRules) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PublicNetworkRule)) + { + writer.WritePropertyName("publicNetworkRule"u8); + writer.WriteObjectValue(PublicNetworkRule, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NetworkAcls IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NetworkAcls)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNetworkAcls(document.RootElement, options); + } + + internal static NetworkAcls DeserializeNetworkAcls(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ipRules = default; + PublicInternetAuthorizationRule publicNetworkRule = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipRules"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(IPRule.DeserializeIPRule(item, options)); + } + ipRules = array; + continue; + } + if (property.NameEquals("publicNetworkRule"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkRule = PublicInternetAuthorizationRule.DeserializePublicInternetAuthorizationRule(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NetworkAcls(ipRules ?? new ChangeTrackingList(), publicNetworkRule, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NetworkAcls)} does not support writing '{options.Format}' format."); + } + } + + NetworkAcls IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNetworkAcls(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NetworkAcls)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.cs new file mode 100644 index 000000000000..616c5985a886 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NetworkAcls.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// A collection of network authorization rules. + public partial class NetworkAcls + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public NetworkAcls() + { + IPRules = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of IP rules. + /// A default (public Internet) network authorization rule, which contains rights if no other network rule matches. + /// Keeps track of any properties unknown to the library. + internal NetworkAcls(IList ipRules, PublicInternetAuthorizationRule publicNetworkRule, IDictionary serializedAdditionalRawData) + { + IPRules = ipRules; + PublicNetworkRule = publicNetworkRule; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of IP rules. + public IList IPRules { get; } + /// A default (public Internet) network authorization rule, which contains rights if no other network rule matches. + internal PublicInternetAuthorizationRule PublicNetworkRule { get; set; } + /// List of access rights. + public IList PublicNetworkRuleRights + { + get => PublicNetworkRule is null ? default : PublicNetworkRule.Rights; + set => PublicNetworkRule = new PublicInternetAuthorizationRule(value); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.Serialization.cs new file mode 100644 index 000000000000..0796c56f30b5 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class NotificationHubListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NotificationHubListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationHubListResult(document.RootElement, options); + } + + internal static NotificationHubListResult DeserializeNotificationHubListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NotificationHubResourceData.DeserializeNotificationHubResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationHubListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationHubListResult)} does not support writing '{options.Format}' format."); + } + } + + NotificationHubListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationHubListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationHubListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.cs new file mode 100644 index 000000000000..fe797a8c8907 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Paged collection of NotificationHubResource items. + internal partial class NotificationHubListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The NotificationHubResource items on this page. + internal NotificationHubListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The NotificationHubResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal NotificationHubListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NotificationHubListResult() + { + } + + /// The NotificationHubResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.Serialization.cs new file mode 100644 index 000000000000..d9356b678c6c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.Serialization.cs @@ -0,0 +1,387 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NotificationHubResourcePatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubResourcePatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + 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("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(RegistrationTtl)) + { + writer.WritePropertyName("registrationTtl"u8); + writer.WriteStringValue(RegistrationTtl); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AuthorizationRules)) + { + writer.WritePropertyName("authorizationRules"u8); + writer.WriteStartArray(); + foreach (var item in AuthorizationRules) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ApnsCredential)) + { + writer.WritePropertyName("apnsCredential"u8); + writer.WriteObjectValue(ApnsCredential, options); + } + if (Optional.IsDefined(WnsCredential)) + { + writer.WritePropertyName("wnsCredential"u8); + writer.WriteObjectValue(WnsCredential, options); + } + if (Optional.IsDefined(GcmCredential)) + { + writer.WritePropertyName("gcmCredential"u8); + writer.WriteObjectValue(GcmCredential, options); + } + if (Optional.IsDefined(MpnsCredential)) + { + writer.WritePropertyName("mpnsCredential"u8); + writer.WriteObjectValue(MpnsCredential, options); + } + if (Optional.IsDefined(AdmCredential)) + { + writer.WritePropertyName("admCredential"u8); + writer.WriteObjectValue(AdmCredential, options); + } + if (Optional.IsDefined(BaiduCredential)) + { + writer.WritePropertyName("baiduCredential"u8); + writer.WriteObjectValue(BaiduCredential, options); + } + if (Optional.IsDefined(BrowserCredential)) + { + writer.WritePropertyName("browserCredential"u8); + writer.WriteObjectValue(BrowserCredential, options); + } + if (Optional.IsDefined(XiaomiCredential)) + { + writer.WritePropertyName("xiaomiCredential"u8); + writer.WriteObjectValue(XiaomiCredential, options); + } + if (Optional.IsDefined(FcmV1Credential)) + { + writer.WritePropertyName("fcmV1Credential"u8); + writer.WriteObjectValue(FcmV1Credential, options); + } + if (options.Format != "W" && Optional.IsDefined(DailyMaxActiveDevices)) + { + writer.WritePropertyName("dailyMaxActiveDevices"u8); + writer.WriteNumberValue(DailyMaxActiveDevices.Value); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NotificationHubResourcePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubResourcePatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationHubResourcePatch(document.RootElement, options); + } + + internal static NotificationHubResourcePatch DeserializeNotificationHubResourcePatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsSku sku = default; + IDictionary tags = default; + string name = default; + string registrationTtl = default; + IReadOnlyList authorizationRules = default; + ApnsCredential apnsCredential = default; + WnsCredential wnsCredential = default; + GcmCredential gcmCredential = default; + MpnsCredential mpnsCredential = default; + AdmCredential admCredential = default; + BaiduCredential baiduCredential = default; + BrowserCredential browserCredential = default; + XiaomiCredential xiaomiCredential = default; + FcmV1Credential fcmV1Credential = default; + long? dailyMaxActiveDevices = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("name"u8)) + { + name = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("registrationTtl"u8)) + { + registrationTtl = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("authorizationRules"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(SharedAccessAuthorizationRuleProperties.DeserializeSharedAccessAuthorizationRuleProperties(item, options)); + } + authorizationRules = array; + continue; + } + if (property0.NameEquals("apnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + apnsCredential = ApnsCredential.DeserializeApnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("wnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wnsCredential = WnsCredential.DeserializeWnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("gcmCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gcmCredential = GcmCredential.DeserializeGcmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("mpnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mpnsCredential = MpnsCredential.DeserializeMpnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("admCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + admCredential = AdmCredential.DeserializeAdmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("baiduCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baiduCredential = BaiduCredential.DeserializeBaiduCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("browserCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + browserCredential = BrowserCredential.DeserializeBrowserCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("xiaomiCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + xiaomiCredential = XiaomiCredential.DeserializeXiaomiCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("fcmV1Credential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fcmV1Credential = FcmV1Credential.DeserializeFcmV1Credential(property0.Value, options); + continue; + } + if (property0.NameEquals("dailyMaxActiveDevices"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dailyMaxActiveDevices = property0.Value.GetInt64(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationHubResourcePatch( + name, + registrationTtl, + authorizationRules ?? new ChangeTrackingList(), + apnsCredential, + wnsCredential, + gcmCredential, + mpnsCredential, + admCredential, + baiduCredential, + browserCredential, + xiaomiCredential, + fcmV1Credential, + dailyMaxActiveDevices, + sku, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationHubResourcePatch)} does not support writing '{options.Format}' format."); + } + } + + NotificationHubResourcePatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationHubResourcePatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationHubResourcePatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.cs new file mode 100644 index 000000000000..77dd0f5b2efa --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationHubResourcePatch.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Patch parameter for NamespaceResource. + public partial class NotificationHubResourcePatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public NotificationHubResourcePatch() + { + AuthorizationRules = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Gets or sets the NotificationHub name. + /// Gets or sets the RegistrationTtl of the created NotificationHub. + /// Gets or sets the AuthorizationRules of the created NotificationHub. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// + /// The Sku description for a namespace. + /// Dictionary of <string>. + /// Keeps track of any properties unknown to the library. + internal NotificationHubResourcePatch(string name, string registrationTtl, IReadOnlyList authorizationRules, ApnsCredential apnsCredential, WnsCredential wnsCredential, GcmCredential gcmCredential, MpnsCredential mpnsCredential, AdmCredential admCredential, BaiduCredential baiduCredential, BrowserCredential browserCredential, XiaomiCredential xiaomiCredential, FcmV1Credential fcmV1Credential, long? dailyMaxActiveDevices, NotificationhubsSku sku, IDictionary tags, IDictionary serializedAdditionalRawData) + { + Name = name; + RegistrationTtl = registrationTtl; + AuthorizationRules = authorizationRules; + ApnsCredential = apnsCredential; + WnsCredential = wnsCredential; + GcmCredential = gcmCredential; + MpnsCredential = mpnsCredential; + AdmCredential = admCredential; + BaiduCredential = baiduCredential; + BrowserCredential = browserCredential; + XiaomiCredential = xiaomiCredential; + FcmV1Credential = fcmV1Credential; + DailyMaxActiveDevices = dailyMaxActiveDevices; + Sku = sku; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the NotificationHub name. + public string Name { get; set; } + /// Gets or sets the RegistrationTtl of the created NotificationHub. + public string RegistrationTtl { get; set; } + /// Gets or sets the AuthorizationRules of the created NotificationHub. + public IReadOnlyList AuthorizationRules { get; } + /// Description of a NotificationHub ApnsCredential. + public ApnsCredential ApnsCredential { get; set; } + /// Description of a NotificationHub WnsCredential. + public WnsCredential WnsCredential { get; set; } + /// Description of a NotificationHub GcmCredential. + public GcmCredential GcmCredential { get; set; } + /// Description of a NotificationHub MpnsCredential. + public MpnsCredential MpnsCredential { get; set; } + /// Description of a NotificationHub AdmCredential. + public AdmCredential AdmCredential { get; set; } + /// Description of a NotificationHub BaiduCredential. + public BaiduCredential BaiduCredential { get; set; } + /// Description of a NotificationHub BrowserCredential. + public BrowserCredential BrowserCredential { get; set; } + /// Description of a NotificationHub XiaomiCredential. + public XiaomiCredential XiaomiCredential { get; set; } + /// Description of a NotificationHub FcmV1Credential. + public FcmV1Credential FcmV1Credential { get; set; } + /// Gets the daily max active devices. + public long? DailyMaxActiveDevices { get; } + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; set; } + /// Dictionary of <string>. + public IDictionary Tags { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateEndpointConnectionProvisioningState.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateEndpointConnectionProvisioningState.cs new file mode 100644 index 000000000000..3e00706dd483 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateEndpointConnectionProvisioningState.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// State of Private Endpoint Connection. + public readonly partial struct NotificationhubsPrivateEndpointConnectionProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NotificationhubsPrivateEndpointConnectionProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string SucceededValue = "Succeeded"; + private const string CreatingValue = "Creating"; + private const string UpdatingValue = "Updating"; + private const string UpdatingByProxyValue = "UpdatingByProxy"; + private const string DeletingValue = "Deleting"; + private const string DeletingByProxyValue = "DeletingByProxy"; + private const string DeletedValue = "Deleted"; + + /// Unknown. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Unknown { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(UnknownValue); + /// Succeeded. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Succeeded { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(SucceededValue); + /// Creating. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Creating { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(CreatingValue); + /// Updating. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Updating { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(UpdatingValue); + /// UpdatingByProxy. + public static NotificationhubsPrivateEndpointConnectionProvisioningState UpdatingByProxy { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(UpdatingByProxyValue); + /// Deleting. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Deleting { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(DeletingValue); + /// DeletingByProxy. + public static NotificationhubsPrivateEndpointConnectionProvisioningState DeletingByProxy { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(DeletingByProxyValue); + /// Deleted. + public static NotificationhubsPrivateEndpointConnectionProvisioningState Deleted { get; } = new NotificationhubsPrivateEndpointConnectionProvisioningState(DeletedValue); + /// Determines if two values are the same. + public static bool operator ==(NotificationhubsPrivateEndpointConnectionProvisioningState left, NotificationhubsPrivateEndpointConnectionProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NotificationhubsPrivateEndpointConnectionProvisioningState left, NotificationhubsPrivateEndpointConnectionProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NotificationhubsPrivateEndpointConnectionProvisioningState(string value) => new NotificationhubsPrivateEndpointConnectionProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NotificationhubsPrivateEndpointConnectionProvisioningState other && Equals(other); + /// + public bool Equals(NotificationhubsPrivateEndpointConnectionProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.Serialization.cs new file mode 100644 index 000000000000..2f8b369e4e20 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class NotificationhubsPrivateLinkResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NotificationhubsPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement, options); + } + + internal static NotificationhubsPrivateLinkResourceListResult DeserializeNotificationhubsPrivateLinkResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NotificationhubsPrivateLinkResourceDataData.DeserializeNotificationhubsPrivateLinkResourceDataData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationhubsPrivateLinkResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + NotificationhubsPrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..0b17eadf1ad6 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// The response of a PrivateLinkResource list operation. + internal partial class NotificationhubsPrivateLinkResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The PrivateLinkResource items on this page. + internal NotificationhubsPrivateLinkResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The PrivateLinkResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal NotificationhubsPrivateLinkResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NotificationhubsPrivateLinkResourceListResult() + { + } + + /// The PrivateLinkResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.Serialization.cs new file mode 100644 index 000000000000..3127b614a65b --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NotificationhubsPrivateLinkResourceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(GroupId)) + { + writer.WritePropertyName("groupId"u8); + writer.WriteStringValue(GroupId); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RequiredMembers)) + { + writer.WritePropertyName("requiredMembers"u8); + writer.WriteStartArray(); + foreach (var item in RequiredMembers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RequiredZoneNames)) + { + writer.WritePropertyName("requiredZoneNames"u8); + writer.WriteStartArray(); + foreach (var item in RequiredZoneNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NotificationhubsPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationhubsPrivateLinkResourceProperties(document.RootElement, options); + } + + internal static NotificationhubsPrivateLinkResourceProperties DeserializeNotificationhubsPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string groupId = default; + IReadOnlyList requiredMembers = default; + IReadOnlyList requiredZoneNames = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("groupId"u8)) + { + groupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requiredMembers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + requiredMembers = array; + continue; + } + if (property.NameEquals("requiredZoneNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + requiredZoneNames = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationhubsPrivateLinkResourceProperties(groupId, requiredMembers ?? new ChangeTrackingList(), requiredZoneNames ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + NotificationhubsPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationhubsPrivateLinkResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..8423b0537a73 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsPrivateLinkResourceProperties.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Represents properties of Private Link Resource. + public partial class NotificationhubsPrivateLinkResourceProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NotificationhubsPrivateLinkResourceProperties() + { + RequiredMembers = new ChangeTrackingList(); + RequiredZoneNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A Group Id for Private Link. For Notification Hubs, it is always set to "namespace". + /// Required members. For Notification Hubs, it's always a collection with a single "namespace" item. + /// Required DNS zone names. For Notification Hubs, it contains two CNames for Service Bus and Notification Hubs zones. + /// Keeps track of any properties unknown to the library. + internal NotificationhubsPrivateLinkResourceProperties(string groupId, IReadOnlyList requiredMembers, IReadOnlyList requiredZoneNames, IDictionary serializedAdditionalRawData) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + RequiredZoneNames = requiredZoneNames; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A Group Id for Private Link. For Notification Hubs, it is always set to "namespace". + public string GroupId { get; } + /// Required members. For Notification Hubs, it's always a collection with a single "namespace" item. + public IReadOnlyList RequiredMembers { get; } + /// Required DNS zone names. For Notification Hubs, it contains two CNames for Service Bus and Notification Hubs zones. + public IReadOnlyList RequiredZoneNames { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.Serialization.cs new file mode 100644 index 000000000000..06e39152612c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.Serialization.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class NotificationhubsSku : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsSku)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.ToString()); + if (Optional.IsDefined(Tier)) + { + writer.WritePropertyName("tier"u8); + writer.WriteStringValue(Tier); + } + if (Optional.IsDefined(Size)) + { + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size); + } + if (Optional.IsDefined(Family)) + { + writer.WritePropertyName("family"u8); + writer.WriteStringValue(Family); + } + if (Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NotificationhubsSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsSku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationhubsSku(document.RootElement, options); + } + + internal static NotificationhubsSku DeserializeNotificationhubsSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsSkuName name = default; + string tier = default; + string size = default; + string family = default; + int? capacity = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = new NotificationhubsSkuName(property.Value.GetString()); + continue; + } + if (property.NameEquals("tier"u8)) + { + tier = property.Value.GetString(); + continue; + } + if (property.NameEquals("size"u8)) + { + size = property.Value.GetString(); + continue; + } + if (property.NameEquals("family"u8)) + { + family = property.Value.GetString(); + continue; + } + if (property.NameEquals("capacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationhubsSku( + name, + tier, + size, + family, + capacity, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationhubsSku)} does not support writing '{options.Format}' format."); + } + } + + NotificationhubsSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationhubsSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationhubsSku)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.cs new file mode 100644 index 000000000000..6824299b0d03 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSku.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// The Sku description for a namespace. + public partial class NotificationhubsSku + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Namespace SKU name. + public NotificationhubsSku(NotificationhubsSkuName name) + { + Name = name; + } + + /// Initializes a new instance of . + /// Namespace SKU name. + /// Gets or sets the tier of particular sku. + /// Gets or sets the Sku size. + /// Gets or sets the Sku Family. + /// Gets or sets the capacity of the resource. + /// Keeps track of any properties unknown to the library. + internal NotificationhubsSku(NotificationhubsSkuName name, string tier, string size, string family, int? capacity, IDictionary serializedAdditionalRawData) + { + Name = name; + Tier = tier; + Size = size; + Family = family; + Capacity = capacity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NotificationhubsSku() + { + } + + /// Namespace SKU name. + public NotificationhubsSkuName Name { get; set; } + /// Gets or sets the tier of particular sku. + public string Tier { get; set; } + /// Gets or sets the Sku size. + public string Size { get; set; } + /// Gets or sets the Sku Family. + public string Family { get; set; } + /// Gets or sets the capacity of the resource. + public int? Capacity { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSkuName.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSkuName.cs new file mode 100644 index 000000000000..33eddf91c714 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/NotificationhubsSkuName.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Namespace SKU name. + public readonly partial struct NotificationhubsSkuName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NotificationhubsSkuName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FreeValue = "Free"; + private const string BasicValue = "Basic"; + private const string StandardValue = "Standard"; + + /// Free. + public static NotificationhubsSkuName Free { get; } = new NotificationhubsSkuName(FreeValue); + /// Basic. + public static NotificationhubsSkuName Basic { get; } = new NotificationhubsSkuName(BasicValue); + /// Standard. + public static NotificationhubsSkuName Standard { get; } = new NotificationhubsSkuName(StandardValue); + /// Determines if two values are the same. + public static bool operator ==(NotificationhubsSkuName left, NotificationhubsSkuName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NotificationhubsSkuName left, NotificationhubsSkuName right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator NotificationhubsSkuName(string value) => new NotificationhubsSkuName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NotificationhubsSkuName other && Equals(other); + /// + public bool Equals(NotificationhubsSkuName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.Serialization.cs new file mode 100644 index 000000000000..7f941e7107b0 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class OperationDisplay : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + if (options.Format != "W" && Optional.IsDefined(Resource)) + { + writer.WritePropertyName("resource"u8); + writer.WriteStringValue(Resource); + } + if (options.Format != "W" && Optional.IsDefined(Operation)) + { + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OperationDisplay IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationDisplay)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationDisplay(document.RootElement, options); + } + + internal static OperationDisplay DeserializeOperationDisplay(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provider = default; + string resource = default; + string operation = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("resource"u8)) + { + resource = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationDisplay(provider, resource, operation, description, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{options.Format}' format."); + } + } + + OperationDisplay IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOperationDisplay(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationDisplay)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..0393bce79767 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationDisplay.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// The OperationDisplay. + public partial class OperationDisplay + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal OperationDisplay() + { + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// Keeps track of any properties unknown to the library. + internal OperationDisplay(string provider, string resource, string operation, string description, IDictionary serializedAdditionalRawData) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + public string Provider { get; } + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + public string Resource { get; } + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + public string Operation { get; } + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + public string Description { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.Serialization.cs new file mode 100644 index 000000000000..d62d05e70e30 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class OperationListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OperationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationListResult(document.RootElement, options); + } + + internal static OperationListResult DeserializeOperationListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Info.DeserializeInfo(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{options.Format}' format."); + } + } + + OperationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOperationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..966ed1c1c63f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Paged collection of Operation items. + internal partial class OperationListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The Operation items on this page. + internal OperationListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Operation items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal OperationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationListResult() + { + } + + /// The Operation items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.Serialization.cs new file mode 100644 index 000000000000..f04905c2c62d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class OperationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ServiceSpecification)) + { + writer.WritePropertyName("serviceSpecification"u8); + writer.WriteObjectValue(ServiceSpecification, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OperationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationProperties(document.RootElement, options); + } + + internal static OperationProperties DeserializeOperationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ServiceSpecification serviceSpecification = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("serviceSpecification"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceSpecification = ServiceSpecification.DeserializeServiceSpecification(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationProperties(serviceSpecification, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(OperationProperties)} does not support writing '{options.Format}' format."); + } + } + + OperationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOperationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.cs new file mode 100644 index 000000000000..be723b0d66d0 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProperties.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Optional operation properties. + internal partial class OperationProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal OperationProperties() + { + } + + /// Initializes a new instance of . + /// Optional service specification used in Operations API. + /// Keeps track of any properties unknown to the library. + internal OperationProperties(ServiceSpecification serviceSpecification, IDictionary serializedAdditionalRawData) + { + ServiceSpecification = serviceSpecification; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Optional service specification used in Operations API. + public ServiceSpecification ServiceSpecification { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProvisioningState.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProvisioningState.cs new file mode 100644 index 000000000000..5abe793e3651 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/OperationProvisioningState.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.Notificationhubs.Models +{ + /// Defines values for OperationProvisioningState. + public readonly partial struct OperationProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperationProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string InProgressValue = "InProgress"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string PendingValue = "Pending"; + private const string DisabledValue = "Disabled"; + + /// Unknown. + public static OperationProvisioningState Unknown { get; } = new OperationProvisioningState(UnknownValue); + /// InProgress. + public static OperationProvisioningState InProgress { get; } = new OperationProvisioningState(InProgressValue); + /// Succeeded. + public static OperationProvisioningState Succeeded { get; } = new OperationProvisioningState(SucceededValue); + /// Failed. + public static OperationProvisioningState Failed { get; } = new OperationProvisioningState(FailedValue); + /// Canceled. + public static OperationProvisioningState Canceled { get; } = new OperationProvisioningState(CanceledValue); + /// Pending. + public static OperationProvisioningState Pending { get; } = new OperationProvisioningState(PendingValue); + /// Disabled. + public static OperationProvisioningState Disabled { get; } = new OperationProvisioningState(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(OperationProvisioningState left, OperationProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperationProvisioningState left, OperationProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator OperationProvisioningState(string value) => new OperationProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationProvisioningState other && Equals(other); + /// + public bool Equals(OperationProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.Serialization.cs new file mode 100644 index 000000000000..22f49f59d66d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.Serialization.cs @@ -0,0 +1,263 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class PnsCredentials : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PnsCredentials)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AdmCredential)) + { + writer.WritePropertyName("admCredential"u8); + writer.WriteObjectValue(AdmCredential, options); + } + if (Optional.IsDefined(ApnsCredential)) + { + writer.WritePropertyName("apnsCredential"u8); + writer.WriteObjectValue(ApnsCredential, options); + } + if (Optional.IsDefined(BaiduCredential)) + { + writer.WritePropertyName("baiduCredential"u8); + writer.WriteObjectValue(BaiduCredential, options); + } + if (Optional.IsDefined(BrowserCredential)) + { + writer.WritePropertyName("browserCredential"u8); + writer.WriteObjectValue(BrowserCredential, options); + } + if (Optional.IsDefined(GcmCredential)) + { + writer.WritePropertyName("gcmCredential"u8); + writer.WriteObjectValue(GcmCredential, options); + } + if (Optional.IsDefined(MpnsCredential)) + { + writer.WritePropertyName("mpnsCredential"u8); + writer.WriteObjectValue(MpnsCredential, options); + } + if (Optional.IsDefined(WnsCredential)) + { + writer.WritePropertyName("wnsCredential"u8); + writer.WriteObjectValue(WnsCredential, options); + } + if (Optional.IsDefined(XiaomiCredential)) + { + writer.WritePropertyName("xiaomiCredential"u8); + writer.WriteObjectValue(XiaomiCredential, options); + } + if (Optional.IsDefined(FcmV1Credential)) + { + writer.WritePropertyName("fcmV1Credential"u8); + writer.WriteObjectValue(FcmV1Credential, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PnsCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PnsCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePnsCredentials(document.RootElement, options); + } + + internal static PnsCredentials DeserializePnsCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AdmCredential admCredential = default; + ApnsCredential apnsCredential = default; + BaiduCredential baiduCredential = default; + BrowserCredential browserCredential = default; + GcmCredential gcmCredential = default; + MpnsCredential mpnsCredential = default; + WnsCredential wnsCredential = default; + XiaomiCredential xiaomiCredential = default; + FcmV1Credential fcmV1Credential = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("admCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + admCredential = AdmCredential.DeserializeAdmCredential(property.Value, options); + continue; + } + if (property.NameEquals("apnsCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + apnsCredential = ApnsCredential.DeserializeApnsCredential(property.Value, options); + continue; + } + if (property.NameEquals("baiduCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baiduCredential = BaiduCredential.DeserializeBaiduCredential(property.Value, options); + continue; + } + if (property.NameEquals("browserCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + browserCredential = BrowserCredential.DeserializeBrowserCredential(property.Value, options); + continue; + } + if (property.NameEquals("gcmCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gcmCredential = GcmCredential.DeserializeGcmCredential(property.Value, options); + continue; + } + if (property.NameEquals("mpnsCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mpnsCredential = MpnsCredential.DeserializeMpnsCredential(property.Value, options); + continue; + } + if (property.NameEquals("wnsCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wnsCredential = WnsCredential.DeserializeWnsCredential(property.Value, options); + continue; + } + if (property.NameEquals("xiaomiCredential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + xiaomiCredential = XiaomiCredential.DeserializeXiaomiCredential(property.Value, options); + continue; + } + if (property.NameEquals("fcmV1Credential"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fcmV1Credential = FcmV1Credential.DeserializeFcmV1Credential(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PnsCredentials( + admCredential, + apnsCredential, + baiduCredential, + browserCredential, + gcmCredential, + mpnsCredential, + wnsCredential, + xiaomiCredential, + fcmV1Credential, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PnsCredentials)} does not support writing '{options.Format}' format."); + } + } + + PnsCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePnsCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PnsCredentials)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.cs new file mode 100644 index 000000000000..10bc08d94aad --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentials.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + public partial class PnsCredentials + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PnsCredentials() + { + } + + /// Initializes a new instance of . + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// Keeps track of any properties unknown to the library. + internal PnsCredentials(AdmCredential admCredential, ApnsCredential apnsCredential, BaiduCredential baiduCredential, BrowserCredential browserCredential, GcmCredential gcmCredential, MpnsCredential mpnsCredential, WnsCredential wnsCredential, XiaomiCredential xiaomiCredential, FcmV1Credential fcmV1Credential, IDictionary serializedAdditionalRawData) + { + AdmCredential = admCredential; + ApnsCredential = apnsCredential; + BaiduCredential = baiduCredential; + BrowserCredential = browserCredential; + GcmCredential = gcmCredential; + MpnsCredential = mpnsCredential; + WnsCredential = wnsCredential; + XiaomiCredential = xiaomiCredential; + FcmV1Credential = fcmV1Credential; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Description of a NotificationHub AdmCredential. + public AdmCredential AdmCredential { get; set; } + /// Description of a NotificationHub ApnsCredential. + public ApnsCredential ApnsCredential { get; set; } + /// Description of a NotificationHub BaiduCredential. + public BaiduCredential BaiduCredential { get; set; } + /// Description of a NotificationHub BrowserCredential. + public BrowserCredential BrowserCredential { get; set; } + /// Description of a NotificationHub GcmCredential. + public GcmCredential GcmCredential { get; set; } + /// Description of a NotificationHub MpnsCredential. + public MpnsCredential MpnsCredential { get; set; } + /// Description of a NotificationHub WnsCredential. + public WnsCredential WnsCredential { get; set; } + /// Description of a NotificationHub XiaomiCredential. + public XiaomiCredential XiaomiCredential { get; set; } + /// Description of a NotificationHub FcmV1Credential. + public FcmV1Credential FcmV1Credential { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.Serialization.cs new file mode 100644 index 000000000000..0675125267f3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.Serialization.cs @@ -0,0 +1,336 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class PnsCredentialsResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PnsCredentialsResource)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + } + 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("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(AdmCredential)) + { + writer.WritePropertyName("admCredential"u8); + writer.WriteObjectValue(AdmCredential, options); + } + if (Optional.IsDefined(ApnsCredential)) + { + writer.WritePropertyName("apnsCredential"u8); + writer.WriteObjectValue(ApnsCredential, options); + } + if (Optional.IsDefined(BaiduCredential)) + { + writer.WritePropertyName("baiduCredential"u8); + writer.WriteObjectValue(BaiduCredential, options); + } + if (Optional.IsDefined(BrowserCredential)) + { + writer.WritePropertyName("browserCredential"u8); + writer.WriteObjectValue(BrowserCredential, options); + } + if (Optional.IsDefined(GcmCredential)) + { + writer.WritePropertyName("gcmCredential"u8); + writer.WriteObjectValue(GcmCredential, options); + } + if (Optional.IsDefined(MpnsCredential)) + { + writer.WritePropertyName("mpnsCredential"u8); + writer.WriteObjectValue(MpnsCredential, options); + } + if (Optional.IsDefined(WnsCredential)) + { + writer.WritePropertyName("wnsCredential"u8); + writer.WriteObjectValue(WnsCredential, options); + } + if (Optional.IsDefined(XiaomiCredential)) + { + writer.WritePropertyName("xiaomiCredential"u8); + writer.WriteObjectValue(XiaomiCredential, options); + } + if (Optional.IsDefined(FcmV1Credential)) + { + writer.WritePropertyName("fcmV1Credential"u8); + writer.WriteObjectValue(FcmV1Credential, options); + } + writer.WriteEndObject(); + } + + PnsCredentialsResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PnsCredentialsResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePnsCredentialsResource(document.RootElement, options); + } + + internal static PnsCredentialsResource DeserializePnsCredentialsResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string location = default; + IReadOnlyDictionary tags = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + AdmCredential admCredential = default; + ApnsCredential apnsCredential = default; + BaiduCredential baiduCredential = default; + BrowserCredential browserCredential = default; + GcmCredential gcmCredential = default; + MpnsCredential mpnsCredential = default; + WnsCredential wnsCredential = default; + XiaomiCredential xiaomiCredential = default; + FcmV1Credential fcmV1Credential = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + location = property.Value.GetString(); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (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("admCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + admCredential = AdmCredential.DeserializeAdmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("apnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + apnsCredential = ApnsCredential.DeserializeApnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("baiduCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baiduCredential = BaiduCredential.DeserializeBaiduCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("browserCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + browserCredential = BrowserCredential.DeserializeBrowserCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("gcmCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gcmCredential = GcmCredential.DeserializeGcmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("mpnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mpnsCredential = MpnsCredential.DeserializeMpnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("wnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wnsCredential = WnsCredential.DeserializeWnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("xiaomiCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + xiaomiCredential = XiaomiCredential.DeserializeXiaomiCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("fcmV1Credential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fcmV1Credential = FcmV1Credential.DeserializeFcmV1Credential(property0.Value, options); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PnsCredentialsResource( + id, + name, + type, + systemData, + admCredential, + apnsCredential, + baiduCredential, + browserCredential, + gcmCredential, + mpnsCredential, + wnsCredential, + xiaomiCredential, + fcmV1Credential, + location, + tags ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PnsCredentialsResource)} does not support writing '{options.Format}' format."); + } + } + + PnsCredentialsResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePnsCredentialsResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PnsCredentialsResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.cs new file mode 100644 index 000000000000..6284ccd3854c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PnsCredentialsResource.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// + /// Description of a NotificationHub PNS Credentials. This is a response of the POST requests that return namespace or hubs + /// PNS credentials. + /// + public partial class PnsCredentialsResource : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal PnsCredentialsResource() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// Deprecated - only for compatibility. + /// Deprecated - only for compatibility. + /// Keeps track of any properties unknown to the library. + internal PnsCredentialsResource(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AdmCredential admCredential, ApnsCredential apnsCredential, BaiduCredential baiduCredential, BrowserCredential browserCredential, GcmCredential gcmCredential, MpnsCredential mpnsCredential, WnsCredential wnsCredential, XiaomiCredential xiaomiCredential, FcmV1Credential fcmV1Credential, string location, IReadOnlyDictionary tags, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + AdmCredential = admCredential; + ApnsCredential = apnsCredential; + BaiduCredential = baiduCredential; + BrowserCredential = browserCredential; + GcmCredential = gcmCredential; + MpnsCredential = mpnsCredential; + WnsCredential = wnsCredential; + XiaomiCredential = xiaomiCredential; + FcmV1Credential = fcmV1Credential; + Location = location; + Tags = tags; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Description of a NotificationHub AdmCredential. + public AdmCredential AdmCredential { get; } + /// Description of a NotificationHub ApnsCredential. + public ApnsCredential ApnsCredential { get; } + /// Description of a NotificationHub BaiduCredential. + public BaiduCredential BaiduCredential { get; } + /// Description of a NotificationHub BrowserCredential. + public BrowserCredential BrowserCredential { get; } + /// Description of a NotificationHub GcmCredential. + public GcmCredential GcmCredential { get; } + /// Description of a NotificationHub MpnsCredential. + public MpnsCredential MpnsCredential { get; } + /// Description of a NotificationHub WnsCredential. + public WnsCredential WnsCredential { get; } + /// Description of a NotificationHub XiaomiCredential. + public XiaomiCredential XiaomiCredential { get; } + /// Description of a NotificationHub FcmV1Credential. + public FcmV1Credential FcmV1Credential { get; } + /// Deprecated - only for compatibility. + public string Location { get; } + /// Deprecated - only for compatibility. + public IReadOnlyDictionary Tags { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.Serialization.cs new file mode 100644 index 000000000000..2068a0fde999 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class PolicyKeyResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PolicyKeyResource)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("policyKey"u8); + writer.WriteStringValue(PolicyKey.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PolicyKeyResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PolicyKeyResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolicyKeyResource(document.RootElement, options); + } + + internal static PolicyKeyResource DeserializePolicyKeyResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PolicyKeyType policyKey = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("policyKey"u8)) + { + policyKey = new PolicyKeyType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PolicyKeyResource(policyKey, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PolicyKeyResource)} does not support writing '{options.Format}' format."); + } + } + + PolicyKeyResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePolicyKeyResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PolicyKeyResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.cs new file mode 100644 index 000000000000..a2b82b83b299 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyResource.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Namespace / NotificationHub Regenerate Keys request. + public partial class PolicyKeyResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Type of Shared Access Policy Key (primary or secondary). + public PolicyKeyResource(PolicyKeyType policyKey) + { + PolicyKey = policyKey; + } + + /// Initializes a new instance of . + /// Type of Shared Access Policy Key (primary or secondary). + /// Keeps track of any properties unknown to the library. + internal PolicyKeyResource(PolicyKeyType policyKey, IDictionary serializedAdditionalRawData) + { + PolicyKey = policyKey; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PolicyKeyResource() + { + } + + /// Type of Shared Access Policy Key (primary or secondary). + public PolicyKeyType PolicyKey { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyType.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyType.cs new file mode 100644 index 000000000000..7986e41cd89f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PolicyKeyType.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.Notificationhubs.Models +{ + /// Type of Shared Access Policy Key (primary or secondary). + public readonly partial struct PolicyKeyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PolicyKeyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PrimaryKeyValue = "PrimaryKey"; + private const string SecondaryKeyValue = "SecondaryKey"; + + /// PrimaryKey. + public static PolicyKeyType PrimaryKey { get; } = new PolicyKeyType(PrimaryKeyValue); + /// SecondaryKey. + public static PolicyKeyType SecondaryKey { get; } = new PolicyKeyType(SecondaryKeyValue); + /// Determines if two values are the same. + public static bool operator ==(PolicyKeyType left, PolicyKeyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PolicyKeyType left, PolicyKeyType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PolicyKeyType(string value) => new PolicyKeyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PolicyKeyType other && Equals(other); + /// + public bool Equals(PolicyKeyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs new file mode 100644 index 000000000000..98fef8849b28 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.Serialization.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class PrivateEndpointConnectionProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(PrivateEndpoint)) + { + writer.WritePropertyName("privateEndpoint"u8); + JsonSerializer.Serialize(writer, PrivateEndpoint); + } + if (options.Format != "W" && Optional.IsCollectionDefined(GroupIds)) + { + writer.WritePropertyName("groupIds"u8); + writer.WriteStartArray(); + foreach (var item in GroupIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PrivateLinkServiceConnectionState)) + { + writer.WritePropertyName("privateLinkServiceConnectionState"u8); + writer.WriteObjectValue(PrivateLinkServiceConnectionState, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PrivateEndpointConnectionProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + + internal static PrivateEndpointConnectionProperties DeserializePrivateEndpointConnectionProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsPrivateEndpointConnectionProvisioningState? provisioningState = default; + SubResource privateEndpoint = default; + IReadOnlyList groupIds = default; + RemotePrivateLinkServiceConnectionState privateLinkServiceConnectionState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new NotificationhubsPrivateEndpointConnectionProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("privateEndpoint"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateEndpoint = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("groupIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + groupIds = array; + continue; + } + if (property.NameEquals("privateLinkServiceConnectionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateLinkServiceConnectionState = RemotePrivateLinkServiceConnectionState.DeserializeRemotePrivateLinkServiceConnectionState(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PrivateEndpointConnectionProperties(provisioningState, privateEndpoint, groupIds ?? new ChangeTrackingList(), privateLinkServiceConnectionState, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support writing '{options.Format}' format."); + } + } + + PrivateEndpointConnectionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePrivateEndpointConnectionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.cs new file mode 100644 index 000000000000..38c00966adf5 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionProperties.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Private Endpoint Connection properties. + public partial class PrivateEndpointConnectionProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PrivateEndpointConnectionProperties() + { + GroupIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// State of Private Endpoint Connection. + /// Represents a Private Endpoint that is connected to Notification Hubs namespace using Private Endpoint Connection. + /// List of group ids. For Notification Hubs, it always contains a single "namespace" element. + /// State of the Private Link Service connection. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionProperties(NotificationhubsPrivateEndpointConnectionProvisioningState? provisioningState, SubResource privateEndpoint, IReadOnlyList groupIds, RemotePrivateLinkServiceConnectionState privateLinkServiceConnectionState, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + PrivateEndpoint = privateEndpoint; + GroupIds = groupIds; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// State of Private Endpoint Connection. + public NotificationhubsPrivateEndpointConnectionProvisioningState? ProvisioningState { get; set; } + /// Represents a Private Endpoint that is connected to Notification Hubs namespace using Private Endpoint Connection. + internal SubResource PrivateEndpoint { get; set; } + /// Gets Id. + public ResourceIdentifier PrivateEndpointId + { + get => PrivateEndpoint is null ? default : PrivateEndpoint.Id; + } + + /// List of group ids. For Notification Hubs, it always contains a single "namespace" element. + public IReadOnlyList GroupIds { get; } + /// State of the Private Link Service connection. + public RemotePrivateLinkServiceConnectionState PrivateLinkServiceConnectionState { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.Serialization.cs new file mode 100644 index 000000000000..69614ece66f1 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class PrivateEndpointConnectionResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PrivateEndpointConnectionResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpointConnectionResourceListResult(document.RootElement, options); + } + + internal static PrivateEndpointConnectionResourceListResult DeserializePrivateEndpointConnectionResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PrivateEndpointConnectionResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + PrivateEndpointConnectionResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePrivateEndpointConnectionResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.cs new file mode 100644 index 000000000000..81d81bc8cd01 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateEndpointConnectionResourceListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// The response of a PrivateEndpointConnectionResource list operation. + internal partial class PrivateEndpointConnectionResourceListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The PrivateEndpointConnectionResource items on this page. + internal PrivateEndpointConnectionResourceListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The PrivateEndpointConnectionResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PrivateEndpointConnectionResourceListResult() + { + } + + /// The PrivateEndpointConnectionResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateLinkConnectionStatus.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateLinkConnectionStatus.cs new file mode 100644 index 000000000000..ab9ae50d3fad --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PrivateLinkConnectionStatus.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.Notificationhubs.Models +{ + /// State of Private Link Connection. + public readonly partial struct PrivateLinkConnectionStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PrivateLinkConnectionStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DisconnectedValue = "Disconnected"; + private const string PendingValue = "Pending"; + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + + /// Disconnected. + public static PrivateLinkConnectionStatus Disconnected { get; } = new PrivateLinkConnectionStatus(DisconnectedValue); + /// Pending. + public static PrivateLinkConnectionStatus Pending { get; } = new PrivateLinkConnectionStatus(PendingValue); + /// Approved. + public static PrivateLinkConnectionStatus Approved { get; } = new PrivateLinkConnectionStatus(ApprovedValue); + /// Rejected. + public static PrivateLinkConnectionStatus Rejected { get; } = new PrivateLinkConnectionStatus(RejectedValue); + /// Determines if two values are the same. + public static bool operator ==(PrivateLinkConnectionStatus left, PrivateLinkConnectionStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PrivateLinkConnectionStatus left, PrivateLinkConnectionStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PrivateLinkConnectionStatus(string value) => new PrivateLinkConnectionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PrivateLinkConnectionStatus other && Equals(other); + /// + public bool Equals(PrivateLinkConnectionStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.Serialization.cs new file mode 100644 index 000000000000..49bb631a553e --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.Serialization.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class PublicInternetAuthorizationRule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PublicInternetAuthorizationRule)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("rights"u8); + writer.WriteStartArray(); + foreach (var item in Rights) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PublicInternetAuthorizationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PublicInternetAuthorizationRule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePublicInternetAuthorizationRule(document.RootElement, options); + } + + internal static PublicInternetAuthorizationRule DeserializePublicInternetAuthorizationRule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList rights = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rights"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AccessRight(item.GetString())); + } + rights = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PublicInternetAuthorizationRule(rights, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PublicInternetAuthorizationRule)} does not support writing '{options.Format}' format."); + } + } + + PublicInternetAuthorizationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePublicInternetAuthorizationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PublicInternetAuthorizationRule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.cs new file mode 100644 index 000000000000..177efd1e3cdd --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicInternetAuthorizationRule.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// A default (public Internet) network authorization rule, which contains rights if no other network rule matches. + internal partial class PublicInternetAuthorizationRule + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// List of access rights. + /// is null. + public PublicInternetAuthorizationRule(IEnumerable rights) + { + Argument.AssertNotNull(rights, nameof(rights)); + + Rights = rights.ToList(); + } + + /// Initializes a new instance of . + /// List of access rights. + /// Keeps track of any properties unknown to the library. + internal PublicInternetAuthorizationRule(IList rights, IDictionary serializedAdditionalRawData) + { + Rights = rights; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PublicInternetAuthorizationRule() + { + } + + /// List of access rights. + public IList Rights { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicNetworkAccess.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicNetworkAccess.cs new file mode 100644 index 000000000000..fc0c4c943393 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/PublicNetworkAccess.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.Notificationhubs.Models +{ + /// Type of public network access. + public readonly partial struct PublicNetworkAccess : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PublicNetworkAccess(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EnabledValue = "Enabled"; + private const string DisabledValue = "Disabled"; + + /// Enabled. + public static PublicNetworkAccess Enabled { get; } = new PublicNetworkAccess(EnabledValue); + /// Disabled. + public static PublicNetworkAccess Disabled { get; } = new PublicNetworkAccess(DisabledValue); + /// Determines if two values are the same. + public static bool operator ==(PublicNetworkAccess left, PublicNetworkAccess right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PublicNetworkAccess left, PublicNetworkAccess right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PublicNetworkAccess(string value) => new PublicNetworkAccess(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicNetworkAccess other && Equals(other); + /// + public bool Equals(PublicNetworkAccess other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.Serialization.cs new file mode 100644 index 000000000000..df0f71e2ea5b --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.Serialization.cs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class RegistrationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RegistrationResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ApplicationPlatform)) + { + writer.WritePropertyName("applicationPlatform"u8); + writer.WriteStringValue(ApplicationPlatform); + } + if (options.Format != "W" && Optional.IsDefined(PnsHandle)) + { + writer.WritePropertyName("pnsHandle"u8); + writer.WriteStringValue(PnsHandle); + } + if (options.Format != "W" && Optional.IsDefined(RegistrationId)) + { + writer.WritePropertyName("registrationId"u8); + writer.WriteStringValue(RegistrationId); + } + if (options.Format != "W" && Optional.IsDefined(Outcome)) + { + writer.WritePropertyName("outcome"u8); + writer.WriteStringValue(Outcome); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RegistrationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RegistrationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRegistrationResult(document.RootElement, options); + } + + internal static RegistrationResult DeserializeRegistrationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string applicationPlatform = default; + string pnsHandle = default; + string registrationId = default; + string outcome = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("applicationPlatform"u8)) + { + applicationPlatform = property.Value.GetString(); + continue; + } + if (property.NameEquals("pnsHandle"u8)) + { + pnsHandle = property.Value.GetString(); + continue; + } + if (property.NameEquals("registrationId"u8)) + { + registrationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("outcome"u8)) + { + outcome = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RegistrationResult(applicationPlatform, pnsHandle, registrationId, outcome, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(RegistrationResult)} does not support writing '{options.Format}' format."); + } + } + + RegistrationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRegistrationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RegistrationResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.cs new file mode 100644 index 000000000000..e52c63d819ae --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RegistrationResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Notification result for a single registration. + public partial class RegistrationResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RegistrationResult() + { + } + + /// Initializes a new instance of . + /// PNS type. + /// PNS handle. + /// Registration id. + /// Notification outcome. + /// Keeps track of any properties unknown to the library. + internal RegistrationResult(string applicationPlatform, string pnsHandle, string registrationId, string outcome, IDictionary serializedAdditionalRawData) + { + ApplicationPlatform = applicationPlatform; + PnsHandle = pnsHandle; + RegistrationId = registrationId; + Outcome = outcome; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// PNS type. + public string ApplicationPlatform { get; } + /// PNS handle. + public string PnsHandle { get; } + /// Registration id. + public string RegistrationId { get; } + /// Notification outcome. + public string Outcome { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.Serialization.cs new file mode 100644 index 000000000000..f91738a7195d --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class RemotePrivateLinkServiceConnectionState : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RemotePrivateLinkServiceConnectionState)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(ActionsRequired)) + { + writer.WritePropertyName("actionsRequired"u8); + writer.WriteStringValue(ActionsRequired); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RemotePrivateLinkServiceConnectionState IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RemotePrivateLinkServiceConnectionState)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRemotePrivateLinkServiceConnectionState(document.RootElement, options); + } + + internal static RemotePrivateLinkServiceConnectionState DeserializeRemotePrivateLinkServiceConnectionState(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PrivateLinkConnectionStatus? status = default; + string description = default; + string actionsRequired = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new PrivateLinkConnectionStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("actionsRequired"u8)) + { + actionsRequired = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RemotePrivateLinkServiceConnectionState(status, description, actionsRequired, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(RemotePrivateLinkServiceConnectionState)} does not support writing '{options.Format}' format."); + } + } + + RemotePrivateLinkServiceConnectionState IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRemotePrivateLinkServiceConnectionState(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RemotePrivateLinkServiceConnectionState)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.cs new file mode 100644 index 000000000000..f817d032cd58 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/RemotePrivateLinkServiceConnectionState.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// State of the Private Link Service connection. + public partial class RemotePrivateLinkServiceConnectionState + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public RemotePrivateLinkServiceConnectionState() + { + } + + /// Initializes a new instance of . + /// State of Private Link Connection. + /// Human-friendly description. + /// Human-friendly description of required actions. + /// Keeps track of any properties unknown to the library. + internal RemotePrivateLinkServiceConnectionState(PrivateLinkConnectionStatus? status, string description, string actionsRequired, IDictionary serializedAdditionalRawData) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// State of Private Link Connection. + public PrivateLinkConnectionStatus? Status { get; set; } + /// Human-friendly description. + public string Description { get; } + /// Human-friendly description of required actions. + public string ActionsRequired { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ReplicationRegion.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ReplicationRegion.cs new file mode 100644 index 000000000000..a567ff7615ca --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ReplicationRegion.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Allowed replication region. + public readonly partial struct ReplicationRegion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ReplicationRegion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DefaultValue = "Default"; + private const string WestUs2Value = "WestUs2"; + private const string NorthEuropeValue = "NorthEurope"; + private const string AustraliaEastValue = "AustraliaEast"; + private const string BrazilSouthValue = "BrazilSouth"; + private const string SouthEastAsiaValue = "SouthEastAsia"; + private const string SouthAfricaNorthValue = "SouthAfricaNorth"; + private const string NoneValue = "None"; + + /// Default. + public static ReplicationRegion Default { get; } = new ReplicationRegion(DefaultValue); + /// WestUs2. + public static ReplicationRegion WestUs2 { get; } = new ReplicationRegion(WestUs2Value); + /// NorthEurope. + public static ReplicationRegion NorthEurope { get; } = new ReplicationRegion(NorthEuropeValue); + /// AustraliaEast. + public static ReplicationRegion AustraliaEast { get; } = new ReplicationRegion(AustraliaEastValue); + /// BrazilSouth. + public static ReplicationRegion BrazilSouth { get; } = new ReplicationRegion(BrazilSouthValue); + /// SouthEastAsia. + public static ReplicationRegion SouthEastAsia { get; } = new ReplicationRegion(SouthEastAsiaValue); + /// SouthAfricaNorth. + public static ReplicationRegion SouthAfricaNorth { get; } = new ReplicationRegion(SouthAfricaNorthValue); + /// None. + public static ReplicationRegion None { get; } = new ReplicationRegion(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(ReplicationRegion left, ReplicationRegion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ReplicationRegion left, ReplicationRegion right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ReplicationRegion(string value) => new ReplicationRegion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReplicationRegion other && Equals(other); + /// + public bool Equals(ReplicationRegion other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.Serialization.cs new file mode 100644 index 000000000000..2b189320160a --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class ResourceListKeys : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceListKeys)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(PrimaryConnectionString)) + { + writer.WritePropertyName("primaryConnectionString"u8); + writer.WriteStringValue(PrimaryConnectionString); + } + if (options.Format != "W" && Optional.IsDefined(SecondaryConnectionString)) + { + writer.WritePropertyName("secondaryConnectionString"u8); + writer.WriteStringValue(SecondaryConnectionString); + } + if (options.Format != "W" && Optional.IsDefined(PrimaryKey)) + { + writer.WritePropertyName("primaryKey"u8); + writer.WriteStringValue(PrimaryKey); + } + if (options.Format != "W" && Optional.IsDefined(SecondaryKey)) + { + writer.WritePropertyName("secondaryKey"u8); + writer.WriteStringValue(SecondaryKey); + } + if (options.Format != "W" && Optional.IsDefined(KeyName)) + { + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResourceListKeys IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceListKeys)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceListKeys(document.RootElement, options); + } + + internal static ResourceListKeys DeserializeResourceListKeys(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string primaryConnectionString = default; + string secondaryConnectionString = default; + string primaryKey = default; + string secondaryKey = default; + string keyName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("primaryConnectionString"u8)) + { + primaryConnectionString = property.Value.GetString(); + continue; + } + if (property.NameEquals("secondaryConnectionString"u8)) + { + secondaryConnectionString = property.Value.GetString(); + continue; + } + if (property.NameEquals("primaryKey"u8)) + { + primaryKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("secondaryKey"u8)) + { + secondaryKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyName"u8)) + { + keyName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceListKeys( + primaryConnectionString, + secondaryConnectionString, + primaryKey, + secondaryKey, + keyName, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(ResourceListKeys)} does not support writing '{options.Format}' format."); + } + } + + ResourceListKeys IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeResourceListKeys(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceListKeys)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.cs new file mode 100644 index 000000000000..02f8b4f7775c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ResourceListKeys.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Response for the POST request that returns Namespace or NotificationHub access keys (connection strings). + public partial class ResourceListKeys + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ResourceListKeys() + { + } + + /// Initializes a new instance of . + /// Gets or sets primaryConnectionString of the AuthorizationRule. + /// + /// Gets or sets secondaryConnectionString of the created + /// AuthorizationRule + /// + /// Gets or sets primaryKey of the created AuthorizationRule. + /// Gets or sets secondaryKey of the created AuthorizationRule. + /// Gets or sets keyName of the created AuthorizationRule. + /// Keeps track of any properties unknown to the library. + internal ResourceListKeys(string primaryConnectionString, string secondaryConnectionString, string primaryKey, string secondaryKey, string keyName, IDictionary serializedAdditionalRawData) + { + PrimaryConnectionString = primaryConnectionString; + SecondaryConnectionString = secondaryConnectionString; + PrimaryKey = primaryKey; + SecondaryKey = secondaryKey; + KeyName = keyName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets primaryConnectionString of the AuthorizationRule. + public string PrimaryConnectionString { get; } + /// + /// Gets or sets secondaryConnectionString of the created + /// AuthorizationRule + /// + public string SecondaryConnectionString { get; } + /// Gets or sets primaryKey of the created AuthorizationRule. + public string PrimaryKey { get; } + /// Gets or sets secondaryKey of the created AuthorizationRule. + public string SecondaryKey { get; } + /// Gets or sets keyName of the created AuthorizationRule. + public string KeyName { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.Serialization.cs new file mode 100644 index 000000000000..0ac50616f504 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.Serialization.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class ServiceSpecification : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ServiceSpecification)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(LogSpecifications)) + { + writer.WritePropertyName("logSpecifications"u8); + writer.WriteStartArray(); + foreach (var item in LogSpecifications) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(MetricSpecifications)) + { + writer.WritePropertyName("metricSpecifications"u8); + writer.WriteStartArray(); + foreach (var item in MetricSpecifications) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ServiceSpecification IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ServiceSpecification)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeServiceSpecification(document.RootElement, options); + } + + internal static ServiceSpecification DeserializeServiceSpecification(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList logSpecifications = default; + IReadOnlyList metricSpecifications = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logSpecifications"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LogSpecification.DeserializeLogSpecification(item, options)); + } + logSpecifications = array; + continue; + } + if (property.NameEquals("metricSpecifications"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricSpecification.DeserializeMetricSpecification(item, options)); + } + metricSpecifications = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ServiceSpecification(logSpecifications ?? new ChangeTrackingList(), metricSpecifications ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(ServiceSpecification)} does not support writing '{options.Format}' format."); + } + } + + ServiceSpecification IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeServiceSpecification(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ServiceSpecification)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.cs new file mode 100644 index 000000000000..0896b3b8d619 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ServiceSpecification.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Optional service specification used in Operations API. + public partial class ServiceSpecification + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ServiceSpecification() + { + LogSpecifications = new ChangeTrackingList(); + MetricSpecifications = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Log specifications. + /// Metric specification. + /// Keeps track of any properties unknown to the library. + internal ServiceSpecification(IReadOnlyList logSpecifications, IReadOnlyList metricSpecifications, IDictionary serializedAdditionalRawData) + { + LogSpecifications = logSpecifications; + MetricSpecifications = metricSpecifications; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Log specifications. + public IReadOnlyList LogSpecifications { get; } + /// Metric specification. + public IReadOnlyList MetricSpecifications { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.Serialization.cs new file mode 100644 index 000000000000..c106f2206881 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + internal partial class SharedAccessAuthorizationRuleListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleListResult)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SharedAccessAuthorizationRuleListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement, options); + } + + internal static SharedAccessAuthorizationRuleListResult DeserializeSharedAccessAuthorizationRuleListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedAccessAuthorizationRuleListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleListResult)} does not support writing '{options.Format}' format."); + } + } + + SharedAccessAuthorizationRuleListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.cs new file mode 100644 index 000000000000..13591b0320d3 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleListResult.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Paged collection of SharedAccessAuthorizationRuleResource items. + internal partial class SharedAccessAuthorizationRuleListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The SharedAccessAuthorizationRuleResource items on this page. + internal SharedAccessAuthorizationRuleListResult(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The SharedAccessAuthorizationRuleResource items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal SharedAccessAuthorizationRuleListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SharedAccessAuthorizationRuleListResult() + { + } + + /// The SharedAccessAuthorizationRuleResource items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.Serialization.cs new file mode 100644 index 000000000000..c6b0e4ba1eb2 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.Serialization.cs @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class SharedAccessAuthorizationRuleProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("rights"u8); + writer.WriteStartArray(); + foreach (var item in Rights) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + if (Optional.IsDefined(PrimaryKey)) + { + writer.WritePropertyName("primaryKey"u8); + writer.WriteStringValue(PrimaryKey); + } + if (Optional.IsDefined(SecondaryKey)) + { + writer.WritePropertyName("secondaryKey"u8); + writer.WriteStringValue(SecondaryKey); + } + if (options.Format != "W" && Optional.IsDefined(KeyName)) + { + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedOn)) + { + writer.WritePropertyName("modifiedTime"u8); + writer.WriteStringValue(ModifiedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdTime"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ClaimType)) + { + writer.WritePropertyName("claimType"u8); + writer.WriteStringValue(ClaimType); + } + if (options.Format != "W" && Optional.IsDefined(ClaimValue)) + { + writer.WritePropertyName("claimValue"u8); + writer.WriteStringValue(ClaimValue); + } + if (options.Format != "W" && Optional.IsDefined(Revision)) + { + writer.WritePropertyName("revision"u8); + writer.WriteNumberValue(Revision.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SharedAccessAuthorizationRuleProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharedAccessAuthorizationRuleProperties(document.RootElement, options); + } + + internal static SharedAccessAuthorizationRuleProperties DeserializeSharedAccessAuthorizationRuleProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList rights = default; + string primaryKey = default; + string secondaryKey = default; + string keyName = default; + DateTimeOffset? modifiedTime = default; + DateTimeOffset? createdTime = default; + string claimType = default; + string claimValue = default; + int? revision = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rights"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AccessRight(item.GetString())); + } + rights = array; + continue; + } + if (property.NameEquals("primaryKey"u8)) + { + primaryKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("secondaryKey"u8)) + { + secondaryKey = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyName"u8)) + { + keyName = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("claimType"u8)) + { + claimType = property.Value.GetString(); + continue; + } + if (property.NameEquals("claimValue"u8)) + { + claimValue = property.Value.GetString(); + continue; + } + if (property.NameEquals("revision"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + revision = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedAccessAuthorizationRuleProperties( + rights, + primaryKey, + secondaryKey, + keyName, + modifiedTime, + createdTime, + claimType, + claimValue, + revision, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleProperties)} does not support writing '{options.Format}' format."); + } + } + + SharedAccessAuthorizationRuleProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharedAccessAuthorizationRuleProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.cs new file mode 100644 index 000000000000..0e45d14105db --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/SharedAccessAuthorizationRuleProperties.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// SharedAccessAuthorizationRule properties. + public partial class SharedAccessAuthorizationRuleProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Gets or sets the rights associated with the rule. + /// is null. + public SharedAccessAuthorizationRuleProperties(IEnumerable rights) + { + Argument.AssertNotNull(rights, nameof(rights)); + + Rights = rights.ToList(); + } + + /// Initializes a new instance of . + /// Gets or sets the rights associated with the rule. + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// Gets a string that describes the authorization rule. + /// Gets the last modified time for this rule. + /// Gets the created time for this rule. + /// Gets a string that describes the claim type. + /// Gets a string that describes the claim value. + /// Gets the revision number for the rule. + /// Keeps track of any properties unknown to the library. + internal SharedAccessAuthorizationRuleProperties(IList rights, string primaryKey, string secondaryKey, string keyName, DateTimeOffset? modifiedOn, DateTimeOffset? createdOn, string claimType, string claimValue, int? revision, IDictionary serializedAdditionalRawData) + { + Rights = rights; + PrimaryKey = primaryKey; + SecondaryKey = secondaryKey; + KeyName = keyName; + ModifiedOn = modifiedOn; + CreatedOn = createdOn; + ClaimType = claimType; + ClaimValue = claimValue; + Revision = revision; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SharedAccessAuthorizationRuleProperties() + { + } + + /// Gets or sets the rights associated with the rule. + public IList Rights { get; } + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + public string PrimaryKey { get; set; } + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + public string SecondaryKey { get; set; } + /// Gets a string that describes the authorization rule. + public string KeyName { get; } + /// Gets the last modified time for this rule. + public DateTimeOffset? ModifiedOn { get; } + /// Gets the created time for this rule. + public DateTimeOffset? CreatedOn { get; } + /// Gets a string that describes the claim type. + public string ClaimType { get; } + /// Gets a string that describes the claim value. + public string ClaimValue { get; } + /// Gets the revision number for the rule. + public int? Revision { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.Serialization.cs new file mode 100644 index 000000000000..78e1350f59f0 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class WnsCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WnsCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(PackageSid)) + { + writer.WritePropertyName("packageSid"u8); + writer.WriteStringValue(PackageSid); + } + if (Optional.IsDefined(SecretKey)) + { + writer.WritePropertyName("secretKey"u8); + writer.WriteStringValue(SecretKey); + } + if (Optional.IsDefined(WindowsLiveEndpoint)) + { + writer.WritePropertyName("windowsLiveEndpoint"u8); + writer.WriteStringValue(WindowsLiveEndpoint); + } + if (Optional.IsDefined(CertificateKey)) + { + writer.WritePropertyName("certificateKey"u8); + writer.WriteStringValue(CertificateKey); + } + if (Optional.IsDefined(WnsCertificate)) + { + writer.WritePropertyName("wnsCertificate"u8); + writer.WriteStringValue(WnsCertificate); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WnsCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WnsCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWnsCredential(document.RootElement, options); + } + + internal static WnsCredential DeserializeWnsCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string packageSid = default; + string secretKey = default; + string windowsLiveEndpoint = default; + string certificateKey = default; + string wnsCertificate = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("packageSid"u8)) + { + packageSid = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("secretKey"u8)) + { + secretKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("windowsLiveEndpoint"u8)) + { + windowsLiveEndpoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("certificateKey"u8)) + { + certificateKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("wnsCertificate"u8)) + { + wnsCertificate = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WnsCredential( + packageSid, + secretKey, + windowsLiveEndpoint, + certificateKey, + wnsCertificate, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(WnsCredential)} does not support writing '{options.Format}' format."); + } + } + + WnsCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWnsCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WnsCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.cs new file mode 100644 index 000000000000..8e67258d81f9 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/WnsCredential.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub WnsCredential. + public partial class WnsCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WnsCredential() + { + } + + /// Initializes a new instance of . + /// Gets or sets the package ID for this credential. + /// Gets or sets the secret key. + /// Gets or sets the Windows Live endpoint. + /// Ges or sets the WNS Certificate Key. + /// Gets or sets the WNS Certificate. + /// Keeps track of any properties unknown to the library. + internal WnsCredential(string packageSid, string secretKey, string windowsLiveEndpoint, string certificateKey, string wnsCertificate, IDictionary serializedAdditionalRawData) + { + PackageSid = packageSid; + SecretKey = secretKey; + WindowsLiveEndpoint = windowsLiveEndpoint; + CertificateKey = certificateKey; + WnsCertificate = wnsCertificate; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the package ID for this credential. + public string PackageSid { get; set; } + /// Gets or sets the secret key. + public string SecretKey { get; set; } + /// Gets or sets the Windows Live endpoint. + public string WindowsLiveEndpoint { get; set; } + /// Ges or sets the WNS Certificate Key. + public string CertificateKey { get; set; } + /// Gets or sets the WNS Certificate. + public string WnsCertificate { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.Serialization.cs new file mode 100644 index 000000000000..318fc9fd2a54 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + public partial class XiaomiCredential : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XiaomiCredential)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(AppSecret)) + { + writer.WritePropertyName("appSecret"u8); + writer.WriteStringValue(AppSecret); + } + if (Optional.IsDefined(Endpoint)) + { + writer.WritePropertyName("endpoint"u8); + writer.WriteStringValue(Endpoint); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + XiaomiCredential IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(XiaomiCredential)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeXiaomiCredential(document.RootElement, options); + } + + internal static XiaomiCredential DeserializeXiaomiCredential(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string appSecret = default; + string endpoint = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("appSecret"u8)) + { + appSecret = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("endpoint"u8)) + { + endpoint = property0.Value.GetString(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new XiaomiCredential(appSecret, endpoint, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(XiaomiCredential)} does not support writing '{options.Format}' format."); + } + } + + XiaomiCredential IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeXiaomiCredential(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(XiaomiCredential)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.cs new file mode 100644 index 000000000000..cb8b4c12a938 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/XiaomiCredential.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Notificationhubs.Models +{ + /// Description of a NotificationHub XiaomiCredential. + public partial class XiaomiCredential + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public XiaomiCredential() + { + } + + /// Initializes a new instance of . + /// Gets or sets app secret. + /// Gets or sets xiaomi service endpoint. + /// Keeps track of any properties unknown to the library. + internal XiaomiCredential(string appSecret, string endpoint, IDictionary serializedAdditionalRawData) + { + AppSecret = appSecret; + Endpoint = endpoint; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets app secret. + public string AppSecret { get; set; } + /// Gets or sets xiaomi service endpoint. + public string Endpoint { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ZoneRedundancyPreference.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ZoneRedundancyPreference.cs new file mode 100644 index 000000000000..3961e2d5153c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/Models/ZoneRedundancyPreference.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.Notificationhubs.Models +{ + /// Namespace SKU name. + public readonly partial struct ZoneRedundancyPreference : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ZoneRedundancyPreference(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DisabledValue = "Disabled"; + private const string EnabledValue = "Enabled"; + + /// Disabled. + public static ZoneRedundancyPreference Disabled { get; } = new ZoneRedundancyPreference(DisabledValue); + /// Enabled. + public static ZoneRedundancyPreference Enabled { get; } = new ZoneRedundancyPreference(EnabledValue); + /// Determines if two values are the same. + public static bool operator ==(ZoneRedundancyPreference left, ZoneRedundancyPreference right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ZoneRedundancyPreference left, ZoneRedundancyPreference right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ZoneRedundancyPreference(string value) => new ZoneRedundancyPreference(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ZoneRedundancyPreference other && Equals(other); + /// + public bool Equals(ZoneRedundancyPreference other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleCollection.cs new file mode 100644 index 000000000000..93ceb99822f0 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleCollection.cs @@ -0,0 +1,497 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetNamespaceAuthorizationRules method from an instance of . + /// + public partial class NamespaceAuthorizationRuleCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _namespaceAuthorizationRuleNamespacesClientDiagnostics; + private readonly NamespacesRestOperations _namespaceAuthorizationRuleNamespacesRestClient; + + /// Initializes a new instance of the class for mocking. + protected NamespaceAuthorizationRuleCollection() + { + } + + /// 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 NamespaceAuthorizationRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceAuthorizationRuleNamespacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NamespaceAuthorizationRuleResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NamespaceAuthorizationRuleResource.ResourceType, out string namespaceAuthorizationRuleNamespacesApiVersion); + _namespaceAuthorizationRuleNamespacesRestClient = new NamespacesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceAuthorizationRuleNamespacesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NamespaceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NamespaceResource.ResourceType), nameof(id)); + } + + /// + /// Creates an authorization rule for a namespace + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// 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 authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.CreateOrUpdateAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, data, cancellationToken).ConfigureAwait(false); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates an authorization rule for a namespace + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// 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 authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.CreateOrUpdateAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, data, cancellationToken); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.Get"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.Get"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the authorization rules for a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_ListAuthorizationRules + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceAuthorizationRuleNamespacesRestClient.CreateListAuthorizationRulesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceAuthorizationRuleNamespacesRestClient.CreateListAuthorizationRulesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NamespaceAuthorizationRuleResource(Client, SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(e)), _namespaceAuthorizationRuleNamespacesClientDiagnostics, Pipeline, "NamespaceAuthorizationRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the authorization rules for a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_ListAuthorizationRules + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceAuthorizationRuleNamespacesRestClient.CreateListAuthorizationRulesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceAuthorizationRuleNamespacesRestClient.CreateListAuthorizationRulesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NamespaceAuthorizationRuleResource(Client, SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(e)), _namespaceAuthorizationRuleNamespacesClientDiagnostics, Pipeline, "NamespaceAuthorizationRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.Exists"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, 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.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.Exists"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, authorizationRuleName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.Serialization.cs new file mode 100644 index 000000000000..2aaeb8cd1dfd --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NamespaceAuthorizationRuleResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + SharedAccessAuthorizationRuleResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + SharedAccessAuthorizationRuleResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.cs new file mode 100644 index 000000000000..3ad9999bc7bd --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceAuthorizationRuleResource.cs @@ -0,0 +1,853 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a NamespaceAuthorizationRule 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 GetNamespaceAuthorizationRuleResource method. + /// Otherwise you can get one from its parent resource using the GetNamespaceAuthorizationRule method. + /// + public partial class NamespaceAuthorizationRuleResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + /// The authorizationRuleName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _namespaceAuthorizationRuleNamespacesClientDiagnostics; + private readonly NamespacesRestOperations _namespaceAuthorizationRuleNamespacesRestClient; + private readonly SharedAccessAuthorizationRuleResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces/authorizationRules"; + + /// Initializes a new instance of the class for mocking. + protected NamespaceAuthorizationRuleResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NamespaceAuthorizationRuleResource(ArmClient client, SharedAccessAuthorizationRuleResourceData 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 NamespaceAuthorizationRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceAuthorizationRuleNamespacesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string namespaceAuthorizationRuleNamespacesApiVersion); + _namespaceAuthorizationRuleNamespacesRestClient = new NamespacesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceAuthorizationRuleNamespacesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual SharedAccessAuthorizationRuleResourceData 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 an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Get"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(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 NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Get"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a namespace authorization rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_DeleteAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Delete"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.DeleteAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateDeleteAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a namespace authorization rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_DeleteAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Delete"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.DeleteAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateDeleteAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates an authorization rule for a namespace + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Update"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.CreateOrUpdateAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates an authorization rule for a namespace + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.Update"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.CreateOrUpdateAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _namespaceAuthorizationRuleNamespacesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the Primary and Secondary ConnectionStrings to the namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys + /// + /// + /// Operation Id + /// Namespaces_ListKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetKeysAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.GetKeys"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.ListKeysAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the Primary and Secondary ConnectionStrings to the namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys + /// + /// + /// Operation Id + /// Namespaces_ListKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetKeys(CancellationToken cancellationToken = default) + { + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.GetKeys"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.ListKeys(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys + /// + /// + /// Operation Id + /// Namespaces_RegenerateKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> RegenerateKeysAsync(PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.RegenerateKeys"); + scope.Start(); + try + { + var response = await _namespaceAuthorizationRuleNamespacesRestClient.RegenerateKeysAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, policyKeyResource, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys + /// + /// + /// Operation Id + /// Namespaces_RegenerateKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual Response RegenerateKeys(PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.RegenerateKeys"); + scope.Start(); + try + { + var response = _namespaceAuthorizationRuleNamespacesRestClient.RegenerateKeys(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, policyKeyResource, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceAuthorizationRuleNamespacesClientDiagnostics.CreateScope("NamespaceAuthorizationRuleResource.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 = _namespaceAuthorizationRuleNamespacesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleCollection.cs new file mode 100644 index 000000000000..cf83c04d4901 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleCollection.cs @@ -0,0 +1,497 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetNamespaceNotificationHubAuthorizationRules method from an instance of . + /// + public partial class NamespaceNotificationHubAuthorizationRuleCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics; + private readonly SharedAccessAuthorizationRuleResourcesRestOperations _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient; + + /// Initializes a new instance of the class for mocking. + protected NamespaceNotificationHubAuthorizationRuleCollection() + { + } + + /// 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 NamespaceNotificationHubAuthorizationRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NamespaceNotificationHubAuthorizationRuleResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NamespaceNotificationHubAuthorizationRuleResource.ResourceType, out string namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesApiVersion); + _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient = new SharedAccessAuthorizationRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NotificationHubResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NotificationHubResource.ResourceType), nameof(id)); + } + + /// + /// Creates/Updates an authorization rule for a NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// 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 authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateOrUpdateAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, data, cancellationToken).ConfigureAwait(false); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates/Updates an authorization rule for a NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// 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 authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateOrUpdateAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, data, cancellationToken); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.Get"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.Get"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the authorization rules for a NotificationHub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_ListAuthorizationRules + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateListAuthorizationRulesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateListAuthorizationRulesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NamespaceNotificationHubAuthorizationRuleResource(Client, SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(e)), _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics, Pipeline, "NamespaceNotificationHubAuthorizationRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Gets the authorization rules for a NotificationHub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_ListAuthorizationRules + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateListAuthorizationRulesRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateListAuthorizationRulesNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NamespaceNotificationHubAuthorizationRuleResource(Client, SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(e)), _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics, Pipeline, "NamespaceNotificationHubAuthorizationRuleCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.Exists"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.Exists"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleCollection.GetIfExists"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, authorizationRuleName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.Serialization.cs new file mode 100644 index 000000000000..f2062bc3c19f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NamespaceNotificationHubAuthorizationRuleResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + SharedAccessAuthorizationRuleResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + SharedAccessAuthorizationRuleResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.cs new file mode 100644 index 000000000000..1517e6d58011 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceNotificationHubAuthorizationRuleResource.cs @@ -0,0 +1,854 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a NamespaceNotificationHubAuthorizationRule 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 GetNamespaceNotificationHubAuthorizationRuleResource method. + /// Otherwise you can get one from its parent resource using the GetNamespaceNotificationHubAuthorizationRule method. + /// + public partial class NamespaceNotificationHubAuthorizationRuleResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + /// The notificationHubName. + /// The authorizationRuleName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics; + private readonly SharedAccessAuthorizationRuleResourcesRestOperations _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient; + private readonly SharedAccessAuthorizationRuleResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces/notificationHubs/authorizationRules"; + + /// Initializes a new instance of the class for mocking. + protected NamespaceNotificationHubAuthorizationRuleResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NamespaceNotificationHubAuthorizationRuleResource(ArmClient client, SharedAccessAuthorizationRuleResourceData 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 NamespaceNotificationHubAuthorizationRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesApiVersion); + _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient = new SharedAccessAuthorizationRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual SharedAccessAuthorizationRuleResourceData 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 an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Get"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(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 NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Get"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(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 NamespaceNotificationHubAuthorizationRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a notificationHub authorization rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_DeleteAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Delete"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.DeleteAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateDeleteAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a notificationHub authorization rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_DeleteAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Delete"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.DeleteAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateDeleteAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates/Updates an authorization rule for a NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Update"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateOrUpdateAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates/Updates an authorization rule for a NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_CreateOrUpdateAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.Update"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateOrUpdateAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.CreateCreateOrUpdateAuthorizationRuleRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the Primary and Secondary ConnectionStrings to the NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/listKeys + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResources_ListKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetKeysAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.GetKeys"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.ListKeysAsync(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; + } + } + + /// + /// Gets the Primary and Secondary ConnectionStrings to the NotificationHub + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/listKeys + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResources_ListKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetKeys(CancellationToken cancellationToken = default) + { + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.GetKeys"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.ListKeys(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResources_RegenerateKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> RegenerateKeysAsync(PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.RegenerateKeys"); + scope.Start(); + try + { + var response = await _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.RegenerateKeysAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, policyKeyResource, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResources_RegenerateKeys + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual Response RegenerateKeys(PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.RegenerateKeys"); + scope.Start(); + try + { + var response = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.RegenerateKeys(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, policyKeyResource, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags[key] = value; + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRuleAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + current.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, current, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesClientDiagnostics.CreateScope("NamespaceNotificationHubAuthorizationRuleResource.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 = _namespaceNotificationHubAuthorizationRuleSharedAccessAuthorizationRuleResourcesRestClient.GetAuthorizationRule(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceNotificationHubAuthorizationRuleResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + current.Tags.Remove(key); + var result = Update(WaitUntil.Completed, current, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.Serialization.cs new file mode 100644 index 000000000000..c70884d8ea18 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NamespaceResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NamespaceResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + NamespaceResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.cs new file mode 100644 index 000000000000..34dedc11ef83 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResource.cs @@ -0,0 +1,1143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a NamespaceResource 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 GetNamespaceResource method. + /// Otherwise you can get one from its parent resource using the GetNamespaceResource method. + /// + public partial class NamespaceResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _namespaceResourceClientDiagnostics; + private readonly NamespaceResourcesRestOperations _namespaceResourceRestClient; + private readonly NamespaceResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces"; + + /// Initializes a new instance of the class for mocking. + protected NamespaceResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NamespaceResource(ArmClient client, NamespaceResourceData 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 NamespaceResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string namespaceResourceApiVersion); + _namespaceResourceRestClient = new NamespaceResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual NamespaceResourceData 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 NotificationHubResources in the NamespaceResource. + /// An object representing collection of NotificationHubResources and their operations over a NotificationHubResource. + public virtual NotificationHubResourceCollection GetNotificationHubResources() + { + return GetCachedClient(client => new NotificationHubResourceCollection(client, Id)); + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNotificationHubResourceAsync(string notificationHubName, CancellationToken cancellationToken = default) + { + return await GetNotificationHubResources().GetAsync(notificationHubName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNotificationHubResource(string notificationHubName, CancellationToken cancellationToken = default) + { + return GetNotificationHubResources().Get(notificationHubName, cancellationToken); + } + + /// Gets a collection of NamespaceAuthorizationRuleResources in the NamespaceResource. + /// An object representing collection of NamespaceAuthorizationRuleResources and their operations over a NamespaceAuthorizationRuleResource. + public virtual NamespaceAuthorizationRuleCollection GetNamespaceAuthorizationRules() + { + return GetCachedClient(client => new NamespaceAuthorizationRuleCollection(client, Id)); + } + + /// + /// Gets an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNamespaceAuthorizationRuleAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + return await GetNamespaceAuthorizationRules().GetAsync(authorizationRuleName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an authorization rule for a namespace by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNamespaceAuthorizationRule(string authorizationRuleName, CancellationToken cancellationToken = default) + { + return GetNamespaceAuthorizationRules().Get(authorizationRuleName, cancellationToken); + } + + /// Gets a collection of PrivateEndpointConnectionResources in the NamespaceResource. + /// An object representing collection of PrivateEndpointConnectionResources and their operations over a PrivateEndpointConnectionResource. + public virtual PrivateEndpointConnectionResourceCollection GetPrivateEndpointConnectionResources() + { + return GetCachedClient(client => new PrivateEndpointConnectionResourceCollection(client, Id)); + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetPrivateEndpointConnectionResourceAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + return await GetPrivateEndpointConnectionResources().GetAsync(privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetPrivateEndpointConnectionResource(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + return GetPrivateEndpointConnectionResources().Get(privateEndpointConnectionName, cancellationToken); + } + + /// Gets a collection of NotificationhubsPrivateLinkResourceDataResources in the NamespaceResource. + /// An object representing collection of NotificationhubsPrivateLinkResourceDataResources and their operations over a NotificationhubsPrivateLinkResourceDataResource. + public virtual NotificationhubsPrivateLinkResourceDataCollection GetAllNotificationhubsPrivateLinkResourceData() + { + return GetCachedClient(client => new NotificationhubsPrivateLinkResourceDataCollection(client, Id)); + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNotificationhubsPrivateLinkResourceDataAsync(string subResourceName, CancellationToken cancellationToken = default) + { + return await GetAllNotificationhubsPrivateLinkResourceData().GetAsync(subResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNotificationhubsPrivateLinkResourceData(string subResourceName, CancellationToken cancellationToken = default) + { + return GetAllNotificationhubsPrivateLinkResourceData().Get(subResourceName, cancellationToken); + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Get"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Get"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Delete"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _namespaceResourceRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Delete"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var uri = _namespaceResourceRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patches the existing namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(NamespaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Update"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patches the existing namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual Response Update(NamespaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.Update"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks the availability of the given notificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability + /// + /// + /// Operation Id + /// NamespaceResources_CheckNotificationHubAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> CheckNotificationHubAvailabilityAsync(CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.CheckNotificationHubAvailability"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.CheckNotificationHubAvailabilityAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks the availability of the given notificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability + /// + /// + /// Operation Id + /// NamespaceResources_CheckNotificationHubAvailability + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual Response CheckNotificationHubAvailability(CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.CheckNotificationHubAvailability"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.CheckNotificationHubAvailability(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the PNS credentials associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/pnsCredentials + /// + /// + /// Operation Id + /// NamespaceResources_GetPnsCredentials + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetPnsCredentialsAsync(CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.GetPnsCredentials"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.GetPnsCredentialsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the PNS credentials associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/pnsCredentials + /// + /// + /// Operation Id + /// NamespaceResources_GetPnsCredentials + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetPnsCredentials(CancellationToken cancellationToken = default) + { + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.GetPnsCredentials"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.GetPnsCredentials(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NamespaceResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NamespaceResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NamespaceResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NamespaceResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NamespaceResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResource.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 = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new NamespaceResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NamespaceResourcePatch(); + 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/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceCollection.cs new file mode 100644 index 000000000000..b6403ebcfc50 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceCollection.cs @@ -0,0 +1,498 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetNamespaceResources method from an instance of . + /// + public partial class NamespaceResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _namespaceResourceClientDiagnostics; + private readonly NamespaceResourcesRestOperations _namespaceResourceRestClient; + + /// Initializes a new instance of the class for mocking. + protected NamespaceResourceCollection() + { + } + + /// 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 NamespaceResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _namespaceResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NamespaceResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NamespaceResource.ResourceType, out string namespaceResourceApiVersion); + _namespaceResourceRestClient = new NamespaceResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, namespaceResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Creates / Updates a Notification Hub namespace. This operation is idempotent. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, data, cancellationToken).ConfigureAwait(false); + var operation = new NotificationhubsArmOperation(new NamespaceResourceOperationSource(Client), _namespaceResourceClientDiagnostics, Pipeline, _namespaceResourceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates / Updates a Notification Hub namespace. This operation is idempotent. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, data, cancellationToken); + var operation = new NotificationhubsArmOperation(new NamespaceResourceOperationSource(Client), _namespaceResourceClientDiagnostics, Pipeline, _namespaceResourceRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.Get"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns the given namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.Get"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the available namespaces within a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skipToken, top); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NamespaceResource(Client, NamespaceResourceData.DeserializeNamespaceResourceData(e)), _namespaceResourceClientDiagnostics, Pipeline, "NamespaceResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the available namespaces within a resource group. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces + /// + /// + /// Operation Id + /// NamespaceResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _namespaceResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _namespaceResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, skipToken, top); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NamespaceResource(Client, NamespaceResourceData.DeserializeNamespaceResourceData(e)), _namespaceResourceClientDiagnostics, Pipeline, "NamespaceResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, 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.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.Exists"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _namespaceResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName} + /// + /// + /// Operation Id + /// NamespaceResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Namespace name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var scope = _namespaceResourceClientDiagnostics.CreateScope("NamespaceResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _namespaceResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, namespaceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NamespaceResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.Serialization.cs new file mode 100644 index 000000000000..6294b22142b4 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.Serialization.cs @@ -0,0 +1,476 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NamespaceResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(Critical)) + { + writer.WritePropertyName("critical"u8); + writer.WriteBooleanValue(Critical.Value); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && Optional.IsDefined(Region)) + { + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + } + if (options.Format != "W" && Optional.IsDefined(MetricId)) + { + writer.WritePropertyName("metricId"u8); + writer.WriteStringValue(MetricId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedOn)) + { + writer.WritePropertyName("updatedAt"u8); + writer.WriteStringValue(UpdatedOn.Value, "O"); + } + if (Optional.IsDefined(NamespaceType)) + { + writer.WritePropertyName("namespaceType"u8); + writer.WriteStringValue(NamespaceType.Value.ToString()); + } + if (Optional.IsDefined(ReplicationRegion)) + { + writer.WritePropertyName("replicationRegion"u8); + writer.WriteStringValue(ReplicationRegion.Value.ToString()); + } + if (Optional.IsDefined(ZoneRedundancy)) + { + writer.WritePropertyName("zoneRedundancy"u8); + writer.WriteStringValue(ZoneRedundancy.Value.ToString()); + } + if (Optional.IsDefined(NetworkAcls)) + { + writer.WritePropertyName("networkAcls"u8); + writer.WriteObjectValue(NetworkAcls, options); + } + if (Optional.IsDefined(PnsCredentials)) + { + writer.WritePropertyName("pnsCredentials"u8); + writer.WriteObjectValue(PnsCredentials, options); + } + if (options.Format != "W" && Optional.IsDefined(ServiceBusEndpoint)) + { + writer.WritePropertyName("serviceBusEndpoint"u8); + writer.WriteStringValue(ServiceBusEndpoint); + } + if (options.Format != "W" && Optional.IsCollectionDefined(PrivateEndpointConnections)) + { + writer.WritePropertyName("privateEndpointConnections"u8); + writer.WriteStartArray(); + foreach (var item in PrivateEndpointConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ScaleUnit)) + { + writer.WritePropertyName("scaleUnit"u8); + writer.WriteStringValue(ScaleUnit); + } + if (Optional.IsDefined(DataCenter)) + { + writer.WritePropertyName("dataCenter"u8); + writer.WriteStringValue(DataCenter); + } + if (Optional.IsDefined(PublicNetworkAccess)) + { + writer.WritePropertyName("publicNetworkAccess"u8); + writer.WriteStringValue(PublicNetworkAccess.Value.ToString()); + } + writer.WriteEndObject(); + } + + NamespaceResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NamespaceResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNamespaceResourceData(document.RootElement, options); + } + + internal static NamespaceResourceData DeserializeNamespaceResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsSku sku = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + OperationProvisioningState? provisioningState = default; + NamespaceStatus? status = default; + bool? enabled = default; + bool? critical = default; + string subscriptionId = default; + string region = default; + string metricId = default; + DateTimeOffset? createdAt = default; + DateTimeOffset? updatedAt = default; + NamespaceType? namespaceType = default; + ReplicationRegion? replicationRegion = default; + ZoneRedundancyPreference? zoneRedundancy = default; + NetworkAcls networkAcls = default; + PnsCredentials pnsCredentials = default; + string serviceBusEndpoint = default; + IReadOnlyList privateEndpointConnections = default; + string scaleUnit = default; + string dataCenter = default; + PublicNetworkAccess? publicNetworkAccess = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sku"u8)) + { + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (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 OperationProvisioningState(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("status"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new NamespaceStatus(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("enabled"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("critical"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + critical = property0.Value.GetBoolean(); + continue; + } + if (property0.NameEquals("subscriptionId"u8)) + { + subscriptionId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("region"u8)) + { + region = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("metricId"u8)) + { + metricId = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("createdAt"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdAt = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("updatedAt"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedAt = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("namespaceType"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + namespaceType = new NamespaceType(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("replicationRegion"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + replicationRegion = new ReplicationRegion(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("zoneRedundancy"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + zoneRedundancy = new ZoneRedundancyPreference(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("networkAcls"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkAcls = NetworkAcls.DeserializeNetworkAcls(property0.Value, options); + continue; + } + if (property0.NameEquals("pnsCredentials"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pnsCredentials = PnsCredentials.DeserializePnsCredentials(property0.Value, options); + continue; + } + if (property0.NameEquals("serviceBusEndpoint"u8)) + { + serviceBusEndpoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("privateEndpointConnections"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(item, options)); + } + privateEndpointConnections = array; + continue; + } + if (property0.NameEquals("scaleUnit"u8)) + { + scaleUnit = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("dataCenter"u8)) + { + dataCenter = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("publicNetworkAccess"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NamespaceResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + sku, + provisioningState, + status, + enabled, + critical, + subscriptionId, + region, + metricId, + createdAt, + updatedAt, + namespaceType, + replicationRegion, + zoneRedundancy, + networkAcls, + pnsCredentials, + serviceBusEndpoint, + privateEndpointConnections ?? new ChangeTrackingList(), + scaleUnit, + dataCenter, + publicNetworkAccess, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NamespaceResourceData)} does not support writing '{options.Format}' format."); + } + } + + NamespaceResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNamespaceResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NamespaceResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.cs new file mode 100644 index 000000000000..6c5ff2a993bf --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NamespaceResourceData.cs @@ -0,0 +1,177 @@ +// 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.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A class representing the NamespaceResource data model. + /// Notification Hubs Namespace Resource. + /// + public partial class NamespaceResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + /// The Sku description for a namespace. + /// is null. + public NamespaceResourceData(AzureLocation location, NotificationhubsSku sku) : base(location) + { + Argument.AssertNotNull(sku, nameof(sku)); + + Sku = sku; + PrivateEndpointConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The Sku description for a namespace. + /// Defines values for OperationProvisioningState. + /// Namespace status. + /// Gets or sets whether or not the namespace is currently enabled. + /// Gets or sets whether or not the namespace is set as Critical. + /// Namespace subscription id. + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + /// Azure Insights Metrics id. + /// Time when the namespace was created. + /// Time when the namespace was updated. + /// Defines values for NamespaceType. + /// Allowed replication region. + /// Namespace SKU name. + /// A collection of network authorization rules. + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + /// Private Endpoint Connections for namespace. + /// Gets or sets scaleUnit where the namespace gets created. + /// Deprecated. + /// Type of public network access. + /// Keeps track of any properties unknown to the library. + internal NamespaceResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, NotificationhubsSku sku, OperationProvisioningState? provisioningState, NamespaceStatus? status, bool? enabled, bool? critical, string subscriptionId, string region, string metricId, DateTimeOffset? createdOn, DateTimeOffset? updatedOn, NamespaceType? namespaceType, ReplicationRegion? replicationRegion, ZoneRedundancyPreference? zoneRedundancy, NetworkAcls networkAcls, PnsCredentials pnsCredentials, string serviceBusEndpoint, IReadOnlyList privateEndpointConnections, string scaleUnit, string dataCenter, PublicNetworkAccess? publicNetworkAccess, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Sku = sku; + ProvisioningState = provisioningState; + Status = status; + Enabled = enabled; + Critical = critical; + SubscriptionId = subscriptionId; + Region = region; + MetricId = metricId; + CreatedOn = createdOn; + UpdatedOn = updatedOn; + NamespaceType = namespaceType; + ReplicationRegion = replicationRegion; + ZoneRedundancy = zoneRedundancy; + NetworkAcls = networkAcls; + PnsCredentials = pnsCredentials; + ServiceBusEndpoint = serviceBusEndpoint; + PrivateEndpointConnections = privateEndpointConnections; + ScaleUnit = scaleUnit; + DataCenter = dataCenter; + PublicNetworkAccess = publicNetworkAccess; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NamespaceResourceData() + { + } + + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; set; } + /// Defines values for OperationProvisioningState. + public OperationProvisioningState? ProvisioningState { get; set; } + /// Namespace status. + public NamespaceStatus? Status { get; set; } + /// Gets or sets whether or not the namespace is currently enabled. + public bool? Enabled { get; } + /// Gets or sets whether or not the namespace is set as Critical. + public bool? Critical { get; } + /// Namespace subscription id. + public string SubscriptionId { get; } + /// + /// Region. The value is always set to the same value as Namespace.Location, so we are deprecating + /// this property. + /// + public string Region { get; } + /// Azure Insights Metrics id. + public string MetricId { get; } + /// Time when the namespace was created. + public DateTimeOffset? CreatedOn { get; } + /// Time when the namespace was updated. + public DateTimeOffset? UpdatedOn { get; } + /// Defines values for NamespaceType. + public NamespaceType? NamespaceType { get; set; } + /// Allowed replication region. + public ReplicationRegion? ReplicationRegion { get; set; } + /// Namespace SKU name. + public ZoneRedundancyPreference? ZoneRedundancy { get; set; } + /// A collection of network authorization rules. + public NetworkAcls NetworkAcls { get; set; } + /// Collection of Notification Hub or Notification Hub Namespace PNS credentials. + public PnsCredentials PnsCredentials { get; set; } + /// + /// Gets or sets endpoint you can use to perform NotificationHub + /// operations. + /// + public string ServiceBusEndpoint { get; } + /// Private Endpoint Connections for namespace. + public IReadOnlyList PrivateEndpointConnections { get; } + /// Gets or sets scaleUnit where the namespace gets created. + public string ScaleUnit { get; set; } + /// Deprecated. + public string DataCenter { get; set; } + /// Type of public network access. + public PublicNetworkAccess? PublicNetworkAccess { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.Serialization.cs new file mode 100644 index 000000000000..cf56b2af436f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NotificationHubResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NotificationHubResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + NotificationHubResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.cs new file mode 100644 index 000000000000..7556b863c984 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResource.cs @@ -0,0 +1,924 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a NotificationHubResource 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 GetNotificationHubResource method. + /// Otherwise you can get one from its parent resource using the GetNotificationHubResource method. + /// + public partial class NotificationHubResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + /// The notificationHubName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _notificationHubResourceClientDiagnostics; + private readonly NotificationHubResourcesRestOperations _notificationHubResourceRestClient; + private readonly NotificationHubResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces/notificationHubs"; + + /// Initializes a new instance of the class for mocking. + protected NotificationHubResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NotificationHubResource(ArmClient client, NotificationHubResourceData 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 NotificationHubResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _notificationHubResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string notificationHubResourceApiVersion); + _notificationHubResourceRestClient = new NotificationHubResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, notificationHubResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual NotificationHubResourceData 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 NamespaceNotificationHubAuthorizationRuleResources in the NotificationHubResource. + /// An object representing collection of NamespaceNotificationHubAuthorizationRuleResources and their operations over a NamespaceNotificationHubAuthorizationRuleResource. + public virtual NamespaceNotificationHubAuthorizationRuleCollection GetNamespaceNotificationHubAuthorizationRules() + { + return GetCachedClient(client => new NamespaceNotificationHubAuthorizationRuleCollection(client, Id)); + } + + /// + /// Gets an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetNamespaceNotificationHubAuthorizationRuleAsync(string authorizationRuleName, CancellationToken cancellationToken = default) + { + return await GetNamespaceNotificationHubAuthorizationRules().GetAsync(authorizationRuleName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets an authorization rule for a NotificationHub by name. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName} + /// + /// + /// Operation Id + /// SharedAccessAuthorizationRuleResource_GetAuthorizationRule + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetNamespaceNotificationHubAuthorizationRule(string authorizationRuleName, CancellationToken cancellationToken = default) + { + return GetNamespaceNotificationHubAuthorizationRules().Get(authorizationRuleName, cancellationToken); + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Get"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.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 NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Get"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a notification hub associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Delete"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _notificationHubResourceRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes a notification hub associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Delete"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _notificationHubResourceRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch a NotificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(NotificationHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Update"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Patch a NotificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Request content. + /// The cancellation token to use. + /// is null. + public virtual Response Update(NotificationHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.Update"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Test send a push notification. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend + /// + /// + /// Operation Id + /// NotificationHubResources_DebugSend + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> DebugSendAsync(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.DebugSend"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.DebugSendAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Test send a push notification. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend + /// + /// + /// Operation Id + /// NotificationHubResources_DebugSend + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response DebugSend(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.DebugSend"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.DebugSend(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the PNS Credentials associated with a notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials + /// + /// + /// Operation Id + /// NotificationHubResources_GetPnsCredentials + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetPnsCredentialsAsync(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.GetPnsCredentials"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.GetPnsCredentialsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the PNS Credentials associated with a notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials + /// + /// + /// Operation Id + /// NotificationHubResources_GetPnsCredentials + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response GetPnsCredentials(CancellationToken cancellationToken = default) + { + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.GetPnsCredentials"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.GetPnsCredentials(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResource.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 = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + return Response.FromValue(new NotificationHubResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new NotificationHubResourcePatch(); + 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/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceCollection.cs new file mode 100644 index 000000000000..d183c347f2e7 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceCollection.cs @@ -0,0 +1,501 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetNotificationHubResources method from an instance of . + /// + public partial class NotificationHubResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _notificationHubResourceClientDiagnostics; + private readonly NotificationHubResourcesRestOperations _notificationHubResourceRestClient; + + /// Initializes a new instance of the class for mocking. + protected NotificationHubResourceCollection() + { + } + + /// 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 NotificationHubResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _notificationHubResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NotificationHubResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NotificationHubResource.ResourceType, out string notificationHubResourceApiVersion); + _notificationHubResourceRestClient = new NotificationHubResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, notificationHubResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NamespaceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NamespaceResource.ResourceType), nameof(id)); + } + + /// + /// Creates/Update a NotificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Notification Hub name. + /// Request content. + /// 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 notificationHubName, NotificationHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, data, cancellationToken).ConfigureAwait(false); + var uri = _notificationHubResourceRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NotificationHubResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Creates/Update a NotificationHub in a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Notification Hub name. + /// Request content. + /// 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 notificationHubName, NotificationHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, data, cancellationToken); + var uri = _notificationHubResourceRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, data); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new NotificationhubsArmOperation(Response.FromValue(new NotificationHubResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub 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 notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.Get"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets the notification hub. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.Get"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Lists the notification hubs associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs + /// + /// + /// Operation Id + /// NotificationHubResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _notificationHubResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _notificationHubResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, top); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NotificationHubResource(Client, NotificationHubResourceData.DeserializeNotificationHubResourceData(e)), _notificationHubResourceClientDiagnostics, Pipeline, "NotificationHubResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Lists the notification hubs associated with a namespace. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs + /// + /// + /// Operation Id + /// NotificationHubResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _notificationHubResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, top); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _notificationHubResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, top); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NotificationHubResource(Client, NotificationHubResourceData.DeserializeNotificationHubResourceData(e)), _notificationHubResourceClientDiagnostics, Pipeline, "NotificationHubResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub 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 notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, 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.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.Exists"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _notificationHubResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName} + /// + /// + /// Operation Id + /// NotificationHubResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Notification Hub name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var scope = _notificationHubResourceClientDiagnostics.CreateScope("NotificationHubResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _notificationHubResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, notificationHubName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NotificationHubResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.Serialization.cs new file mode 100644 index 000000000000..ba51148b0a13 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.Serialization.cs @@ -0,0 +1,391 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NotificationHubResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(RegistrationTtl)) + { + writer.WritePropertyName("registrationTtl"u8); + writer.WriteStringValue(RegistrationTtl); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AuthorizationRules)) + { + writer.WritePropertyName("authorizationRules"u8); + writer.WriteStartArray(); + foreach (var item in AuthorizationRules) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ApnsCredential)) + { + writer.WritePropertyName("apnsCredential"u8); + writer.WriteObjectValue(ApnsCredential, options); + } + if (Optional.IsDefined(WnsCredential)) + { + writer.WritePropertyName("wnsCredential"u8); + writer.WriteObjectValue(WnsCredential, options); + } + if (Optional.IsDefined(GcmCredential)) + { + writer.WritePropertyName("gcmCredential"u8); + writer.WriteObjectValue(GcmCredential, options); + } + if (Optional.IsDefined(MpnsCredential)) + { + writer.WritePropertyName("mpnsCredential"u8); + writer.WriteObjectValue(MpnsCredential, options); + } + if (Optional.IsDefined(AdmCredential)) + { + writer.WritePropertyName("admCredential"u8); + writer.WriteObjectValue(AdmCredential, options); + } + if (Optional.IsDefined(BaiduCredential)) + { + writer.WritePropertyName("baiduCredential"u8); + writer.WriteObjectValue(BaiduCredential, options); + } + if (Optional.IsDefined(BrowserCredential)) + { + writer.WritePropertyName("browserCredential"u8); + writer.WriteObjectValue(BrowserCredential, options); + } + if (Optional.IsDefined(XiaomiCredential)) + { + writer.WritePropertyName("xiaomiCredential"u8); + writer.WriteObjectValue(XiaomiCredential, options); + } + if (Optional.IsDefined(FcmV1Credential)) + { + writer.WritePropertyName("fcmV1Credential"u8); + writer.WriteObjectValue(FcmV1Credential, options); + } + if (options.Format != "W" && Optional.IsDefined(DailyMaxActiveDevices)) + { + writer.WritePropertyName("dailyMaxActiveDevices"u8); + writer.WriteNumberValue(DailyMaxActiveDevices.Value); + } + writer.WriteEndObject(); + } + + NotificationHubResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationHubResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationHubResourceData(document.RootElement, options); + } + + internal static NotificationHubResourceData DeserializeNotificationHubResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsSku sku = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + string registrationTtl = default; + IReadOnlyList authorizationRules = default; + ApnsCredential apnsCredential = default; + WnsCredential wnsCredential = default; + GcmCredential gcmCredential = default; + MpnsCredential mpnsCredential = default; + AdmCredential admCredential = default; + BaiduCredential baiduCredential = default; + BrowserCredential browserCredential = default; + XiaomiCredential xiaomiCredential = default; + FcmV1Credential fcmV1Credential = default; + long? dailyMaxActiveDevices = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = NotificationhubsSku.DeserializeNotificationhubsSku(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (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("registrationTtl"u8)) + { + registrationTtl = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("authorizationRules"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(SharedAccessAuthorizationRuleProperties.DeserializeSharedAccessAuthorizationRuleProperties(item, options)); + } + authorizationRules = array; + continue; + } + if (property0.NameEquals("apnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + apnsCredential = ApnsCredential.DeserializeApnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("wnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wnsCredential = WnsCredential.DeserializeWnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("gcmCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gcmCredential = GcmCredential.DeserializeGcmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("mpnsCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mpnsCredential = MpnsCredential.DeserializeMpnsCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("admCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + admCredential = AdmCredential.DeserializeAdmCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("baiduCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baiduCredential = BaiduCredential.DeserializeBaiduCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("browserCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + browserCredential = BrowserCredential.DeserializeBrowserCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("xiaomiCredential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + xiaomiCredential = XiaomiCredential.DeserializeXiaomiCredential(property0.Value, options); + continue; + } + if (property0.NameEquals("fcmV1Credential"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fcmV1Credential = FcmV1Credential.DeserializeFcmV1Credential(property0.Value, options); + continue; + } + if (property0.NameEquals("dailyMaxActiveDevices"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dailyMaxActiveDevices = property0.Value.GetInt64(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationHubResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + registrationTtl, + authorizationRules ?? new ChangeTrackingList(), + apnsCredential, + wnsCredential, + gcmCredential, + mpnsCredential, + admCredential, + baiduCredential, + browserCredential, + xiaomiCredential, + fcmV1Credential, + dailyMaxActiveDevices, + sku, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationHubResourceData)} does not support writing '{options.Format}' format."); + } + } + + NotificationHubResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationHubResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationHubResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.cs new file mode 100644 index 000000000000..20fe5ee4e61b --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationHubResourceData.cs @@ -0,0 +1,132 @@ +// 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.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A class representing the NotificationHubResource data model. + /// Notification Hub Resource. + /// + public partial class NotificationHubResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public NotificationHubResourceData(AzureLocation location) : base(location) + { + AuthorizationRules = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Gets or sets the RegistrationTtl of the created NotificationHub. + /// Gets or sets the AuthorizationRules of the created NotificationHub. + /// Description of a NotificationHub ApnsCredential. + /// Description of a NotificationHub WnsCredential. + /// Description of a NotificationHub GcmCredential. + /// Description of a NotificationHub MpnsCredential. + /// Description of a NotificationHub AdmCredential. + /// Description of a NotificationHub BaiduCredential. + /// Description of a NotificationHub BrowserCredential. + /// Description of a NotificationHub XiaomiCredential. + /// Description of a NotificationHub FcmV1Credential. + /// + /// The Sku description for a namespace. + /// Keeps track of any properties unknown to the library. + internal NotificationHubResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, string registrationTtl, IReadOnlyList authorizationRules, ApnsCredential apnsCredential, WnsCredential wnsCredential, GcmCredential gcmCredential, MpnsCredential mpnsCredential, AdmCredential admCredential, BaiduCredential baiduCredential, BrowserCredential browserCredential, XiaomiCredential xiaomiCredential, FcmV1Credential fcmV1Credential, long? dailyMaxActiveDevices, NotificationhubsSku sku, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + RegistrationTtl = registrationTtl; + AuthorizationRules = authorizationRules; + ApnsCredential = apnsCredential; + WnsCredential = wnsCredential; + GcmCredential = gcmCredential; + MpnsCredential = mpnsCredential; + AdmCredential = admCredential; + BaiduCredential = baiduCredential; + BrowserCredential = browserCredential; + XiaomiCredential = xiaomiCredential; + FcmV1Credential = fcmV1Credential; + DailyMaxActiveDevices = dailyMaxActiveDevices; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal NotificationHubResourceData() + { + } + + /// Gets or sets the RegistrationTtl of the created NotificationHub. + public string RegistrationTtl { get; set; } + /// Gets or sets the AuthorizationRules of the created NotificationHub. + public IReadOnlyList AuthorizationRules { get; } + /// Description of a NotificationHub ApnsCredential. + public ApnsCredential ApnsCredential { get; set; } + /// Description of a NotificationHub WnsCredential. + public WnsCredential WnsCredential { get; set; } + /// Description of a NotificationHub GcmCredential. + public GcmCredential GcmCredential { get; set; } + /// Description of a NotificationHub MpnsCredential. + public MpnsCredential MpnsCredential { get; set; } + /// Description of a NotificationHub AdmCredential. + public AdmCredential AdmCredential { get; set; } + /// Description of a NotificationHub BaiduCredential. + public BaiduCredential BaiduCredential { get; set; } + /// Description of a NotificationHub BrowserCredential. + public BrowserCredential BrowserCredential { get; set; } + /// Description of a NotificationHub XiaomiCredential. + public XiaomiCredential XiaomiCredential { get; set; } + /// Description of a NotificationHub FcmV1Credential. + public FcmV1Credential FcmV1Credential { get; set; } + /// Gets the daily max active devices. + public long? DailyMaxActiveDevices { get; } + /// The Sku description for a namespace. + public NotificationhubsSku Sku { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataCollection.cs new file mode 100644 index 000000000000..a2afbd6e22eb --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataCollection.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetNotificationhubsPrivateLinkResourceData method from an instance of . + /// + public partial class NotificationhubsPrivateLinkResourceDataCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics; + private readonly PrivateLinkResourcesRestOperations _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient; + + /// Initializes a new instance of the class for mocking. + protected NotificationhubsPrivateLinkResourceDataCollection() + { + } + + /// 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 NotificationhubsPrivateLinkResourceDataCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", NotificationhubsPrivateLinkResourceDataResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(NotificationhubsPrivateLinkResourceDataResource.ResourceType, out string notificationhubsPrivateLinkResourceDataPrivateLinkResourcesApiVersion); + _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient = new PrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, notificationhubsPrivateLinkResourceDataPrivateLinkResourcesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NamespaceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NamespaceResource.ResourceType), nameof(id)); + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.Get"); + scope.Start(); + try + { + var response = await _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupIdAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.Get"); + scope.Start(); + try + { + var response = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupId(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources + /// + /// + /// Operation Id + /// PrivateLinkResource_ListGroupIds + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.CreateListGroupIdsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.CreateListGroupIdsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new NotificationhubsPrivateLinkResourceDataResource(Client, NotificationhubsPrivateLinkResourceDataData.DeserializeNotificationhubsPrivateLinkResourceDataData(e)), _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics, Pipeline, "NotificationhubsPrivateLinkResourceDataCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources + /// + /// + /// Operation Id + /// PrivateLinkResource_ListGroupIds + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.CreateListGroupIdsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.CreateListGroupIdsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new NotificationhubsPrivateLinkResourceDataResource(Client, NotificationhubsPrivateLinkResourceDataData.DeserializeNotificationhubsPrivateLinkResourceDataData(e)), _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics, Pipeline, "NotificationhubsPrivateLinkResourceDataCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.Exists"); + scope.Start(); + try + { + var response = await _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupIdAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, 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.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.Exists"); + scope.Start(); + try + { + var response = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupId(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupIdAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataCollection.GetIfExists"); + scope.Start(); + try + { + var response = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupId(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, subResourceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.Serialization.cs new file mode 100644 index 000000000000..174c4ef70ea6 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NotificationhubsPrivateLinkResourceDataData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceDataData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + NotificationhubsPrivateLinkResourceDataData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceDataData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNotificationhubsPrivateLinkResourceDataData(document.RootElement, options); + } + + internal static NotificationhubsPrivateLinkResourceDataData DeserializeNotificationhubsPrivateLinkResourceDataData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + NotificationhubsPrivateLinkResourceProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = NotificationhubsPrivateLinkResourceProperties.DeserializeNotificationhubsPrivateLinkResourceProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NotificationhubsPrivateLinkResourceDataData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceDataData)} does not support writing '{options.Format}' format."); + } + } + + NotificationhubsPrivateLinkResourceDataData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNotificationhubsPrivateLinkResourceDataData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NotificationhubsPrivateLinkResourceDataData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.cs new file mode 100644 index 000000000000..000843217c6c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A class representing the NotificationhubsPrivateLinkResourceData data model. + /// A Private Link Arm Resource. + /// + public partial class NotificationhubsPrivateLinkResourceDataData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NotificationhubsPrivateLinkResourceDataData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Represents properties of Private Link Resource. + /// Keeps track of any properties unknown to the library. + internal NotificationhubsPrivateLinkResourceDataData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, NotificationhubsPrivateLinkResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Represents properties of Private Link Resource. + public NotificationhubsPrivateLinkResourceProperties Properties { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.Serialization.cs new file mode 100644 index 000000000000..8bf67149fe68 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class NotificationhubsPrivateLinkResourceDataResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + NotificationhubsPrivateLinkResourceDataData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + NotificationhubsPrivateLinkResourceDataData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.cs new file mode 100644 index 000000000000..e3e7540ffaba --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/NotificationhubsPrivateLinkResourceDataResource.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a NotificationhubsPrivateLinkResourceData 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 GetNotificationhubsPrivateLinkResourceDataResource method. + /// Otherwise you can get one from its parent resource using the GetNotificationhubsPrivateLinkResourceData method. + /// + public partial class NotificationhubsPrivateLinkResourceDataResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + /// The subResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName, string subResourceName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics; + private readonly PrivateLinkResourcesRestOperations _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient; + private readonly NotificationhubsPrivateLinkResourceDataData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces/privateLinkResources"; + + /// Initializes a new instance of the class for mocking. + protected NotificationhubsPrivateLinkResourceDataResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal NotificationhubsPrivateLinkResourceDataResource(ArmClient client, NotificationhubsPrivateLinkResourceDataData 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 NotificationhubsPrivateLinkResourceDataResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string notificationhubsPrivateLinkResourceDataPrivateLinkResourcesApiVersion); + _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient = new PrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, notificationhubsPrivateLinkResourceDataPrivateLinkResourcesApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual NotificationhubsPrivateLinkResourceDataData 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)); + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataResource.Get"); + scope.Start(); + try + { + var response = await _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupIdAsync(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 NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName} + /// + /// + /// Operation Id + /// PrivateLinkResource_GetGroupId + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesClientDiagnostics.CreateScope("NotificationhubsPrivateLinkResourceDataResource.Get"); + scope.Start(); + try + { + var response = _notificationhubsPrivateLinkResourceDataPrivateLinkResourcesRestClient.GetGroupId(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new NotificationhubsPrivateLinkResourceDataResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.Serialization.cs new file mode 100644 index 000000000000..d46d05908ee6 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class PrivateEndpointConnectionResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + PrivateEndpointConnectionResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerNotificationhubsContext.Default); + + PrivateEndpointConnectionResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerNotificationhubsContext.Default); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.cs new file mode 100644 index 000000000000..35347c11750c --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResource.cs @@ -0,0 +1,353 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A Class representing a PrivateEndpointConnectionResource 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 GetPrivateEndpointConnectionResource method. + /// Otherwise you can get one from its parent resource using the GetPrivateEndpointConnectionResource method. + /// + public partial class PrivateEndpointConnectionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The namespaceName. + /// The privateEndpointConnectionName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _privateEndpointConnectionResourceClientDiagnostics; + private readonly PrivateEndpointConnectionResourcesRestOperations _privateEndpointConnectionResourceRestClient; + private readonly PrivateEndpointConnectionResourceData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.NotificationHubs/namespaces/privateEndpointConnections"; + + /// Initializes a new instance of the class for mocking. + protected PrivateEndpointConnectionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal PrivateEndpointConnectionResource(ArmClient client, PrivateEndpointConnectionResourceData 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 PrivateEndpointConnectionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _privateEndpointConnectionResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string privateEndpointConnectionResourceApiVersion); + _privateEndpointConnectionResourceRestClient = new PrivateEndpointConnectionResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, privateEndpointConnectionResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual PrivateEndpointConnectionResourceData 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)); + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.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 PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Get"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new NotificationhubsArmOperation(_privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Deletes the Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Delete + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Delete"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new NotificationhubsArmOperation(_privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Description of the Private Endpoint Connection resource. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new NotificationhubsArmOperation(new PrivateEndpointConnectionResourceOperationSource(Client), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateUpdateRequest(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; + } + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Description of the Private Endpoint Connection resource. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResource.Update"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new NotificationhubsArmOperation(new PrivateEndpointConnectionResourceOperationSource(Client), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateUpdateRequest(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/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceCollection.cs new file mode 100644 index 000000000000..02724c295bd0 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceCollection.cs @@ -0,0 +1,499 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// 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 GetPrivateEndpointConnectionResources method from an instance of . + /// + public partial class PrivateEndpointConnectionResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _privateEndpointConnectionResourceClientDiagnostics; + private readonly PrivateEndpointConnectionResourcesRestOperations _privateEndpointConnectionResourceRestClient; + + /// Initializes a new instance of the class for mocking. + protected PrivateEndpointConnectionResourceCollection() + { + } + + /// 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 PrivateEndpointConnectionResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _privateEndpointConnectionResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Notificationhubs", PrivateEndpointConnectionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(PrivateEndpointConnectionResource.ResourceType, out string privateEndpointConnectionResourceApiVersion); + _privateEndpointConnectionResourceRestClient = new PrivateEndpointConnectionResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, privateEndpointConnectionResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != NamespaceResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, NamespaceResource.ResourceType), nameof(id)); + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Private Endpoint Connection Name. + /// Description of the Private Endpoint Connection resource. + /// 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 privateEndpointConnectionName, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken).ConfigureAwait(false); + var operation = new NotificationhubsArmOperation(new PrivateEndpointConnectionResourceOperationSource(Client), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Update + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Private Endpoint Connection Name. + /// Description of the Private Endpoint Connection resource. + /// 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 privateEndpointConnectionName, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data, cancellationToken); + var operation = new NotificationhubsArmOperation(new PrivateEndpointConnectionResourceOperationSource(Client), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, _privateEndpointConnectionResourceRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.Get"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.Get"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _privateEndpointConnectionResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _privateEndpointConnectionResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new PrivateEndpointConnectionResource(Client, PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(e)), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, "PrivateEndpointConnectionResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_List + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _privateEndpointConnectionResourceRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _privateEndpointConnectionResourceRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new PrivateEndpointConnectionResource(Client, PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(e)), _privateEndpointConnectionResourceClientDiagnostics, Pipeline, "PrivateEndpointConnectionResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection 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 privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, 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.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.Exists"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _privateEndpointConnectionResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName} + /// + /// + /// Operation Id + /// PrivateEndpointConnectionResource_Get + /// + /// + /// Default Api Version + /// 2023-10-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Private Endpoint Connection Name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var scope = _privateEndpointConnectionResourceClientDiagnostics.CreateScope("PrivateEndpointConnectionResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _privateEndpointConnectionResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, privateEndpointConnectionName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new PrivateEndpointConnectionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.Serialization.cs new file mode 100644 index 000000000000..eed3142df21f --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class PrivateEndpointConnectionResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + PrivateEndpointConnectionResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrivateEndpointConnectionResourceData(document.RootElement, options); + } + + internal static PrivateEndpointConnectionResourceData DeserializePrivateEndpointConnectionResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PrivateEndpointConnectionProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = PrivateEndpointConnectionProperties.DeserializePrivateEndpointConnectionProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PrivateEndpointConnectionResourceData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceData)} does not support writing '{options.Format}' format."); + } + } + + PrivateEndpointConnectionResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePrivateEndpointConnectionResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PrivateEndpointConnectionResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.cs new file mode 100644 index 000000000000..91bac328ab96 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/PrivateEndpointConnectionResourceData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A class representing the PrivateEndpointConnectionResource data model. + /// Represents a Private Endpoint Connection ARM resource - a sub-resource of Notification Hubs namespace. + /// + public partial class PrivateEndpointConnectionResourceData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PrivateEndpointConnectionResourceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Private Endpoint Connection properties. + /// Keeps track of any properties unknown to the library. + internal PrivateEndpointConnectionResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, PrivateEndpointConnectionProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Private Endpoint Connection properties. + public PrivateEndpointConnectionProperties Properties { get; set; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/ProviderConstants.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..d6491e1c1ec7 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/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.Notificationhubs +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespaceResourcesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespaceResourcesRestOperations.cs new file mode 100644 index 000000000000..4fb422e53a98 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespaceResourcesRestOperations.cs @@ -0,0 +1,975 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class NamespaceResourcesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NamespaceResourcesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public NamespaceResourcesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Returns the given namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceResourceData.DeserializeNamespaceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NamespaceResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Returns the given namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceResourceData.DeserializeNamespaceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NamespaceResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, NamespaceResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string namespaceName, NamespaceResourceData 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates / Updates a Notification Hub namespace. This operation is idempotent. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, namespaceName, 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); + } + } + + /// Creates / Updates a Notification Hub namespace. This operation is idempotent. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, namespaceName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, NamespaceResourcePatch 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string namespaceName, NamespaceResourcePatch 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Patches the existing namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceResourceData.DeserializeNamespaceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Patches the existing namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// 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 namespaceName, NamespaceResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceResourceData.DeserializeNamespaceResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace 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 namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string skipToken, int? top) + { + 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.NotificationHubs/namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string skipToken, int? top) + { + 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.NotificationHubs/namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the available namespaces within a resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the available namespaces within a resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAllRequestUri(string subscriptionId, string skipToken, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + return uri; + } + + internal HttpMessage CreateListAllRequest(string subscriptionId, string skipToken, int? top) + { + 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.NotificationHubs/namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists all the available namespaces within the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAllAsync(string subscriptionId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListAllRequest(subscriptionId, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the available namespaces within the subscription. + /// The ID of the target subscription. The value must be an UUID. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListAll(string subscriptionId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListAllRequest(subscriptionId, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCheckNotificationHubAvailabilityRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, CheckAvailabilityContent content) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/checkNotificationHubAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCheckNotificationHubAvailabilityRequest(string subscriptionId, string resourceGroupName, string namespaceName, CheckAvailabilityContent 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/checkNotificationHubAvailability", 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, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Checks the availability of the given notificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> CheckNotificationHubAvailabilityAsync(string subscriptionId, string resourceGroupName, string namespaceName, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckNotificationHubAvailabilityRequest(subscriptionId, resourceGroupName, namespaceName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CheckAvailabilityResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CheckAvailabilityResult.DeserializeCheckAvailabilityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Checks the availability of the given notificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Request content. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response CheckNotificationHubAvailability(string subscriptionId, string resourceGroupName, string namespaceName, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckNotificationHubAvailabilityRequest(subscriptionId, resourceGroupName, namespaceName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CheckAvailabilityResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CheckAvailabilityResult.DeserializeCheckAvailabilityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetPnsCredentialsRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/pnsCredentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetPnsCredentialsRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/pnsCredentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the PNS credentials associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetPnsCredentialsAsync(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateGetPnsCredentialsRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PnsCredentialsResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = PnsCredentialsResource.DeserializePnsCredentialsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the PNS credentials associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response GetPnsCredentials(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateGetPnsCredentialsRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PnsCredentialsResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = PnsCredentialsResource.DeserializePnsCredentialsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string skipToken, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string skipToken, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the available namespaces within a resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the available namespaces within a resource group. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAllNextPageRequestUri(string nextLink, string subscriptionId, string skipToken, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListAllNextPageRequest(string nextLink, string subscriptionId, string skipToken, int? top) + { + 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 all the available namespaces within the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListAllNextPageAsync(string nextLink, string subscriptionId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListAllNextPageRequest(nextLink, subscriptionId, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists all the available namespaces within the subscription. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// Skip token for subsequent requests. + /// Maximum number of results to return. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListAllNextPage(string nextLink, string subscriptionId, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListAllNextPageRequest(nextLink, subscriptionId, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NamespaceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NamespaceListResult.DeserializeNamespaceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesOperationGroupRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesOperationGroupRestOperations.cs new file mode 100644 index 000000000000..c6eaabb1921a --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesOperationGroupRestOperations.cs @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class NamespacesOperationGroupRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NamespacesOperationGroupRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public NamespacesOperationGroupRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateCheckAvailabilityRequestUri(string subscriptionId, CheckAvailabilityContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/checkNamespaceAvailability", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCheckAvailabilityRequest(string subscriptionId, CheckAvailabilityContent 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("/providers/Microsoft.NotificationHubs/checkNamespaceAvailability", 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, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// The ID of the target subscription. The value must be an UUID. + /// The request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> CheckAvailabilityAsync(string subscriptionId, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckAvailabilityRequest(subscriptionId, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CheckAvailabilityResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = CheckAvailabilityResult.DeserializeCheckAvailabilityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. + /// The ID of the target subscription. The value must be an UUID. + /// The request body. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response CheckAvailability(string subscriptionId, CheckAvailabilityContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCheckAvailabilityRequest(subscriptionId, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CheckAvailabilityResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = CheckAvailabilityResult.DeserializeCheckAvailabilityResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesRestOperations.cs new file mode 100644 index 000000000000..a3c46c746a03 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NamespacesRestOperations.cs @@ -0,0 +1,735 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class NamespacesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NamespacesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public NamespacesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets an authorization rule for a namespace by name. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateGetAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedAccessAuthorizationRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets an authorization rule for a namespace by name. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response GetAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateGetAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedAccessAuthorizationRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates an authorization rule for a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> CreateOrUpdateAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates an authorization rule for a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdateAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes a namespace authorization rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateDeleteAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes a namespace authorization rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response DeleteAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateDeleteAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAuthorizationRulesRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListAuthorizationRulesRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the authorization rules for a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAuthorizationRulesAsync(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListAuthorizationRulesRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the authorization rules for a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListAuthorizationRules(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListAuthorizationRulesRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListKeysRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/listKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListKeysRequest(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/listKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the Primary and Secondary ConnectionStrings to the namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListKeysAsync(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the Primary and Secondary ConnectionStrings to the namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListKeys(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateRegenerateKeysRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, PolicyKeyResource policyKeyResource) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/regenerateKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateRegenerateKeysRequest(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, PolicyKeyResource policyKeyResource) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/regenerateKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(policyKeyResource, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> RegenerateKeysAsync(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var message = CreateRegenerateKeysRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName, policyKeyResource); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response RegenerateKeys(string subscriptionId, string resourceGroupName, string namespaceName, string authorizationRuleName, PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var message = CreateRegenerateKeysRequest(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName, policyKeyResource); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAuthorizationRulesNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListAuthorizationRulesNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the authorization rules for a namespace. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAuthorizationRulesNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListAuthorizationRulesNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the authorization rules for a namespace. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListAuthorizationRulesNextPage(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListAuthorizationRulesNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NotificationHubResourcesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NotificationHubResourcesRestOperations.cs new file mode 100644 index 000000000000..b5e5cf02a3f8 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/NotificationHubResourcesRestOperations.cs @@ -0,0 +1,859 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class NotificationHubResourcesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of NotificationHubResourcesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public NotificationHubResourcesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the notification hub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub 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 namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationHubResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NotificationHubResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the notification hub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub 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 namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationHubResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NotificationHubResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, NotificationHubResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, NotificationHubResourceData 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates/Update a NotificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// Request content. + /// 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 namespaceName, string notificationHubName, NotificationHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + NotificationHubResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates/Update a NotificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// Request content. + /// 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 namespaceName, string notificationHubName, NotificationHubResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + NotificationHubResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, NotificationHubResourcePatch 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, NotificationHubResourcePatch 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Patch a NotificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// Request content. + /// 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 namespaceName, string notificationHubName, NotificationHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationHubResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Patch a NotificationHub in a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// Request content. + /// 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 namespaceName, string notificationHubName, NotificationHubResourcePatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationHubResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationHubResourceData.DeserializeNotificationHubResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes a notification hub associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub 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 namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes a notification hub associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub 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 namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string skipToken, int? top) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string namespaceName, string skipToken, int? top) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (skipToken != null) + { + uri.AppendQuery("$skipToken", skipToken, true); + } + if (top != null) + { + uri.AppendQuery("$top", top.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the notification hubs associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string namespaceName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, namespaceName, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationHubListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationHubListResult.DeserializeNotificationHubListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the notification hubs associated with a namespace. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string namespaceName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, namespaceName, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationHubListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationHubListResult.DeserializeNotificationHubListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDebugSendRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/debugsend", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDebugSendRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/debugsend", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Test send a push notification. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> DebugSendAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateDebugSendRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DebugSendResponseResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = DebugSendResponseResult.DeserializeDebugSendResponseResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Test send a push notification. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response DebugSend(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateDebugSendRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DebugSendResponseResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = DebugSendResponseResult.DeserializeDebugSendResponseResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetPnsCredentialsRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/pnsCredentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetPnsCredentialsRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/pnsCredentials", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the PNS Credentials associated with a notification hub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetPnsCredentialsAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateGetPnsCredentialsRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PnsCredentialsResource value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = PnsCredentialsResource.DeserializePnsCredentialsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the PNS Credentials associated with a notification hub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Notification Hub name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response GetPnsCredentials(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateGetPnsCredentialsRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PnsCredentialsResource value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = PnsCredentialsResource.DeserializePnsCredentialsResource(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string skipToken, int? top) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string skipToken, int? top) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Lists the notification hubs associated with a namespace. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName, skipToken, top); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationHubListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationHubListResult.DeserializeNotificationHubListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the notification hubs associated with a namespace. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Continuation token. + /// Page size. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string skipToken = null, int? top = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName, skipToken, top); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationHubListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationHubListResult.DeserializeNotificationHubListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/OperationsRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/OperationsRestOperations.cs new file mode 100644 index 000000000000..bc32bb6dbd91 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/OperationsRestOperations.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class OperationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of OperationsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public OperationsRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri() + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.NotificationHubs/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.NotificationHubs/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List the operations for the provider. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink) + { + 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 operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateEndpointConnectionResourcesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateEndpointConnectionResourcesRestOperations.cs new file mode 100644 index 000000000000..7b181165c579 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateEndpointConnectionResourcesRestOperations.cs @@ -0,0 +1,543 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class PrivateEndpointConnectionResourcesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of PrivateEndpointConnectionResourcesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public PrivateEndpointConnectionResourcesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection 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 namespaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((PrivateEndpointConnectionResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Returns a Private Endpoint Connection with a given name. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection 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 namespaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = PrivateEndpointConnectionResourceData.DeserializePrivateEndpointConnectionResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((PrivateEndpointConnectionResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName, PrivateEndpointConnectionResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName, PrivateEndpointConnectionResourceData 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection Name. + /// Description of the Private Endpoint Connection resource. + /// 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 namespaceName, string privateEndpointConnectionName, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName, 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); + } + } + + /// + /// Approves or rejects Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection Name. + /// Description of the Private Endpoint Connection resource. + /// 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 namespaceName, string privateEndpointConnectionName, PrivateEndpointConnectionResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string namespaceName, string privateEndpointConnectionName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections/", false); + uri.AppendPath(privateEndpointConnectionName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Deletes the Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection 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 namespaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Deletes the Private Endpoint Connection. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Private Endpoint Connection 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 namespaceName, string privateEndpointConnectionName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(privateEndpointConnectionName, nameof(privateEndpointConnectionName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateEndpointConnections", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = PrivateEndpointConnectionResourceListResult.DeserializePrivateEndpointConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = PrivateEndpointConnectionResourceListResult.DeserializePrivateEndpointConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + 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; + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = PrivateEndpointConnectionResourceListResult.DeserializePrivateEndpointConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + /// This is a public API that can be called directly by Notification Hubs users. + /// + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + PrivateEndpointConnectionResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = PrivateEndpointConnectionResourceListResult.DeserializePrivateEndpointConnectionResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs new file mode 100644 index 000000000000..31d73646fdce --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/PrivateLinkResourcesRestOperations.cs @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class PrivateLinkResourcesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of PrivateLinkResourcesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public PrivateLinkResourcesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetGroupIdRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string subResourceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateLinkResources/", false); + uri.AppendPath(subResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetGroupIdRequest(string subscriptionId, string resourceGroupName, string namespaceName, string subResourceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateLinkResources/", false); + uri.AppendPath(subResourceName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetGroupIdAsync(string subscriptionId, string resourceGroupName, string namespaceName, string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var message = CreateGetGroupIdRequest(subscriptionId, resourceGroupName, namespaceName, subResourceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceDataData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationhubsPrivateLinkResourceDataData.DeserializeNotificationhubsPrivateLinkResourceDataData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NotificationhubsPrivateLinkResourceDataData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// Name of the Private Link sub-resource. The only supported sub-resource is "namespace". + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response GetGroupId(string subscriptionId, string resourceGroupName, string namespaceName, string subResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(subResourceName, nameof(subResourceName)); + + using var message = CreateGetGroupIdRequest(subscriptionId, resourceGroupName, namespaceName, subResourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceDataData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationhubsPrivateLinkResourceDataData.DeserializeNotificationhubsPrivateLinkResourceDataData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((NotificationhubsPrivateLinkResourceDataData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListGroupIdsRequestUri(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateLinkResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListGroupIdsRequest(string subscriptionId, string resourceGroupName, string namespaceName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/privateLinkResources", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListGroupIdsAsync(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListGroupIdsRequest(subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationhubsPrivateLinkResourceListResult.DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListGroupIds(string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListGroupIdsRequest(subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationhubsPrivateLinkResourceListResult.DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListGroupIdsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListGroupIdsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName) + { + 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; + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListGroupIdsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListGroupIdsNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = NotificationhubsPrivateLinkResourceListResult.DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// + /// Even though this namespace requires subscription id, resource group and namespace name, it returns a constant payload (for a given namespacE) every time it's called. + /// That's why we don't send it to the sibling RP, but process it directly in the scale unit that received the request. + /// + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Namespace name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListGroupIdsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + + using var message = CreateListGroupIdsNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + NotificationhubsPrivateLinkResourceListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = NotificationhubsPrivateLinkResourceListResult.DeserializeNotificationhubsPrivateLinkResourceListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/SharedAccessAuthorizationRuleResourcesRestOperations.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/SharedAccessAuthorizationRuleResourcesRestOperations.cs new file mode 100644 index 000000000000..c72d2844b026 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/RestOperations/SharedAccessAuthorizationRuleResourcesRestOperations.cs @@ -0,0 +1,787 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + internal partial class SharedAccessAuthorizationRuleResourcesRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of SharedAccessAuthorizationRuleResourcesRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public SharedAccessAuthorizationRuleResourcesRestOperations(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 ?? "2023-10-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets an authorization rule for a NotificationHub by name. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateGetAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedAccessAuthorizationRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets an authorization rule for a NotificationHub by name. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response GetAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateGetAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedAccessAuthorizationRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Creates/Updates an authorization rule for a NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> CreateOrUpdateAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Creates/Updates an authorization rule for a NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response CreateOrUpdateAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, SharedAccessAuthorizationRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + SharedAccessAuthorizationRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleResourceData.DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteAuthorizationRuleRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteAuthorizationRuleRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Deletes a notificationHub authorization rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAuthorizationRuleAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateDeleteAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Deletes a notificationHub authorization rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response DeleteAuthorizationRule(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateDeleteAuthorizationRuleRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAuthorizationRulesRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListAuthorizationRulesRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the authorization rules for a NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAuthorizationRulesAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateListAuthorizationRulesRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the authorization rules for a NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListAuthorizationRules(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateListAuthorizationRulesRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListKeysRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/listKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListKeysRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/listKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the Primary and Secondary ConnectionStrings to the NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> ListKeysAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the Primary and Secondary ConnectionStrings to the NotificationHub. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response ListKeys(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + + using var message = CreateListKeysRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateRegenerateKeysRequestUri(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, PolicyKeyResource policyKeyResource) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/regenerateKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateRegenerateKeysRequest(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, PolicyKeyResource policyKeyResource) + { + 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.NotificationHubs/namespaces/", false); + uri.AppendPath(namespaceName, true); + uri.AppendPath("/notificationHubs/", false); + uri.AppendPath(notificationHubName, true); + uri.AppendPath("/authorizationRules/", false); + uri.AppendPath(authorizationRuleName, true); + uri.AppendPath("/regenerateKeys", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(policyKeyResource, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> RegenerateKeysAsync(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var message = CreateRegenerateKeysRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, policyKeyResource); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The name of the SharedAccessAuthorizationRuleResource. + /// Request content. + /// The cancellation token to use. + /// , , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response RegenerateKeys(string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, string authorizationRuleName, PolicyKeyResource policyKeyResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + Argument.AssertNotNullOrEmpty(authorizationRuleName, nameof(authorizationRuleName)); + Argument.AssertNotNull(policyKeyResource, nameof(policyKeyResource)); + + using var message = CreateRegenerateKeysRequest(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, policyKeyResource); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ResourceListKeys value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = ResourceListKeys.DeserializeResourceListKeys(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListAuthorizationRulesNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListAuthorizationRulesNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets the authorization rules for a NotificationHub. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListAuthorizationRulesNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateListAuthorizationRulesNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName, notificationHubName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets the authorization rules for a NotificationHub. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the NamespaceResource. + /// The name of the NotificationHubResource. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListAuthorizationRulesNextPage(string nextLink, string subscriptionId, string resourceGroupName, string namespaceName, string notificationHubName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(namespaceName, nameof(namespaceName)); + Argument.AssertNotNullOrEmpty(notificationHubName, nameof(notificationHubName)); + + using var message = CreateListAuthorizationRulesNextPageRequest(nextLink, subscriptionId, resourceGroupName, namespaceName, notificationHubName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedAccessAuthorizationRuleListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = SharedAccessAuthorizationRuleListResult.DeserializeSharedAccessAuthorizationRuleListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.Serialization.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.Serialization.cs new file mode 100644 index 000000000000..ed68b865e2da --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.Serialization.cs @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + public partial class SharedAccessAuthorizationRuleResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Rights)) + { + writer.WritePropertyName("rights"u8); + writer.WriteStartArray(); + foreach (var item in Rights) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PrimaryKey)) + { + writer.WritePropertyName("primaryKey"u8); + writer.WriteStringValue(PrimaryKey); + } + if (Optional.IsDefined(SecondaryKey)) + { + writer.WritePropertyName("secondaryKey"u8); + writer.WriteStringValue(SecondaryKey); + } + if (options.Format != "W" && Optional.IsDefined(KeyName)) + { + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedOn)) + { + writer.WritePropertyName("modifiedTime"u8); + writer.WriteStringValue(ModifiedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("createdTime"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ClaimType)) + { + writer.WritePropertyName("claimType"u8); + writer.WriteStringValue(ClaimType); + } + if (options.Format != "W" && Optional.IsDefined(ClaimValue)) + { + writer.WritePropertyName("claimValue"u8); + writer.WriteStringValue(ClaimValue); + } + if (options.Format != "W" && Optional.IsDefined(Revision)) + { + writer.WritePropertyName("revision"u8); + writer.WriteNumberValue(Revision.Value); + } + writer.WriteEndObject(); + } + + SharedAccessAuthorizationRuleResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement, options); + } + + internal static SharedAccessAuthorizationRuleResourceData DeserializeSharedAccessAuthorizationRuleResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IList rights = default; + string primaryKey = default; + string secondaryKey = default; + string keyName = default; + DateTimeOffset? modifiedTime = default; + DateTimeOffset? createdTime = default; + string claimType = default; + string claimValue = default; + int? revision = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("rights"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(new AccessRight(item.GetString())); + } + rights = array; + continue; + } + if (property0.NameEquals("primaryKey"u8)) + { + primaryKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("secondaryKey"u8)) + { + secondaryKey = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("keyName"u8)) + { + keyName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("modifiedTime"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("createdTime"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdTime = property0.Value.GetDateTimeOffset("O"); + continue; + } + if (property0.NameEquals("claimType"u8)) + { + claimType = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("claimValue"u8)) + { + claimValue = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("revision"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + revision = property0.Value.GetInt32(); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedAccessAuthorizationRuleResourceData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + rights ?? new ChangeTrackingList(), + primaryKey, + secondaryKey, + keyName, + modifiedTime, + createdTime, + claimType, + claimValue, + revision, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureResourceManagerNotificationhubsContext.Default); + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleResourceData)} does not support writing '{options.Format}' format."); + } + } + + SharedAccessAuthorizationRuleResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSharedAccessAuthorizationRuleResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedAccessAuthorizationRuleResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.cs new file mode 100644 index 000000000000..520ce501aafd --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Generated/SharedAccessAuthorizationRuleResourceData.cs @@ -0,0 +1,128 @@ +// 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.Notificationhubs.Models; + +namespace Azure.ResourceManager.Notificationhubs +{ + /// + /// A class representing the SharedAccessAuthorizationRuleResource data model. + /// Response for POST requests that return single SharedAccessAuthorizationRule. + /// + public partial class SharedAccessAuthorizationRuleResourceData : TrackedResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The location. + public SharedAccessAuthorizationRuleResourceData(AzureLocation location) : base(location) + { + Rights = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// Gets or sets the rights associated with the rule. + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + /// Gets a string that describes the authorization rule. + /// Gets the last modified time for this rule. + /// Gets the created time for this rule. + /// Gets a string that describes the claim type. + /// Gets a string that describes the claim value. + /// Gets the revision number for the rule. + /// Keeps track of any properties unknown to the library. + internal SharedAccessAuthorizationRuleResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, IList rights, string primaryKey, string secondaryKey, string keyName, DateTimeOffset? modifiedOn, DateTimeOffset? createdOn, string claimType, string claimValue, int? revision, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Rights = rights; + PrimaryKey = primaryKey; + SecondaryKey = secondaryKey; + KeyName = keyName; + ModifiedOn = modifiedOn; + CreatedOn = createdOn; + ClaimType = claimType; + ClaimValue = claimValue; + Revision = revision; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SharedAccessAuthorizationRuleResourceData() + { + } + + /// Gets or sets the rights associated with the rule. + public IList Rights { get; } + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + public string PrimaryKey { get; set; } + /// + /// Gets a base64-encoded 256-bit primary key for signing and + /// validating the SAS token. + /// + public string SecondaryKey { get; set; } + /// Gets a string that describes the authorization rule. + public string KeyName { get; } + /// Gets the last modified time for this rule. + public DateTimeOffset? ModifiedOn { get; } + /// Gets the created time for this rule. + public DateTimeOffset? CreatedOn { get; } + /// Gets a string that describes the claim type. + public string ClaimType { get; } + /// Gets a string that describes the claim value. + public string ClaimValue { get; } + /// Gets the revision number for the rule. + public int? Revision { get; } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Properties/AssemblyInfo.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..8fec7c63c58e --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.ResourceManager.Notificationhubs.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Notificationhubs")] diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/Azure.ResourceManager.Notificationhubs.Tests.csproj b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/Azure.ResourceManager.Notificationhubs.Tests.csproj new file mode 100644 index 000000000000..b79324d35b72 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/Azure.ResourceManager.Notificationhubs.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestBase.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestBase.cs new file mode 100644 index 000000000000..d2d83384f2e9 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Notificationhubs.Tests +{ + public class NotificationhubsManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected NotificationhubsManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected NotificationhubsManagementTestBase(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/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestEnvironment.cs b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestEnvironment.cs new file mode 100644 index 000000000000..0a932e26e8b7 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tests/NotificationhubsManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Notificationhubs.Tests +{ + public class NotificationhubsManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tsp-location.yaml b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tsp-location.yaml new file mode 100644 index 000000000000..88b5b4d67d97 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.Notificationhubs/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/notificationhubs/Notificationhubs.Management +commit: 667754246f5134bee75359ea2cd11a3c3f52d511 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index 9ae0a7e75290..4e6f0e6648bb 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -147,6 +147,7 @@ trigger: - sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability - sdk/nginx/Azure.ResourceManager.Nginx - sdk/notificationhubs/Azure.ResourceManager.NotificationHubs + - sdk/notificationhubs/Azure.ResourceManager.Notificationhubs - sdk/openenergyplatform/Azure.ResourceManager.EnergyServices - sdk/operationalinsights/Azure.ResourceManager.OperationalInsights - sdk/oracle/Azure.ResourceManager.OracleDatabase @@ -363,6 +364,7 @@ pr: - sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability - sdk/nginx/Azure.ResourceManager.Nginx - sdk/notificationhubs/Azure.ResourceManager.NotificationHubs + - sdk/notificationhubs/Azure.ResourceManager.Notificationhubs - sdk/openenergyplatform/Azure.ResourceManager.EnergyServices - sdk/operationalinsights/Azure.ResourceManager.OperationalInsights - sdk/oracle/Azure.ResourceManager.OracleDatabase diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 2ca0501b60bd..4e749e6b85b1 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -12,6 +12,8 @@ trigger: - sdk/storage/Azure.Storage.DataMovement/ - sdk/storage/Azure.Storage.DataMovement.Blobs/ - sdk/storage/Azure.Storage.DataMovement.Files/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/ exclude: - sdk/storage/Azure.ResourceManager.Storage/